public function Start() { // If user is already logged in if (jf::CurrentUser()) { if (isset($_GET["return"])) { $return = $_GET["return"]; } else { $return = ""; } $this->Redirect(SiteRoot . $return); // Site root does not contain trailing '/' } // TODO: Implement a secure 'Remember Me' if (isset($_POST["Username"]) && isset($_POST['Password'])) { $this->Result = jf::Login($_POST['Username'], $_POST['Password']); } //Login Successful if (isset($this->Result) && $this->Result) { if (isset($_GET["return"])) { $return = $_GET["return"]; } else { $return = ""; } $this->Redirect(SiteRoot . $return); } return $this->Present(); }
public function Start() { if (jf::CurrentUser()) { $userName = jf::$XUser->Username(); $oldPass = $_POST['old_password']; $newPass = $_POST['new_password']; $cnfNewPass = $_POST['cnew_password']; if ($newPass != $cnfNewPass) { echo json_encode(array('status' => false, 'error' => 'Password and Confirm Password do not match')); } elseif (!jf::Login($userName, $oldPass)) { echo json_encode(array('status' => false, 'error' => 'Old Password is incorrect')); } else { jf::$User->EditUser($userName, $userName, $newPass); echo json_encode(array('status' => true, 'message' => 'Password successfully updated')); } } else { echo json_encode(array('status' => false, 'error' => 'You are not authorized for this action')); } return true; }