/** * {@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; }