/** * Store a newly created user in storage. * * @return Response */ public function store() { if (!$this->validator->validate(Input::all())) { return Redirect::route('users.create')->withErrors($this->validator->getErrors())->withInput(); } $user = array('email' => Input::get('email'), 'password' => Input::get('password'), 'first_name' => Input::get('first_name'), 'last_name' => Input::get('last_name')); if ($user = $this->users->create($user)) { return Redirect::route('users.index'); } return Redirect::route('users.create')->withErrors(array('error' => $this->users->getError())); }
/** * If registration enabled store a newly registered user in storage. */ public function store() { if (!Config::get('laravel-sentry-backend::enable_registrations')) { return App::abort(404); } if ($this->auth->check()) { return Redirect::route('profile.index'); } if (!$this->validator->validate(Input::all())) { return Redirect::route('profile.create')->withErrors($this->validator->getErrors())->withInput(); } $user = array('email' => Input::get('email'), 'password' => Input::get('password'), 'first_name' => Input::get('first_name'), 'last_name' => Input::get('last_name')); if ($user = $this->users->create($user)) { $this->activation->send($user); return Redirect::route('session.create')->with('success_registration', true); } return Redirect::route('profile.create')->withErrors(array('error' => $this->users->getError())); }
public function testCreate() { $credentials = array('email' => '*****@*****.**', 'password' => '123456789'); Sentry::shouldReceive('createUser')->with($credentials)->once()->andReturn(array()); $this->assertEquals(array(), $this->users->create($credentials)); Sentry::shouldReceive('createUser')->once()->andThrow('Cartalyst\\Sentry\\Users\\UserExistsException'); $this->assertFalse($this->users->create($credentials)); $this->assertNotNull($this->users->getError()); Sentry::shouldReceive('createUser')->once()->andThrow('Cartalyst\\Sentry\\Users\\UserExistsException'); $this->assertFalse($this->users->create($credentials)); $this->assertNotNull($this->users->getError()); Sentry::shouldReceive('createUser')->once()->andThrow('Cartalyst\\Sentry\\Groups\\GroupNotFoundException'); $this->assertFalse($this->users->create($credentials)); $this->assertNotNull($this->users->getError()); unset($credentials['password']); Sentry::shouldReceive('createUser')->once()->andThrow('Cartalyst\\Sentry\\Users\\PasswordRequiredException'); $this->assertFalse($this->users->create($credentials)); $this->assertNotNull($this->users->getError()); unset($credentials['email']); Sentry::shouldReceive('createUser')->once()->andThrow('Cartalyst\\Sentry\\Users\\LoginRequiredException'); $this->assertFalse($this->users->create($credentials)); $this->assertNotNull($this->users->getError()); }