예제 #1
0
파일: User.php 프로젝트: discophp/project
 public function postEditPassword()
 {
     $data = \Data::post(array('password_current', 'password', 'password_verify'));
     $UserDataModel = new \App\data_model\User($data);
     $current_password = \App::with('User')->User->select('password')->where('id=?', \App::with('User')->userId())->first()['password'];
     if (\Crypt::hash($data['password_current']) != $current_password) {
         \Session::setFlash('edit-password-errors', array('password_current' => 'That wasn\'t your current password'));
     } else {
         if (!$UserDataModel->verifySetData()) {
             \Session::setFlash('edit-password-errors', $UserDataModel->getErrors());
         } else {
             \App::with('User')->changePassword($UserDataModel['password']);
             \Session::setFlash('edit-success', 'Password Updated!');
         }
     }
     //el
     \View::redirect('/user/edit');
 }
예제 #2
0
 public function postPasswordReset($token)
 {
     $user_id = \App::with('User')->isValidToken($token, 'password');
     if (!$user_id) {
         return false;
     }
     //if
     $UserDataModel = new \App\data_model\User(\Data::post()->all());
     if (!$UserDataModel->verifySetData()) {
         \Session::setFlash('pw-reset-errors', $UserDataModel->getErrors());
     } else {
         \App::with('User')->changePassword($UserDataModel['password'], $user_id);
         \App::with('User')->deleteToken($user_id, 'password');
         \Session::setFlash('pw-reset-success', 1);
     }
     //el
     \View::redirect($_SERVER['REQUEST_URI']);
 }