예제 #1
0
 public function verify($username, $password)
 {
     $credentials = ['username' => $username, 'password' => $password];
     $person = new Person();
     $resp = $person->getUsername($credentials['username']);
     if (!empty($resp)) {
         if (\Hash::check($credentials['password'], $resp['password'])) {
             $auth = true;
         } else {
             //check for old hashing
             if (md5($credentials['password']) == $resp['password']) {
                 //convert old pass to new hashing
                 $resp['password'] = bcrypt($credentials['password']);
                 $id = my_encode($resp['id']);
                 $person->update($id, $resp);
                 $auth = true;
             } else {
                 $auth = false;
             }
         }
     } else {
         //invalid user
         $auth = false;
     }
     if ($auth) {
         $result = $person->respondWithItem($resp, new UserTransformer());
         session()->put('user', $result);
         return my_decode($resp['id']);
     }
     return false;
 }
예제 #2
0
 protected function checkUser($email, $password)
 {
     $customer = Customer::where('email', '=', $email)->get();
     if (count($customer) == 0) {
         return false;
     } else {
         foreach ($customer as $key => $value) {
             if (\Hash::check($password, $value['password'])) {
                 \Session::put('name', $value['name']);
                 \Session::put('email', $value['email']);
                 \Session::put('role', $value['role']);
                 return true;
             } else {
                 return false;
             }
         }
     }
 }
예제 #3
0
 public static function changePassword($user_id, $curr_pwd, $new_pwd)
 {
     $user = User::find($user_id);
     if (!isset($user)) {
         return Redirect::to('/crm/profile')->withMessage(['title' => 'Failed', 'body' => 'User Not Exist']);
     }
     if (Hash::check($curr_pwd, $user->password)) {
         // The passwords match, then now change pass to the new password.
         $user->password = Hash::make($new_pwd);
         $user->save();
         return Redirect::to('/crm/profile')->withMessage(['title' => 'Success', 'body' => 'Password Change successfully.']);
     }
     return Redirect::to('/crm/profile')->withMessage(['title' => 'Failed', 'body' => 'Password Mismatch.']);
 }