Example #1
0
 public function logout()
 {
     unset($_SESSION['adminId']);
     unset($_SESSION['adminEmail']);
     textMsg("Logout Success", "success");
     Redirect::url("administrator");
     exit;
 }
Example #2
0
 public function changePassword()
 {
     if (Input::exists("opass") || Input::exists("npass") || Input::exists("cpass")) {
         $opass = Input::get("opass");
         $npass = Input::get("npass");
         $cpass = Input::get("cpass");
         if (empty($opass) || empty($npass) || empty($cpass)) {
             textMsg("Required fields are empty.", "error");
             Redirect::url("shippingUser/setting");
             exit;
         } else {
             if ($npass == $cpass) {
                 $user = User::find($_SESSION['userId']);
                 $check = Pass::verify($user->password, $opass);
                 if ($check) {
                     $user->password = Pass::hash($npass);
                     if ($user->save()) {
                         textMsg("password has been updated.", "success");
                         Redirect::url("shippingUser/setting");
                         exit;
                     } else {
                         textMsg("Something went wrong try again.", "error");
                         Redirect::url("shippingUser/setting");
                         exit;
                     }
                 } else {
                     textMsg("Old password did not match.", "error");
                     Redirect::url("shippingUser/setting");
                     exit;
                 }
             } else {
                 textMsg("Confirm password did not match.", "error");
                 Redirect::url("shippingUser/setting");
                 exit;
             }
         }
     } else {
         textMsg("Something went wrong try again.", "error");
         Redirect::url("shippingUser/dashboard");
         exit;
     }
 }
Example #3
0
 public function UserPasswordReset()
 {
     if (Input::exists("key") || Input::exists("uId") || Input::exists("autnKey") || Input::exists("npass") || Input::exists("cpass")) {
         $key = Input::get("key");
         $uId = Input::get("uId");
         $authKey = Input::get("autnKey");
         $npass = Input::get("npass");
         $cpass = Input::get("cpass");
         if (empty($key) || empty($uId) || empty($authKey) || empty($npass) || empty($cpass)) {
             textMsg("unable to do this action.", "error");
             Redirect::url("home/index");
             exit;
         } else {
             if ($_SESSION['key'] == $authKey) {
                 if ($npass == $cpass) {
                     $user = User::all(['id' => $uId])[0];
                     if (count($user) > 0) {
                         if ($key == $user->key) {
                             $code = md5(time() . "aas^5s&dw#2" . rand());
                             $code = str_replace(array('/', '\\/'), '', Pass::hash($code));
                             $user->password = Pass::hash($npass);
                             $user->key = $code;
                             if ($user->save()) {
                                 textMsg("Password has been reset successfully.", "success");
                                 Redirect::url("home/index");
                                 exit;
                             }
                         } else {
                             textMsg("Invalid key to reset password.", "error");
                             Redirect::url("home/index");
                             exit;
                         }
                     } else {
                         textMsg("User did not find.", "error");
                         Redirect::url("home/index");
                         exit;
                     }
                 } else {
                     textMsg("Confirm password did not match.", "error");
                     Redirect::url("home/index");
                     exit;
                 }
             } else {
                 textMsg("You are roobot.", "error");
                 Redirect::url("home/index");
                 exit;
             }
         }
     }
 }