From ffdd008344ef3cafe1ab0639ba851147a2f6f10f Mon Sep 17 00:00:00 2001 From: Robbie Antenesse Date: Wed, 5 Jun 2019 11:42:00 -0600 Subject: [PATCH] Make sure php files can be used anywhere --- src/php/api/Db.php | 2 +- src/php/api/Dictionary.php | 4 ++-- src/php/api/Token.php | 2 +- src/php/api/User.php | 6 +++--- src/php/api/index.php | 30 ++++++++++++++++++++++++++++-- 5 files changed, 35 insertions(+), 9 deletions(-) diff --git a/src/php/api/Db.php b/src/php/api/Db.php index f29dd9d..1f9696a 100644 --- a/src/php/api/Db.php +++ b/src/php/api/Db.php @@ -1,5 +1,5 @@ true, ), 400); } + case 'password-reset': { + if (isset($request['code']) && isset($request['password'])) { + $user = new User(); + $password_reset = $user->setPasswordReset($request['email']); + if ($password_reset === true) { + return Response::json(array( + 'data' => $password_reset, + 'error' => false, + ), 200); + } + if (isset($password_reset['error'])) { + return Response::json(array( + 'data' => $password_reset['error'], + 'error' => true, + ), 500); + } + return Response::json(array( + 'data' => 'Could not send password reset key: email not found', + 'error' => true, + ), 401); + } + return Response::json(array( + 'data' => 'Could not send password reset key: required data missing', + 'error' => true, + ), 400); + } default: { return Response::html('Hi!');