/** * {@inheritDoc} */ public function complete(UserInterface $user, $code, $password) { $expires = $this->expires(); $reminder = $this->createModel()->newQuery()->where('user_id', $user->getUserId())->where('code', $code)->where('completed', false)->where('created_at', '>', $expires)->first(); if ($reminder === null) { return false; } $credentials = compact('password'); $valid = $this->validateUser($credentials, $user->getUserId()); if ($valid === false) { return false; } sentinel()->update($user->getUserId(), $credentials); $reminder->fill(['completed' => true, 'completed_at' => Carbon::now()]); $reminder->save(); return true; }
/** * Loads and returns the user throttles collection. * * @param \Cartalyst\Sentinel\Users\UserInterface $user * @return \Illuminate\Database\Eloquent\Collection */ protected function loadUserThrottles(UserInterface $user) { $interval = Carbon::now()->subSeconds($this->userInterval); return $this->createModel()->newQuery()->where('type', 'user')->where('user_id', $user->getUserId())->where('created_at', '>', $interval)->get(); }
/** * Returns the user throttles collection. * * @param \Cartalyst\Sentinel\Users\UserInterface $user * @return \Illuminate\Support\Collection */ protected function getUserThrottles(UserInterface $user) { if (!$this->userThrottles->has($user->getUserId())) { $this->userThrottles[$user->getUserId()] = $this->loadUserThrottles($user); } return $this->userThrottles[$user->getUserId()]; }
/** * {@inheritDoc} */ public function completed(UserInterface $user) { $activation = $this->createModel()->newQuery()->where('user_id', $user->getUserId())->where('completed', true)->first(); return $activation ?: false; }
/** * Fills a user with the given credentials, intelligently. * * @param \Cartalyst\Sentinel\Users\UserInterface $user * @param array $credentials * @return void */ public function fill(UserInterface $user, array $credentials) { $this->fireEvent('sentinel.user.filling', compact('user', 'credentials')); $loginNames = $user->getLoginNames(); list($logins, $password, $attributes) = $this->parseCredentials($credentials, $loginNames); if (is_array($logins)) { $user->fill($logins); } else { $loginName = reset($loginNames); $user->fill([$loginName => $logins]); } $user->fill($attributes); if (isset($password)) { $password = $this->hasher->hash($password); $user->fill(compact('password')); } $this->fireEvent('sentinel.user.filled', compact('user', 'credentials')); }
/** * Validate the password of the given user. * * @param User $user * @param array $credentials * * @return bool */ public function validateCredentials(UserInterface $user, array $credentials) { return $user->checkPassword(array_get($credentials, 'password')); }