Пример #1
0
$app->get('/manage/users/:team_id', 'authenticateToken', function ($team_id) use($app) {
    global $db;
    $data = json_decode($app->request->getBody());
    $rows = Users_model::get_teamsManage($db, $team_id);
    echoResponse(200, $rows);
});
$app->delete('/manage/:team_id/:user_id', 'authenticateToken', function ($team_id, $user_id) use($app) {
    global $db;
    $rows = Users_model::delete_userManage($db, $team_id, $user_id);
    echoResponse(200, $rows);
});
$app->post('/forgot_password', function () use($app) {
    global $db;
    $data = json_decode($app->request->getBody());
    $user_email = $data->email;
    if (filter_var($user_email, FILTER_VALIDATE_EMAIL)) {
        $posted = [];
        $posted['hash'] = hash('sha256', $user_email);
        $posted['email'] = $user_email;
        $time = new DateTime('24 hours ago');
        $posted['time_formatted'] = $time->format('Y-m-d H:i:s');
        $processed = Users_model::forgotPasswordAction($db, $posted);
    }
    echoResponse(200, $processed);
});
$app->post('/reset_password', function () use($app) {
    global $db;
    $data = json_decode($app->request->getBody());
    $result = Users_model::resetPasswordAction($db, $data->reset_key, $data->email_address, $data->password_token, $data->password, $data->verifyNewPass);
    echoResponse(200, $result);
});