Skip to content

Commit

Permalink
✨ Extract generateNewToken method
Browse files Browse the repository at this point in the history
  • Loading branch information
exodusanto committed Jan 28, 2020
1 parent 0e957ad commit e7968c9
Showing 1 changed file with 13 additions and 1 deletion.
14 changes: 13 additions & 1 deletion src/RefreshApiToken.php
Original file line number Diff line number Diff line change
Expand Up @@ -20,14 +20,26 @@ trait RefreshApiToken
*/
protected $apiTokenRefreshedAt = 'api_token_refreshed_at';

/**
* Generate a new token
*
* @return string
*/
protected function generateNewToken()
{
return Str::random(60);
}

/**
* Refresh the api token
*
* @return void
*/
public function refreshApiToken()
{
$this->{$this->apiToken} = Str::random(60);
$token = $this->generateNewToken();

$this->{$this->apiToken} = $token;
$this->{$this->apiTokenRefreshedAt} = now();

$this->save();
Expand Down

0 comments on commit e7968c9

Please sign in to comment.