/** * Try to create session with provided credentials. * * @return Response */ public function store() { $credentials = array('email' => Input::get('email', null), 'password' => Input::get('password', null)); if ($this->auth->auth($credentials)) { return Redirect::route(Config::get('laravel-sentry-backend::login_redirect')); } return Redirect::route('session.create')->with(array('login_error' => $this->auth->getError()))->withInput(); }
public function testAuth() { $credentials = array('email' => '*****@*****.**', 'password' => '123456789abc'); Sentry::shouldReceive('authenticate')->with($credentials, false)->once(); $this->assertTrue($this->auth->auth($credentials)); $credentialsRemember = $credentials + array('remember' => '1'); Sentry::shouldReceive('authenticate')->with($credentials, true)->once(); $this->assertTrue($this->auth->auth($credentialsRemember)); Sentry::shouldReceive('authenticate')->once()->andThrow('Cartalyst\\Sentry\\Users\\UserNotActivatedException'); $this->assertFalse($this->auth->auth($credentials)); $this->assertNotNull($this->auth->getError()); Sentry::shouldReceive('authenticate')->once()->andThrow('Cartalyst\\Sentry\\Throttling\\UserSuspendedException'); $this->assertFalse($this->auth->auth($credentials)); $this->assertNotNull($this->auth->getError()); Sentry::shouldReceive('authenticate')->once()->andThrow('Cartalyst\\Sentry\\Throttling\\UserBannedException'); $this->assertFalse($this->auth->auth($credentials)); $this->assertNotNull($this->auth->getError()); Sentry::shouldReceive('authenticate')->once()->andThrow('Cartalyst\\Sentry\\Users\\UserNotFoundException'); $this->assertFalse($this->auth->auth($credentials)); $this->assertNotNull($this->auth->getError()); Sentry::shouldReceive('authenticate')->once()->andThrow('Cartalyst\\Sentry\\Users\\WrongPasswordException'); $this->assertFalse($this->auth->auth($credentials)); $this->assertNotNull($this->auth->getError()); $credentials['password'] = ''; Sentry::shouldReceive('authenticate')->once()->andThrow('Cartalyst\\Sentry\\Users\\PasswordRequiredException'); $this->assertFalse($this->auth->auth($credentials)); $this->assertNotNull($this->auth->getError()); $credentials['email'] = ''; Sentry::shouldReceive('authenticate')->once()->andThrow('Cartalyst\\Sentry\\Users\\LoginRequiredException'); $this->assertFalse($this->auth->auth($credentials)); $this->assertNotNull($this->auth->getError()); }