Beispiel #1
0
 public function initiate()
 {
     $email = $this->user->user_email;
     if (!present($this->request->session()->get('verification_key'))) {
         $this->issue();
     }
     if ($this->request->ajax()) {
         return response(['authentication' => 'verify', 'box' => render_to_string('users._verify_box', compact('email'))], 401);
     } else {
         return response()->view('users.verify');
     }
 }
Beispiel #2
0
 public function login()
 {
     $ip = Request::getClientIp();
     $username = Request::input('username');
     $password = Request::input('password');
     $remember = Request::input('remember') === 'yes';
     $user = User::findForLogin($username);
     $authError = User::attemptLogin($user, $password, $ip);
     if ($authError === null) {
         Request::session()->flush();
         Request::session()->regenerateToken();
         Auth::login($user, $remember);
         return ['header' => render_to_string('layout._header_user'), 'header_popup' => render_to_string('layout._popup_user'), 'user' => Auth::user()->defaultJson()];
     } else {
         return error_popup($authError);
     }
 }
 public function login()
 {
     $ip = Request::getClientIp();
     if (LoginAttempt::isLocked($ip)) {
         return error_popup('your IP address is locked. Please wait a few minutes.');
     } else {
         $usernameOrEmail = Request::input('username');
         $user = User::where('username', $usernameOrEmail)->orWhere('user_email', $usernameOrEmail)->first();
         $password = Request::input('password');
         $remember = Request::input('remember') === 'yes';
         $validAuth = $user === null ? false : Auth::getProvider()->validateCredentials($user, compact('password'));
         if ($validAuth) {
             Request::session()->flush();
             Request::session()->regenerateToken();
             Auth::login($user, $remember);
             return ['header' => render_to_string('layout._header_user', ['_user' => Auth::user()]), 'header_popup' => render_to_string('layout._popup_user', ['_user' => Auth::user()]), 'user' => Auth::user()->defaultJson()];
         } else {
             LoginAttempt::failedAttempt($ip, $user);
             return error_popup('wrong password or email');
         }
     }
 }
Beispiel #4
0
function render_email($email_message_name)
{
    # TODO: Should we also deliver the emails here?
    return render_to_string("emails/{$email_message_name}");
}