Beispiel #1
0
 /**
  * Authenticate user
  * @param Request $request
  */
 public function attempt(LoginRequest $request)
 {
     $params = $request->only('username', 'password');
     $person = new Person();
     $resp = $person->getUsername($params['username']);
     if (!empty($resp)) {
         if (\Hash::check($params['password'], $resp['password'])) {
             $request->session()->put('user', ['id' => $resp['id'], 'username' => $resp['username'], 'role' => $resp['role'], 'disp_name' => $resp['role'] == 'A' ? 'Administrator' : $resp['first_name'] . ' ' . $resp['last_name']]);
             $message = 'success';
         } else {
             //check for old hashing
             if (md5($params['password']) == $resp['password']) {
                 //convert old pass to new hashing
                 $resp['password'] = bcrypt($params['password']);
                 $id = 'person_' . $resp['id'];
                 $person->update($id, $resp);
                 $request->session()->put('user', ['id' => $resp['id'], 'username' => $resp['username'], 'role' => $resp['role'], 'disp_name' => $resp['role'] == 'A' ? 'Administrator' : $resp['first_name'] . ' ' . $resp['last_name']]);
                 $message = 'success';
             } else {
                 //invalid password
                 $message = 'invalid';
             }
         }
     } else {
         //invalid user
         $message = 'invalid';
     }
     return response(['login_status' => $message]);
 }
Beispiel #2
0
 public function authenticate(\App\Http\Requests\LoginRequest $request)
 {
     // verify and login the user
     try {
         $this->authentication->authenticate($request->get('email'), $request->get('password'));
         // upon success, set some data into the session
         $request->session()->put('full_name', \Auth::User()->full_name);
     } catch (\L5Admin\Exceptions\ModelNotFoundException $error) {
         $request->session()->flash('error', 'User Not Found');
         return back()->withInput();
     } catch (\L5Admin\Exceptions\PasswordCheckException $error) {
         $request->session()->flash('error', 'Incorrect Password');
         return back()->withInput();
     }
     return redirect()->route('home');
 }