/**
  * Activate a user if they have provided the correct code
  * @param  string $code
  * @return Response|Redirect
  */
 public function getActivate(Request $request, $code)
 {
     // Attempt the registration
     $result = $this->authManager->activate($code);
     if ($result->isFailure()) {
         // Normally an exception would trigger a redirect()->back() However,
         // because they get here via direct link, back() will take them
         // to "/";  I would prefer they be sent to the login page.
         $result->setRedirectUrl(route('auth.login.form'));
         return $result->dispatch();
     }
     // Ask the user to check their email for the activation link
     $result->setMessage('Registration complete.  You may now log in.');
     // There is no need to send the payload data to the end user
     $result->clearPayload();
     // Return the appropriate response
     return $result->dispatch(route('dashboard'));
 }
Beispiel #2
0
 /** @test */
 public function it_handles_an_incorrect_activation_code()
 {
     // Given
     $credentials = ['email' => '*****@*****.**', 'password' => 'violin'];
     $result = $this->authManager->register($credentials);
     // Attempt the Activation
     $result = $this->authManager->activate('incorrect_activation_code');
     // Verify
     $this->assertInstanceOf(ExceptionReply::class, $result);
     $this->assertEquals("Invalid or expired activation code.", $result->message);
 }