/** * @param \Lio\Accounts\User $user * @param \Lio\Accounts\UserUpdaterListener $listener * @param array $data * @return mixed */ private function updateUser(User $user, UserUpdaterListener $listener, array $data) { $oldEmail = $user->email; $user->fill($data); // If the email changed, the user will need to re-confirm it. if ($data['email'] !== $oldEmail) { $user->confirmed = false; // Set a confirmation code for the user. He'll need to verify his email address // with this code before he can use certain sections on the website. $confirmationCode = Str::random(30); // We'll generate a new one if we find a user with the same code. while ($this->users->getByConfirmationCode($confirmationCode) !== null) { $confirmationCode = Str::random(30); } $user->confirmation_code = $confirmationCode; } // check the model validation if (!$this->users->save($user)) { return $listener->userValidationError($user->getErrors()); } // Send a confirmation email to the user. if ($data['email'] !== $oldEmail) { $this->confirmation->send($user); } return $listener->userUpdated($user, $data['email'] !== $oldEmail); }
public function putBanAndDeleteThreads($userId) { // Ban the user $user = $this->users->requireById($userId); $user->is_banned = 1; $this->users->save($user); // Remove all threads by the user $this->threads->deleteByAuthorId($userId); return $this->redirectAction('Admin\\UsersController@getIndex', ['success' => 'The user has been banned and its threads have been removed.']); }
/** * @param \Lio\Github\GithubAuthenticatorListener $listener * @return \Illuminate\Http\RedirectResponse */ public function authBySocialite(GithubAuthenticatorListener $listener) { try { $githubUser = $this->socialite->user(); } catch (Exception $e) { return $listener->invalidLogin(); } if ($user = $this->users->getByGithubId($githubUser->getId())) { return $this->loginUser($listener, $user); } return $listener->userNotFound($this->githubUserToArray($githubUser)); }
/** * Re-sends the confirmation email * * @param string $code * @return \Illuminate\Http\RedirectResponse */ public function getResendConfirmation($code) { $user = $this->users->getByConfirmationCode($code); if (!$user) { App::abort(404); } $this->confirmation->send($user); return Redirect::home()->with('success', 'A new email confirmation was sent to ' . $user->email); }
private function createValidUserRecord($listener, $data) { $user = $this->users->getNew($data); // Set a confirmation code for the user. He'll need to verify his email address // with this code before he can use certain sections on the website. $confirmationCode = Str::random(30); // We'll generate a new one if we find a user with the same code. while ($this->users->getByConfirmationCode($confirmationCode) !== null) { $confirmationCode = Str::random(30); } $user->confirmation_code = $confirmationCode; // check the model validation if (!$this->users->save($user)) { return $listener->userValidationError($user->getErrors()); } // Send a confirmation email to the user. $this->confirmation->send($user); return $listener->userCreated($user); }
/** * Confirms a user's email address * * @param string $code * @return \Illuminate\Http\RedirectResponse */ public function confirmEmail($code) { if (!($user = $this->users->getByConfirmationCode($code))) { abort(404); } $user->confirmed = 1; $user->confirmation_code = null; $user->save(); Auth::login($user, true); session(['success' => 'Your email was successfully confirmed.']); return redirect()->home(); }
public function getReplies($userName) { $user = $this->users->requireByName($userName); $replies = $user->getLatestRepliesPaginated(10); $this->view('users.replies', compact('user', 'replies')); }