예제 #1
0
 /**
  * @param UserInterface $user
  */
 public function __construct(UserInterface $user = null)
 {
     $this->user = $user;
     if (null === $user || $user->getAuthIdentifier() === null) {
         $this->user = Auth::user();
     }
 }
 public function dispatcher(\Illuminate\Auth\UserInterface $user = null)
 {
     // map the user ID: 1 is guest, otherwise add 100
     $vUID = null === $user ? 1 : $user->getKey() + $this->auth_user_offset;
     // lookup the vanilla user with that ID
     $vUser = User::find($vUID);
     // not there, create
     if (null === $vUser) {
         if (null === $user) {
             if (is_callable($this->create_guest_account)) {
                 $vUser = call_user_func($this->create_guest_account);
             }
             if (!$vUser instanceof User) {
                 throw new NoVanillaUserMappedToGuest();
             }
         } else {
             if (is_callable($this->create_account_for)) {
                 $vUser = call_user_func($this->create_account_for, $vUID, $user);
             }
             if (!$vUser instanceof User) {
                 throw new NoVanillaUserMappedToUser();
             }
         }
         // update authenticated user data
     } else {
         if (null !== $user && is_callable($this->update_account_for)) {
             call_user_func($this->update_account_for, $user, $vUser);
         }
     }
     return $vUser;
 }
예제 #3
0
 /**
  * Set the current user of the application.
  * @todo: find a better way of catching whenever a user is resolved, from cookie, at login etc.
  *
  * @param  \Illuminate\Auth\UserInterface  $user
  * @return void
  */
 public function setUser(IlluminateUserInterface $user)
 {
     $this->user = $user;
     // if $user is valid let it add itself to the LaravelAcl however it sees fit
     if (!$this->acl->hasRole($this->user)) {
         $user->attachToAcl($this->acl);
     }
     $this->loggedOut = false;
 }
예제 #4
0
 /**
  * Creates an auth token for user.
  *
  * @param \Illuminate\Auth\UserInterface $user
  * @return \AuthToken\Token|false
  */
 public function create(UserInterface $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;
 }
 /**
  * Validate a user against the given credentials.
  *
  * @param  \Illuminate\Auth\UserInterface  $user
  * @param  array  $credentials
  * @return bool
  */
 public function validateCredentials(UserInterface $user, array $credentials)
 {
     $plain = $credentials['password'];
     // Is user password valid?
     if (!$this->hasher->check($plain, $user->getAuthPassword())) {
         throw new \Exception('User password is incorrect');
     }
     // Is the user deleted?
     if ($user->deleted_at !== NULL) {
         throw new \Exception('User is deleted');
     }
     return true;
 }
 /**
  * Validate a user against the given credentials.
  *
  * @param  \Illuminate\Auth\UserInterface $user
  * @param  array $credentials
  * @throws \ErrorException
  * @return bool
  */
 public function validateCredentials(UserInterface $user, array $credentials)
 {
     if (!array_key_exists('password', $credentials) || !$credentials['password']) {
         throw new ErrorException('Missing credential: "password"');
     }
     return str_is($credentials['password'], $user->getAuthPassword());
 }
예제 #7
0
 /**
  * Set very basic properties and create user.
  *
  * @param array $profile
  * @return UserInterface
  */
 protected function createUser($profile)
 {
     $this->user->email = $profile['email'];
     $this->user->password = $this->makeUserPassword();
     $this->user->save();
     return $this->user;
 }
예제 #8
0
 /**
  * Notify the provider of the RegisterInfo that the user was now successfuly registered.
  *
  * Attaches the social-auth user to the newly created user
  */
 public function success(UserInterface $user)
 {
     $repository = App::make('Ipunkt\\SocialAuth\\Repositories\\SocialLoginRepository');
     /**
      * @var SocialLoginRepository $repository
      */
     $profile = $this->getProfile();
     $login = $repository->create();
     $login->setIdentifier($profile->getIdentifier());
     $login->setProvider($this->provider);
     $login->setUser($user->getAuthIdentifier());
     $success = $repository->save($login);
     if ($success) {
         Event::fire('social-auth.register', ['user' => $user, 'registerInfo' => $this]);
     }
     return $success;
 }
예제 #9
0
 /**
  * Map ldap user to model
  *
  * @param array                   $ldap
  * @param UserInterface|\Eloquent $model
  *
  * @return mixed
  */
 public function map($ldap, UserInterface $model)
 {
     if (!isset($ldap[strtolower($this->mappings['fields'][Loader::username()])])) {
         return false;
     }
     foreach ($this->mappings['fields'] as $field => $mapped) {
         $mapped = strtolower($mapped);
         if (!isset($ldap[$mapped])) {
             continue;
         }
         if ($mapped == 'useraccountcontrol') {
             if (!in_array($ldap[$mapped][0], $this->locked)) {
                 $ldap[$mapped][0] = true;
             } else {
                 $ldap[$mapped][0] = false;
             }
         }
         $model->{$field} = $ldap[$mapped][0];
     }
     $model->save();
     return $model;
 }
예제 #10
0
 /**
  *  Validate a user against the given credentials.
  */
 public function validateCredentials(UserInterface $user, array $credentials)
 {
     // If password equals than the user is ok to signin.
     return $user->getAuthPassword() == $credentials["password"];
 }
 /**
  * Validate a user against the given credentials.
  *
  * @param  \Illuminate\Auth\UserInterface  $user
  * @param  array  $credentials
  * @return bool
  */
 public function validateCredentials(UserInterface $user, array $credentials)
 {
     return $user->getAuthPassword() === $credentials['password'];
 }
예제 #12
0
 /**
  * Create a new remember token for the user if one doens't already exist.
  *
  * @param  \Illuminate\Auth\UserInterface  $user
  * @return void
  */
 protected function createRememberTokenIfDoesntExist(UserInterface $user)
 {
     if (is_null($user->getRememberToken())) {
         $this->refreshRememberToken($user);
     }
 }
예제 #13
0
 /**
  * Validate a user against the given credentials.
  *
  * @param  \Illuminate\Auth\UserInterface  $user
  * @param  array  $credentials
  * @return bool
  */
 public function validateCredentials(UserInterface $user, array $credentials)
 {
     return $this->hasher->checkhash($credentials['password'], $user->getAuthPassword());
 }
 /**
  * Update the "remember me" token for the given user in storage.
  *
  * @param  \Illuminate\Auth\UserInterface  $user
  * @param  string  $token
  * @return void
  */
 public function updateRememberToken(UserInterface $user, $token)
 {
     $user->setRememberToken($token);
 }
예제 #15
0
 /**
  * Update the "remember me" token for the given user in storage.
  *
  * @param  \Illuminate\Auth\UserInterface  $user
  * @param  string  $token
  * @return null
  */
 public function updateRememberToken(\Illuminate\Auth\UserInterface $user, $token)
 {
     if ($user != null) {
         $user->setRememberToken(\App::make('crowd-auth')->ssoUpdateToken($token, filter_var($_SERVER['REMOTE_ADDR'], FILTER_VALIDATE_IP, FILTER_FLAG_IPV4)));
     }
     return null;
 }
예제 #16
0
 /**
  * Remove / delete an activity from the Notification for the user
  * @param Notification $notification
  * @param string $activity
  * @param UserInterface $user
  * @return bool
  */
 public function removeActivity(Notification $notification, $activity, UserInterface $user)
 {
     try {
         /**
          * using index
          */
         $user_activity = $notification->activities()->where('user_id', $user->getAuthIdentifier())->where('activity', $activity)->firstOrFail();
         if ($user_activity->delete()) {
             return true;
         }
         return false;
     } catch (\Exception $e) {
         return false;
     }
 }
예제 #17
0
 /**
  * Attempt to save updates to the User
  *
  * @return boolean
  */
 public function save(UserInterface $user)
 {
     $user->save();
 }
 /**
  * Validate a user against the given credentials.
  *
  * @param \Illuminate\Auth\UserInterface $user
  * @param array $credentials
  * @return bool
  */
 public function validateCredentials(UserInterface $user, array $credentials)
 {
     $plain = $credentials['password'];
     return $this->hasher->CheckPassword($plain, $user->getAuthPassword());
 }
예제 #19
0
파일: Guard.php 프로젝트: rohitbhalani/xyz
 /**
  * Create a new remember token for the user if one doesn't already exist.
  *
  * @param  \Illuminate\Auth\UserInterface  $user
  * @return void
  */
 protected function createRememberTokenIfDoesntExist(UserInterface $user)
 {
     $rememberToken = $user->getRememberToken();
     if (empty($rememberToken)) {
         $this->refreshRememberToken($user);
     }
 }
 /**
  * Validate a user against the given credentials.
  *
  * @param  \Illuminate\Auth\UserInterface  $user
  * @param  array                           $credentials
  * @return bool
  */
 public function validateCredentials(UserInterface $user, array $credentials)
 {
     // Collect user data
     $password = $credentials['password'];
     $salt = $this->user->salt;
     $hash = $user->getAuthPassword();
     // Check if user is banned
     if (!$this->user->active) {
         App::abort(403);
         // Forbidden
     }
     return PHPass::make()->check('User', $password, $salt, $hash);
 }
예제 #21
0
 /**
  * Refresh the remember token for the user.
  *
  * @param  \Illuminate\Auth\UserInterface  $user
  * @return void
  */
 protected function refreshRememberToken(UserInterface $user)
 {
     $user->setRememberToken($token = str_random(60));
     $this->provider->updateRememberToken($user, $token);
 }
 /**
  * Validate a user against the given credentials.
  *
  * @param  Auth\UserInterface  $user
  * @param  array  $credentials
  * @return bool
  */
 public function validateCredentials(Auth\UserInterface $user, array $credentials)
 {
     return Hash::check($credentials['password'], $user->getAuthPassword());
 }
예제 #23
0
 /**
  * Validate a user against the given credentials.
  *
  * @param  \Illuminate\Auth\UserInterface  $user
  * @param  array  $credentials
  * @return bool
  */
 public function validateCredentials(UserInterface $user, array $credentials)
 {
     $plain = $credentials['password'];
     $authPassword = $user->getAuthPassword();
     return $authPassword === md5($plain);
     // 		return $this->hasher->check($plain, $user->getAuthPassword());
 }
예제 #24
0
 /**
  * Update the "remember me" token for the given user in storage.
  *
  * @param  \Illuminate\Auth\UserInterface  $user
  * @param  string  $token
  * @return void
  */
 public function updateRememberToken(UserInterface $user, $token)
 {
     $user->remember_token = $token;
     $user->save();
 }
예제 #25
0
 /**
  * Get the link that can be used to automatically login a user to the 
  * application.
  *
  * @param  \Illuminate\Auth\UserInterface  $user
  * @param  string  $path
  * @return string
  */
 protected function getAutologinLink(UserInterface $user, $path = null)
 {
     // If we are supposed to remove expired tokens, let's do it now.
     if (config('autologin.remove_expired')) {
         $this->deleteExpiredTokens();
     }
     // Get the user ID to be associated with a token.
     $userId = $user->getAuthIdentifier();
     // Generate a random unique token that can be used for the link.
     $token = $this->getAutologinToken();
     // Save the token to storage.
     $this->provider->create(['user_id' => $userId, 'token' => $token, 'path' => $path]);
     // Return a link using the route from the configuration file and
     // the generated token.
     $routeName = config('autologin.route_name');
     return $this->generator->route($routeName, $token);
 }
예제 #26
0
 /**
  * Update the "remember me" token for the given user in storage.
  *
  * @param  \Illuminate\Auth\UserInterface  $user
  * @param  string  $token
  * @return void
  */
 public function updateRememberToken(UserInterface $user, $token)
 {
     $this->dm->createQueryBuilder($this->docname)->update()->field('remember_token')->set($token)->field("id")->equals($user->getAuthIdentifier());
 }
예제 #27
0
 /**
  * Queue the recaller cookie into the cookie jar.
  *
  * @param  \Illuminate\Auth\UserInterface  $user
  * @return void
  */
 protected function queueRecallerCookie($user)
 {
     $value = $user->getAuthIdentifier() . '|' . $user->getRememberToken();
     $this->getCookieJar()->queue($this->createRecaller($value));
 }
예제 #28
0
 /**
  * Set or refresh our cookies.
  * 
  * @param  \Illuminate\Auth\UserInterface  $user
  * @param  bool  $remember
  * @return void
  */
 protected function setLoginCookie(UserInterface $user, $remember = false)
 {
     $id = $user->getAuthIdentifier();
     $password = $user->getAuthPassword();
     $cookie = $this->storage->login($id, $password, $remember);
     $this->queueCookie($cookie);
 }
 /**
  * Update the "remember me" token for the given user in storage.
  *
  * @param  \Illuminate\Auth\UserInterface  $user
  * @param  string                          $token
  * @return void
  */
 public function updateRememberToken(UserInterface $user, $token)
 {
     $user->setAttribute($user->getRememberTokenName(), $token);
     $user->save();
 }
 /**
  * Update the "remember me" token for the given user in storage.
  *
  * @param  UserInterface $user
  * @param  string $token
  * @return void
  */
 public function updateRememberToken(UserInterface $user, $token)
 {
     // If Eloquent User
     if (!$user instanceof GenericUser) {
         // Update Remember Me Token
         $user->setAttribute($user->getRememberTokenName(), $token);
         $user->save();
     }
 }