コード例 #1
0
ファイル: PAMUserProvider.php プロジェクト: SYpanel/SYpanel
 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
0
 /**
  * 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
0
 /**
  * @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;
 }
 /**
  * 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
0
ファイル: UserLoggedIn.php プロジェクト: vitalysemenov/oauth
 /**
  * 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
0
 /**
  * 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
0
ファイル: JwtGuard.php プロジェクト: wisoot/jwt-guard
 /**
  * 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
0
 /**
  * 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
0
 /**
  * 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
0
 /**
  * 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
0
 /**
  * @param Authenticatable $user
  * @return Volunteer
  */
 public function join(Authenticatable $user)
 {
     $uid = $user->getAuthIdentifier();
     return Volunteer::updateOrCreate(['user_id' => $uid, 'pending' => true, 'accepted' => false]);
 }
コード例 #12
0
 /**
  * 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
0
 /**
  * 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
0
 /**
  * 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
0
ファイル: Guard.php プロジェクト: framgia/laravel-jwt
 /**
  * @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();
 }
コード例 #16
0
ファイル: UserProvider.php プロジェクト: stevedien/gatekeeper
 /**
  * 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)
 {
     $username = $user->getAuthIdentifier();
     $credentials = ['username' => $username, 'password' => $credentials['password']];
     return Gatekeeper::authenticate($credentials);
 }
コード例 #17
0
 public function addCheck(Authenticatable $user, $ability, $result, $arguments = [])
 {
     $label = $result ? 'success' : 'error';
     $this->addMessage(['ability' => $ability, 'result' => $result, 'user' => $user->getAuthIdentifier(), 'arguments' => $arguments], $label, false);
 }
コード例 #18
0
 /**
  * @param Authenticatable $user
  * @return string|null
  */
 public static function getUserTier(Authenticatable $user)
 {
     $tx = Transaction::where('buyer_id', $user->getAuthIdentifier())->first();
     return isset($tx) ? $tx->product : null;
 }
 /**
  * Update user password if he wants
  *
  * @param \Illuminate\Contracts\Auth\Authenticatable $user
  * @param                                            $plainPass
  */
 public function updatePassword(Authenticatable $user, $plainPass)
 {
     $field = config('auth.password_field', 'password');
     $this->conn->table($this->table)->where('id', $user->getAuthIdentifier())->update([$field => $this->hasher->make($plainPass)]);
 }
コード例 #20
0
ファイル: TokenGuard.php プロジェクト: iget-master/api-base
 /**
  * Log a user into the application.
  *
  * @param  \Illuminate\Contracts\Auth\Authenticatable  $user
  * @return void
  */
 public function login(AuthenticatableContract $user)
 {
     $lifetime = config('session.lifetime');
     $user_id = $user->getAuthIdentifier();
     $expires_on = Carbon::now()->addMinutes($lifetime);
     $this->token = $this->generateAuthorizationToken();
     Cache::put('auth:' . $this->token, compact('user_id', 'expires_on'), $lifetime);
     // 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->setUser($user);
 }
コード例 #21
0
 /**
  * Removes a role from an authenticatable
  * @param Authenticatable $authenticatable
  * @param $role
  * @return mixed
  */
 public function dissociateAuthenticatableOfRole(Authenticatable $authenticatable, $role)
 {
     if ($role instanceof Role) {
         $role = $role->id();
     }
     return AuthenticatableRole::where('authenticatable_id', $authenticatable->getAuthIdentifier())->where('authenticatable_type', get_class($authenticatable))->where('role_id', $role)->delete();
 }
コード例 #22
0
 /**
  * Validate a user against the given credentials.
  *
  * @param Authenticatable $user
  * @param  array $credentials
  * @return bool
  */
 public function validateCredentials(Authenticatable $user, array $credentials)
 {
     $userId = $user->getAuthIdentifier();
     return true;
 }
コード例 #23
0
 /**
  * Create the query for the favourite, modal and user
  *
  * @param \Mintbridge\EloquentFavourites\FavouritableInterface $model
  * @param \Illuminate\Contracts\Auth\Authenticatable $user
  */
 private function query(FavouritableInterface $model, Authenticatable $user)
 {
     $query = Favourite::where(Favourite::ATTR_FAVOURITABLE_ID, '=', $model->getFavouritableId())->where(Favourite::ATTR_FAVOURITABLE_TYPE, '=', $model->getFavouritableType())->where(Favourite::ATTR_USER_ID, '=', $user->getAuthIdentifier());
     return $query;
 }
コード例 #24
0
 /**
  * Queue the recaller cookie into the cookie jar.
  *
  * @param  \Illuminate\Contracts\Auth\Authenticatable  $user
  * @return void
  */
 protected function queueRecallerCookie(UserContract $user)
 {
     $value = $user->getAuthIdentifier() . '|' . $user->getRememberToken();
     $this->getCookieJar()->queue($this->createRecaller($value));
 }
コード例 #25
0
ファイル: DatabaseUserProvider.php プロジェクト: denise92/cms
 /**
  * 寫入登入時間及IP 位址
  *
  * @param  \Illuminate\Contracts\Auth\Authenticatable  $user
  * @return void
  */
 public function updateUserInfo(UserContract $user)
 {
     // 寫入登入IP & 時間
     $this->conn->table($this->table)->where('id', $user->getAuthIdentifier())->update(['ip_address' => Request::ip(), 'last_login' => Carbon::now()]);
     // 寫入可用權限以供nav 選單使用
     $role = $this->conn->table($this->table)->join('roles', 'roles.id', '=', 'users.role_id')->select('roles.permissions')->where('users.id', $user->getAuthIdentifier())->first();
     // 寫入可用權限以供nav 選單使用
     $permissions = json_decode($role->permissions);
     if (in_array('all', $permissions)) {
         $permissions = $this->conn->table('permissions')->select('slug')->where('status', 'true')->get();
     } else {
         $permissions = $this->conn->table('permissions')->select('slug')->whereIn('slug', $permissions)->where('status', 'true')->get();
     }
     // dd($permissions);
     foreach ($permissions as $value) {
         $permission[] = $value->slug;
     }
     // dd($permission);
     session(['permissions' => $permission]);
 }