示例#1
0
 /** @test */
 public function it_logout_user()
 {
     $this->login();
     $this->visit(user_homepage())->submitForm('#logout-form', ['_token' => csrf_token()])->seePageIs(guest_homepage());
     $this->assertFalse(Auth::check());
 }
 /** @test */
 public function it_activate_account()
 {
     $user = $this->register();
     $this->visit('/auth/register/activate?email=' . $user->email . '&confirmation_code=' . $user->userInfo->confirmation_code)->seePageIs(user_homepage())->assertResponseOk();
 }
示例#3
0
 /** @test */
 public function it_redirect_to_homepage_after_successful_login()
 {
     Hash::shouldReceive('check')->once()->andReturn(true)->shouldReceive('needsRehash')->once()->andReturn(false);
     $user = $this->getUserForAuth();
     $this->visit('/auth/login')->submitForm(['email' => $user->email, 'password' => 'test123', 'remember' => '1'])->seePageIs(user_homepage());
 }
 /**
  * Action to activate account.
  * @url /auth/register/activate?email={email}&confirmation_code={confirmation_code}
  * @param Registrar $registrar
  * @return \Illuminate\Http\RedirectResponse
  * @throws NotFoundException
  */
 public function activateAccount(Registrar $registrar)
 {
     $validationResult = $this->validate(ActivateAccountRequest::class);
     if (!$validationResult->isValid()) {
         throw new NotFoundException();
     }
     $data = $this->getValidatedData();
     $success = true;
     try {
         $registrar->activate($data['email'], $data['confirmation_code']);
         $message = trans('auth.activate_account.account_confirmed');
     } catch (EmailNotFoundException $e) {
         $success = false;
         $message = trans('auth.activate_account.invalid_data');
     } catch (InvalidConfirmationCodeException $e) {
         $success = false;
         $message = trans('auth.activate_account.invalid_data');
     } catch (AlreadyConfirmedException $e) {
         $message = trans('auth.activate_account.already_verified');
     }
     $redirectTo = Auth::check() ? user_homepage() : '/auth/login';
     $messageKey = $success ? 'message.auth_activate_account' : 'message.auth_activate_account_failed';
     return redirect($redirectTo)->with($messageKey, $message);
 }