Example #1
0
 public function clientConfirm($userId, $token)
 {
     $user = User::findOrFail($userId);
     $result = UserMapper::checkAuthToken($user, $token);
     if ($result) {
         if ($user->is_active == 1) {
             return Redirect::to('/')->withErrors(['client' => 'You already confirmed your email']);
         }
         $user->is_active = 1;
         $user->save();
         $user->authToken()->delete();
         Auth::loginUsingId($user->id, true);
         LogMapper::log('client_login', $user->id, 'finish');
         return redirect('/user/client');
     } else {
         LogMapper::log('client_confirm_failed', $user->id, 'token_mismatch');
         return Redirect::to('/')->withErrors(['client' => 'Wrong confirmation token']);
     }
 }