/** * @method POST */ function post() { // parse request parse_str($this->request->data, $request); $token = $request['token']; $password = $request['password']; $friendlyId = $request['friendlyId']; // get site $site = Site::GetByFriendlyId($friendlyId); // get the user from the credentials $user = User::GetByToken($token, $site['SiteId']); if ($user != null) { User::EditPassword($user['UserId'], $password); // return a successful response (200) return new Tonic\Response(Tonic\Response::OK); } else { // return a bad request return new Tonic\Response(Tonic\Response::BADREQUEST); } }
/** * @method POST */ function reset() { // parse request parse_str($this->request->data, $request); $token = $request['token']; $password = $request['password']; // get the user from the credentials $user = User::GetByToken($token); if ($user != null) { User::EditPassword($user['UserUniqId'], $password); // return a successful response (200) return new Tonic\Response(Tonic\Response::OK); } else { // return an unauthorized exception (401) return new Tonic\Response(Tonic\Response::UNAUTHORIZED); } }
public static function EditProfile($userUniqId, $email, $password, $firstName, $lastName, $language) { try { $db = DB::get(); // edit basic information $q = "UPDATE Users SET \n Email = ?,\n FirstName = ?,\n \t\t\tLastName = ?,\n \t\t\tLanguage = ?\n \t\t\tWHERE UserUniqId = ?"; $s = $db->prepare($q); $s->bindParam(1, $email); $s->bindParam(2, $firstName); $s->bindParam(3, $lastName); $s->bindParam(4, $language); $s->bindParam(5, $userUniqId); $s->execute(); // edit password User::EditPassword($userUniqId, $password); } catch (PDOException $e) { die('[User::Edit] PDO Error: ' . $e->getMessage()); } }