/**
  * Verify user.
  *
  * @param \Krucas\LaravelUserEmailVerification\Contracts\RequiresEmailVerification $user
  * @return void
  */
 protected function verifyUser($user)
 {
     $user->verified = true;
     $user->verified_at = new Carbon('now');
     $user->save();
     Auth::guard($this->getGuard())->login($user);
 }
 /**
  * Check if user is verified or not.
  *
  * @param \Illuminate\Http\Request $request
  * @param \Krucas\LaravelUserEmailVerification\Contracts\RequiresEmailVerification $user
  * @return \Illuminate\Http\RedirectResponse|\Illuminate\Routing\Redirector
  */
 public function authenticated(Request $request, Contracts\RequiresEmailVerification $user)
 {
     if (config('verification.verify') && !$user->isUserEmailVerified()) {
         Auth::guard($this->getGuard())->logout();
         return redirect($this->verificationRedirectPath());
     }
     return redirect()->intended($this->redirectPath());
 }
 /**
  * Send the email verification link via e-mail.
  *
  * @param \Krucas\LaravelUserEmailVerification\Contracts\RequiresEmailVerification $user
  * @param string $token
  * @param \Closure|null $callback
  * @return int
  */
 public function emailVerificationLink(Contracts\RequiresEmailVerification $user, $token, Closure $callback = null)
 {
     $view = $this->emailView;
     return $this->mailer->send($view, compact('token', 'user'), function ($message) use($user, $token, $callback) {
         $message->to($user->getEmailForVerification());
         if (!is_null($callback)) {
             call_user_func($callback, $message, $user, $token);
         }
     });
 }
 /**
  * Determine if a token record exists and is valid.
  *
  * @param \Krucas\LaravelUserEmailVerification\Contracts\RequiresEmailVerification $user
  * @param string $token
  * @return bool
  */
 public function exists(Contracts\RequiresEmailVerification $user, $token)
 {
     $email = $user->getEmailForVerification();
     $token = (array) $this->getTable()->where('email', $email)->where('token', $token)->first();
     return $token && !$this->tokenExpired($token);
 }