/** * 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; }
/** * @param UserInterface $user */ public function __construct(UserInterface $user = null) { $this->user = $user; if (null === $user || $user->getAuthIdentifier() === null) { $this->user = Auth::user(); } }
/** * 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; }
/** * 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)); }
/** * Log a user into the application. * * @param \Illuminate\Auth\UserInterface $user * @param bool $remember * @return void */ public function login(UserInterface $user, $remember = false) { $id = $user->getAuthIdentifier(); $this->session->put($this->getName(), $id); // If the user should be permanently "remembered" by the application we will // queue a permanent cookie that contains the encrypted copy of the user // identifier. We will then decrypt this later to retrieve the users. if ($remember) { $this->createRememberTokenIfDoesntExist($user); $this->queueRecallerCookie($user); } // 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. if (isset($this->events)) { $this->events->fire('auth.login', array($user, $remember)); } $this->setUser($user); }
/** * 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); }
/** * 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->conn->table($this->table)->where('id', $user->getAuthIdentifier())->update(array('remember_token' => $token)); }
/** * 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) { $this->dm->createQueryBuilder($this->docname)->update()->field('remember_token')->set($token)->field("id")->equals($user->getAuthIdentifier()); }
/** * 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; } }
/** * Attempt to find the Profile of User $user with provider $providerName * * @param UserInterface $user * @param string $providerName * @return mixed */ function findByUserAndProvider(UserInterface $user, $providerName) { return SocialProfile::where('provider', '=', $providerName)->whereUserId($user->getAuthIdentifier())->first(); }
public function scopeForUser($query, UserInterface $user) { return $query->where('user_id', '=', $user->getAuthIdentifier())->where('user_model', '=', get_class($user)); }
/** * 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->user->updateToken($user->getAuthIdentifier(), $token); }
/** * Check route access against a user * Again we cache the query so that we dont have to trigger it again * * @param \Illuminate\Database\Query\Builder $query * @return integer $acl */ protected function checkRouteAgainstUser(Builder $query) { return $query->where('user_role.user_id', (int) $this->user->getAuthIdentifier())->rememberForever()->first(); }
/** * 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) { $id = $user->getAuthIdentifier(); //print_r($user); $user->setRememberToken($token); }