本文整理汇总了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'];
}
}
示例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');