Exemplo n.º 1
0
 /**
  * Activate an existing user.
  *
  * @param int    $id
  * @param string $code
  *
  * @throws \Symfony\Component\HttpKernel\Exception\BadRequestHttpException
  *
  * @return \Illuminate\Http\Response
  */
 public function getActivate($id, $code)
 {
     if (!$id || !$code) {
         throw new BadRequestHttpException();
     }
     try {
         $user = Credentials::getUserProvider()->findById($id);
         if (!$user->attemptActivation($code)) {
             return Redirect::to(Config::get('core.home', '/'))->with('error', 'There was a problem activating this account. Please contact support.');
         }
         $user->addGroup(Credentials::getGroupProvider()->findByName('Users'));
         return Redirect::route('account.login')->with('success', 'Your account has been activated successfully. You may now login.');
     } catch (UserNotFoundException $e) {
         return Redirect::to(Config::get('core.home', '/'))->with('error', 'There was a problem activating this account. Please contact support.');
     } catch (UserAlreadyActivatedException $e) {
         return Redirect::route('account.login')->with('warning', 'You have already activated this account. You may want to login.');
     }
 }