本文整理汇总了PHP中Illuminate\Contracts\Auth\Authenticatable::getAuthIdentifier方法的典型用法代码示例。如果您正苦于以下问题:PHP Authenticatable::getAuthIdentifier方法的具体用法?PHP Authenticatable::getAuthIdentifier怎么用?PHP Authenticatable::getAuthIdentifier使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Illuminate\Contracts\Auth\Authenticatable
的用法示例。
在下文中一共展示了Authenticatable::getAuthIdentifier方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: validateCredentials
public function validateCredentials(UserContract $user, array $credentials)
{
$profile = $user instanceof Account ? $user : Account::find($user->getAuthIdentifier());
if ($profile && $profile->id == $user->getAuthIdentifier()) {
return static::PAMAuthenticate($profile->username, $credentials['password']);
}
return false;
}
示例2: create
/**
* Creates an auth token for user.
*
* @param \Illuminate\Contracts\Auth\Authenticatable $user
* @return \TAppleby\AuthToken\AuthToken|false
*/
public function create(Authenticatable $user)
{
if ($user == null || $user->getAuthIdentifier() == null) {
return false;
}
$token = $this->generateAuthToken();
$token->setAuthIdentifier($user->getAuthIdentifier());
$t = new \DateTime();
$insertData = array_merge($token->toArray(), array('created_at' => $t, 'updated_at' => $t));
$this->db()->insert($insertData);
return $token;
}
示例3: getOrganizationMember
/**
* @param UserContract $user
* @return OrganizationMember
*/
public function getOrganizationMember(UserContract $user)
{
$memberClass = $this->getOrgMemberClass();
$queryMethod = $memberClass->getMethod('query');
$builder = $queryMethod->invoke(null);
$member = $builder->where('user_id', '=', $user->getAuthIdentifier())->first();
return $member;
}
示例4: validateCredentials
/**
* Validate a user against the given credentials.
*
* @param \Illuminate\Contracts\Auth\Authenticatable $user
* @param array $credentials
* @return bool
*/
public function validateCredentials(Authenticatable $user, array $credentials)
{
try {
$result = $this->application->authenticate($credentials['email'], $credentials['password']);
return $result->account->getHref() == $user->getAuthIdentifier();
} catch (\Exception $e) {
return false;
}
}
示例5: handle
/**
* Handle user logged in.
*
* @param \Illuminate\Contracts\Auth\Authenticatable $user
*
* @return bool|null
*/
public function handle(Authenticatable $user)
{
$social = $this->session->get('authentication.social.oauth');
if (is_null($social)) {
return;
}
$model = User::where('provider', '=', $social['provider'])->where('uid', '=', $social['user']->getId())->first();
if (is_null($model)) {
return;
}
$model->setAttribute('user_id', $user->getAuthIdentifier());
$model->save();
return true;
}
示例6: log
/**
* Log activity
*
* @param string $action
* @param string $description
* @param \Eloquent $content
* @param Authenticatable $user
* @param Request $request
*
* @return bool
*/
public function log($action, $description, $content = null, Authenticatable $user = null, Request $request = null)
{
$user_id = null;
$user_type = null;
$user_name = null;
if ($user) {
$user_id = $user->getAuthIdentifier();
$user_type = get_class($user);
$user_name = $user->getAuthIdentifierName();
}
$content_type = is_object($content) ? get_class($content) : null;
$content_id = is_object($content) ? $content->id : null;
$ip_address = $request->ip();
return (bool) $this->model->create(['action' => $action, 'user_id' => $user_id, 'user_type' => $user_type, 'user_name' => $user_name, 'description' => $description, 'ip_address' => $ip_address, 'content_type' => $content_type, 'content_id' => $content_id]);
}
示例7: login
/**
* Log a user into the application.
*
* @param \Illuminate\Contracts\Auth\Authenticatable $user
* @return void
*/
public function login(AuthenticatableContract $user)
{
$claim = new Claim(['sub' => $user->getAuthIdentifier(), 'aud' => get_class($user), 'refresh' => Config::get('jwt.refreshable')]);
$token = $this->jwtService->getTokenForClaim($claim);
// If we have an event dispatcher instance set we will fire an event so that
// any listeners will hook into the authentication events and run actions
// based on the login and logout events fired from the guard instances.
$this->fireLoginEvent($user);
$this->setToken($token);
$this->setUser($user);
}
示例8: updateRememberToken
/**
* Update the "remember me" token for the given user in storage.
*
* @param \Illuminate\Contracts\Auth\Authenticatable $user
* @param string $token
*/
public function updateRememberToken(Authenticatable $user, $token)
{
$this->user->updateRememberToken($user->getAuthIdentifier(), $token);
}
示例9: updateRememberToken
/**
* Update the "remember me" token for the given user in storage.
*
* @param \Illuminate\Contracts\Auth\Authenticatable $user
* @param string $token
* @return void
*/
public function updateRememberToken(Authenticatable $user, $token)
{
$id = $user->getAuthIdentifier();
if ($this->idShouldBeDecorated()) {
$id = $this->makeObjectId($user->getAuthIdentifier());
}
$this->getCollection()->findAndModify([$this->getIdentificationField() => $id], ['$set' => [$this->getRememberTokenField() => $token]]);
}
示例10: updateRememberToken
/**
* Update the "remember me" token for the given user in storage.
*
* @param \Illuminate\Contracts\Auth\Authenticatable $user
* @param string $token
* @return void
*/
public function updateRememberToken(UserContract $user, $token)
{
$this->query->filterById($user->getAuthIdentifier())->update(['RememberToken' => $token]);
}
示例11: join
/**
* @param Authenticatable $user
* @return Volunteer
*/
public function join(Authenticatable $user)
{
$uid = $user->getAuthIdentifier();
return Volunteer::updateOrCreate(['user_id' => $uid, 'pending' => true, 'accepted' => false]);
}
示例12: updateRememberToken
/**
* Update the "remember me" token for the given user in storage.
*
* @param \Illuminate\Contracts\Auth\Authenticatable $user
* @param string $token
* @return void
*/
public function updateRememberToken(UserContract $user, $token)
{
$this->conn->table($this->table)->where('id', $user->getAuthIdentifier())->update(['remember_token' => $token]);
}
示例13: query
/**
* Create the query for the sentiment, modal and user
*
* @param string $sentiment
* @param \Mintbridge\EloquentSentiment\SentimentableInterface $model
* @param \Illuminate\Contracts\Auth\Authenticatable $user
*/
private function query($sentiment, SentimentableInterface $model, Authenticatable $user)
{
$query = Sentiment::where(Sentiment::ATTR_SENTIMENTABLE_ID, '=', $model->getSentimentableId())->where(Sentiment::ATTR_SENTIMENTABLE_TYPE, '=', $model->getSentimentableType())->where(Sentiment::ATTR_SENTIMENT, '=', $sentiment)->where(Sentiment::ATTR_USER_ID, '=', $user->getAuthIdentifier());
return $query;
}
示例14: refreshToken
/**
* Create a new token from the user identifier
*
* @param Authenticatable $user
* @param Token
*/
public function refreshToken(Authenticatable $user)
{
$claims = ['name' => $user->name, 'email' => $user->email, 'locale' => config('app.locale')];
return $this->repository->encode($user->getAuthIdentifier(), $claims);
}
示例15: createTokenForUser
/**
* @param Authenticatable $user
* @return Token
*/
public function createTokenForUser(Authenticatable $user)
{
$builder = new Builder();
$id = $user->getAuthIdentifier();
$builder->setSubject($id);
if ($user instanceof ProvidesCredentials) {
$builder = $this->applyClaims($user->getCredentials(), true, $builder);
}
$builder->setExpiration($this->getExpirationTimestamp());
$builder->setId(Str::random());
return $this->signer->sign($builder)->getToken();
}