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; } }
public function login() { if (Input::exists("email") || Input::exists("password") || Input::exists("key")) { $key = Input::get("key"); if (!empty($key) && $key == $_SESSION['key']) { $email = Input::get("email"); $pass = Input::get("password"); if (empty($email) || empty($pass)) { textMsg("Unable to login as administrator", "error"); Redirect::url("home"); exit; } else { $admin = Admin::all(['email' => $email]); if (count($admin) > 0) { if (Pass::verify($admin[0]->password, $pass)) { $_SESSION['adminId'] = $admin[0]->id; $_SESSION['adminEmail'] = $admin[0]->email; textMsg("You have logged in", "success"); Redirect::url("administrator/dashboard"); exit; } else { textMsg("Password id did not match", "error"); Redirect::url("administrator"); exit; } } else { textMsg("Email id did not match", "error"); Redirect::url("administrator"); exit; } } } else { textMsg("Unable to login as administrator", "error"); Redirect::url("home"); exit; } } else { textMsg("somethis went wrong try again", "error"); Redirect::url("home"); exit; } }
public function customerSingIn() { if (Input::exists("key") || Input::exists("email") || Input::exists("pass")) { $key = Input::get("key"); $email = Input::get("email"); $pass = Input::get("pass"); if ($key == $_SESSION['key']) { if (empty($email) || empty($pass)) { textMsg("All fields are require try again", "error"); Redirect::url("home/signIn"); exit; } else { $user = User::all(['email' => $email]); if (count($user) > 0) { if ($user[0]->status == 1) { if (Pass::verify($user[0]->password, $pass)) { $_SESSION['userId'] = $user[0]->id; $_SESSION['fname'] = $user[0]->first_name; $_SESSION['lname'] = $user[0]->last_name; $_SESSION['userEmail'] = $user[0]->email; textMsg("Login Success.", "success"); Redirect::url("shippingUser/dashboard"); exit; } else { textMsg("Password did not match ary again.", "error"); Redirect::url("home/signIn"); exit; } } else { textMsg("Your are suspanded please contact to admin.", "error"); Redirect::url("home/signIn"); exit; } } else { textMsg("Email id did not match", "error"); Redirect::url("home/signIn"); exit; } } } else { textMsg("unauthorise do loing", "error"); Redirect::url("home/index"); exit; } } else { textMsg("unauthorise do loing", "error"); Redirect::url("home/index"); exit; } }