示例#1
0
 /**
  * @param $user
  * @return string
  */
 public function apiToken($user)
 {
     $token = \Laravel\Spark\Token::create(['id' => Uuid::uuid4(), 'user_id' => $user->id, 'name' => 'test_token', 'token' => str_random(60), 'metadata' => '[]']);
     return 'api_token=' . $token->token;
 }
示例#2
0
 /**
  * Determine if the current API token is granted a given ability.
  *
  * @param  string  $ability
  * @return bool
  */
 public function tokenCan($ability)
 {
     return $this->currentToken ? $this->currentToken->can($ability) : false;
 }
示例#3
0
 /**
  * {@inheritdoc}
  */
 public function updateToken(Token $token, $name, array $abilities = [])
 {
     $metadata = $token->metadata;
     $metadata['abilities'] = $abilities;
     $token->forceFill(['name' => $name, 'metadata' => $metadata])->save();
 }