当前位置: 首页>>代码示例>>PHP>>正文


PHP AuthService::getUserById方法代码示例

本文整理汇总了PHP中AuthService::getUserById方法的典型用法代码示例。如果您正苦于以下问题:PHP AuthService::getUserById方法的具体用法?PHP AuthService::getUserById怎么用?PHP AuthService::getUserById使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在AuthService的用法示例。


在下文中一共展示了AuthService::getUserById方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: isset

    }
    return $this->view->render($response, 'forms/users_edit.twig', ['user' => $user, 'flash_messages' => $flash_messages, 'errors' => $field_errors, 'userLogged' => isset($_SESSION['user_id']), 'csrf' => ['name' => $request->getAttribute('csrf_name'), 'value' => $request->getAttribute('csrf_value')]]);
})->setName('user-edit');
$app->map(['GET', 'POST'], '/users/password/change', function ($request, $response, $args) {
    $fdata = [];
    $field_errors = [];
    $flash_messages = $this->flash->getMessages();
    if ($request->isPost()) {
        $fdata['current_password'] = filter_var($_POST['current_password'], FILTER_SANITIZE_STRING);
        $fdata['new_password'] = filter_var($_POST['new_password'], FILTER_SANITIZE_STRING);
        $fdata['confirmed_password'] = filter_var($_POST['confirmed_password'], FILTER_SANITIZE_STRING);
        $password_form = validatePasswordForm($fdata);
        if ($password_form['is_valid']) {
            if ($fdata['new_password'] == $fdata['confirmed_password']) {
                $userService = new AuthService();
                $user = $userService->getUserById($_SESSION['user_id']);
                $errors = $userService->changeUserPassword($user['user_name'], $fdata['current_password'], $fdata['new_password']);
                if (empty($errors)) {
                    $this->flash->addMessage('success', 'Password has been changed');
                    return $response->withRedirect($this->router->pathFor('docs-home'));
                } else {
                    $flash_messages['danger'][] = $errors;
                    //
                }
            } else {
                $flash_messages['danger'][] = "Please confirm new passowrd";
            }
        } else {
            $field_errors = $password_form['has_errors'];
        }
    }
开发者ID:BenHicksy,项目名称:dietddocs,代码行数:31,代码来源:userRoutes.php

示例2: AuthService

    $flash_messages = $this->flash->getMessages();
    $userService = new AuthService();
    $user = $userService->getUserById($id);
    if ($request->isPost()) {
        $user['full_name'] = filter_var($_POST['full_name'], FILTER_SANITIZE_STRING);
        $user['email'] = filter_var($_POST['email'], FILTER_SANITIZE_STRING);
        $user_form = validateUserEditForm($user);
        if ($user_form['is_valid']) {
            $userService->updateUser($user);
            $this->flash->addMessage('success', 'Details has been updated');
            return $response->withRedirect($this->router->pathFor('admin-users-all'));
        } else {
            $field_errors = $user_form['has_errors'];
        }
    }
    return $this->view->render($response, 'admin/admin_users_edit.twig', ['user' => $user, 'flash_messages' => $flash_messages, 'userLogged' => isset($_SESSION['user_id'])]);
})->setName('admin-users-edit');
$app->map(['GET', 'POST'], '/admin/users/delete/{id:[\\d]*}', function ($request, $response, $args) {
    $user = [];
    $id = (int) $args['id'];
    $flash_messages = $this->flash->getMessages();
    $userService = new AuthService();
    $user = $userService->getUserById($id);
    $OK_link = $this->router->pathFor('admin-users-delete', ['id' => $id]);
    if ($request->isPost()) {
        $userService->deleteUser($id);
        $this->flash->addMessage('success', 'User has been successfully deleted');
        return $response->withRedirect($this->router->pathFor('admin-users-all'));
    }
    return $this->view->render($response, 'admin/admin_users_delete.twig', ['user' => $user, 'OK_link' => $OK_link, 'flash_messages' => $flash_messages, 'userLogged' => isset($_SESSION['user_id'])]);
})->setName('admin-users-delete');
开发者ID:BenHicksy,项目名称:dietddocs,代码行数:31,代码来源:adminRoutes.php


注:本文中的AuthService::getUserById方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。