Make sure php files can be used anywhere

This commit is contained in:
Robbie Antenesse 2019-06-05 11:42:00 -06:00 committed by Robbie Antenesse
parent 457a6c6798
commit c0fe25007d
5 changed files with 35 additions and 9 deletions

View File

@ -1,5 +1,5 @@
<?php
require_once('./config.php');
require_once(realpath(dirname(__FILE__) . '/./config.php'));
class Db {
private $dbh;

View File

@ -1,6 +1,6 @@
<?php
require_once('./Db.php');
require_once('./Token.php');
require_once(realpath(dirname(__FILE__) . '/./Db.php'));
require_once(realpath(dirname(__FILE__) . '/./Token.php'));
class Dictionary {
private $db;

View File

@ -1,5 +1,5 @@
<?php
require_once('../vendor/autoload.php');
require_once(realpath(dirname(__FILE__) . '/../vendor/autoload.php'));
use \Firebase\JWT\JWT;
use \Hashids\Hashids;

View File

@ -1,7 +1,7 @@
<?php
require_once('./Db.php');
require_once('./Token.php');
require_once('./Dictionary.php');
require_once(realpath(dirname(__FILE__) . '/./Db.php'));
require_once(realpath(dirname(__FILE__) . '/./Token.php'));
require_once(realpath(dirname(__FILE__) . '/./Dictionary.php'));
class User {
private $db;

View File

@ -1,6 +1,6 @@
<?php
require_once('./Response.php');
require_once('./User.php');
require_once(realpath(dirname(__FILE__) . '/./Response.php'));
require_once(realpath(dirname(__FILE__) . '/./User.php'));
$inputJSON = file_get_contents('php://input');
$inputJSON = strip_tags($inputJSON);
@ -444,6 +444,32 @@ switch ($action) {
'error' => 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!');