public function __construct($person = null) { $this->person = $person; if ($this->person !== null && (is_int($this->person) || ctype_digit($this->person))) { $this->person = PersonFacade::find($this->person); } }
public function setPassword() { if ($this->request->method() === 'GET') { return $this->showForm(['token' => $this->request->input('token')]); } $person = Person::findByEmail($this->request->input('email')); if (!$person->isValid()) { return $this->showForm(['error' => Lang::get('boomcms::recover.errors.invalid_email'), 'token' => $this->request->input('token')]); } $tokens = $this->app['auth.password.tokens']; $token = $tokens->exists($person, $this->request->input('token')); if (!$token) { return $this->showForm(['error' => Lang::get('boomcms::recover.errors.invalid_token'), 'token' => $this->request->input('token')]); } if ($this->request->input('password1') != $this->request->input('password2')) { return $this->showForm(['error' => Lang::get('boomcms::recover.errors.password_mismatch'), 'token' => $this->request->input('token')]); } if ($this->request->input('password1') && $this->request->input('password2')) { $tokens->delete($token); $tokens->deleteExpired(); $person->setEncryptedPassword($this->auth->hash($this->request->input('password1'))); Person::save($person); $this->auth->login($person); return redirect('/'); } else { return $this->showForm(['error' => Lang::get('boomcms::recover.errors.password_mismatch'), 'token' => $this->request->input('token')]); } }
public function handle(SuccessfulLogin $event) { $person = $event->getPerson(); $person->setLastFailedLogin(null); $person->setFailedLogins(0); Person::save($person); }
public function update(Request $request, PersonModel $person) { $person->setName($request->input('name'))->setEnabled($request->has('enabled')); if (Gate::allows('editSuperuser', $person)) { $person->setSuperuser($request->has('superuser')); } PersonFacade::save($person); }
/** * @param LoginEvent $event */ public function handle(LoginEvent $event) { $person = $event->user; if ($person instanceof PersonModel && $person->getId()) { $person->setLastLogin(Carbon::now()); Person::save($person); } }
public function save() { $superuser = $this->request->input('superuser'); $this->editPerson->setName($this->request->input('name'))->setEnabled($this->request->input('enabled') == 1); if ($superuser !== null && Auth::getPerson()->isSuperuser() && Auth::getPerson()->getId() != $this->editPerson->getId()) { $this->editPerson->setSuperuser($superuser == 1); } Person::save($this->editPerson); }
public function testFailedLoginsAreReset() { $person = $this->getMock(Person::class, ['setFailedLogins', 'setLastFailedLogin'], [[]]); $person->expects($this->once())->method('setFailedLogins')->with($this->equalTo(0)); $person->expects($this->once())->method('setLastFailedLogin')->with($this->equalTo(null)); PersonFacade::shouldReceive('save')->with($person); $event = new SuccessfulLogin($person, m::mock(Request::class)); $listener = new ResetFailedLogins(); $listener->handle($event); }
/** * @return void */ public function handle() { $password = (string) new RandomPassword(); $hasher = new Hasher(); try { $person = Person::create(['name' => $this->name, 'email' => $this->email, 'password' => $hasher->make($password)]); } catch (DuplicateEmailException $e) { } if (isset($person)) { Event::fire(new AccountCreated($person, $password, Auth::user())); return $person; } else { return Person::findByEmail($this->email); } }
/** * @return void */ public function handle() { $password = (string) new RandomPassword(); $this->credentials['password'] = Auth::hash($password); try { $person = Person::create($this->credentials); } catch (DuplicateEmailException $e) { } if (isset($person)) { foreach ($this->groups as $groupId) { $person->addGroup(Group::find($groupId)); } Event::fire(new AccountCreated($person, $password, Auth::getPerson())); return $person; } else { return Person::findByEmail($this->credentials['email']); } }
public function postIndex() { $message = ''; if ($name = $this->request->input('name')) { $this->person->setName($name); } if ($this->request->input('password1') && $this->request->input('password1') != $this->request->input('current_password')) { if (!$this->person->checkPassword($this->request->input('current_password'))) { $message = 'Invalid password'; } elseif ($this->request->input('password1') != $this->request->input('password2')) { $message = 'The passwords you entered did not match'; } else { $this->person->setEncryptedPassword($this->auth->hash($this->request->input('password1'))); Event::fire(new PasswordChanged($this->person, $this->request)); $message = 'Your password has been updated'; } } Person::save($this->person); return view('boomcms::account.account', ['person' => $this->person, 'auth' => $this->auth, 'logs' => [], 'message' => $message]); }
/** * Bootstrap any application services. * * @return void */ public function boot(Request $request) { $installer = new Installer\Installer(); if (php_sapi_name() !== 'cli' && !$installer->isInstalled()) { if (!$this->app['migration.repository']->repositoryExists()) { $this->app['migration.repository']->createRepository(); } $this->app['migrator']->run(base_path('/vendor/boomcms/boom-core/src/database/migrations')); $site = $installer->saveSiteDetails($request->input('site_name'), $request->input('site_email')); $name = $request->input('user_name'); $email = $request->input('user_email'); $person = $this->dispatch(new Jobs\CreatePerson($email, $name)); $person->addSite($site); $person->setSuperuser(true); Person::save($person); auth()->login($person); $page = $this->dispatch(new Jobs\CreatePage($person, $site)); $this->dispatch(new Jobs\CreatePagePrimaryUri($page, '', '/')); $installer->markInstalled(); header('Location: /boomcms/login'); exit; } }
/** * Reset the given user's password. * * @param \Illuminate\Contracts\Auth\CanResetPassword $user * @param string $password * * @return void */ protected function resetPassword($user, $password) { $user->password = (new Hasher())->make($password); Person::save($user); auth()->login($user); }
public function index() { $groupId = $this->request->input('group'); $people = $groupId ? Person::findByGroupId($groupId) : Person::findAll(); return view($this->viewPrefix . 'list', ['people' => $people]); }
public function __construct(Request $request) { $this->request = $request; $this->editPerson = Person::find($this->request->route()->getParameter('id')); }