Beispiel #1
0
 /**
  *  User should be authorised on cases:
  *      1. username is correct and email is empty
  *      2. email is correct and username is empty
  *      3. username is correct and email is correct
  *
  * Sing in is case sensitive
  *
  * @param Requests\LoginFormRequest $request
  *
  * @return $this
  */
 public function login(Requests\LoginFormRequest $request)
 {
     $data = $request->only('username', 'email', 'password');
     if (empty($data['username'])) {
         unset($data['username']);
     } elseif (empty($data['email'])) {
         unset($data['email']);
     }
     if ($this->auth->attempt($data)) {
         return redirect('chat');
     }
     return redirect('/')->withErrors(['username' => 'Incorrect username, email or password'], $request->getErrorBag());
 }