Example #1
0
    } else {
        $response = (object) array('status' => -3, 'status_explanation' => 'Invalid token.');
    }
    header('Content-Type: application/json');
    echo json_encode($response);
}, $f3->get('route_ttl'));
/**
 * Route: User Reset Pass
 *
 * @example /user/reset-pass
 */
$f3->route('POST /user/reset-pass', function ($f3, $params) use($db) {
    $email = $f3->get('POST.email');
    $user = new User($email);
    // If user exists
    if ($user->existsAlready()) {
        if ($user->resetPassword()) {
            $response = (object) array('status' => 1, 'status_explanation' => 'Success');
        } else {
            $response = (object) array('status' => -2, 'status_explanation' => 'Could not send email.');
        }
    } else {
        $response = (object) array('status' => -1, 'status_explanation' => 'A user with provided email doesn\'t exist.');
    }
    header('Content-Type: application/json');
    echo json_encode($response, JSON_PRETTY_PRINT);
}, $f3->get('route_ttl'));
/**
 * Route: Find users by searching
 *
 * @example /user/reset-pass