Open github-actions[bot] opened 2 years ago
https://github.com/battis/user-session/blob/324537d962438bb2719ef34453bd755df1ed6890/src/Actions/HandleLogin.php#L46
class HandleLogin { private $manager; private $userRepository; private $renderer; private $usernameFieldName; private $passwordFieldName; public function __construct( Manager $manager, UserRepositoryInterface $userRepository, PhpRenderer $renderer, string $usernameFieldName = "username", string $passwordFiledName = "password" ) { $this->manager = $manager; $this->userRepository = $userRepository; $this->renderer = $renderer; $this->usernameFieldName = $usernameFieldName; $this->passwordFieldName = $passwordFiledName; } public function __invoke(ServerRequest $request, Response $response) { if ( ($user = $this->userRepository->getUserEntityByUsername( $request->getParsedBodyParam($this->usernameFieldName) )) && $user->passwordVerify( $request->getParsedBodyParam($this->passwordFieldName) ) ) { return $this->manager->startUserSession($user); } // TODO add timeout return $this->renderer->render($response, "login.php", [ "message" => "bad credentials", "message_type" => "error", ]); } }
https://github.com/battis/user-session/blob/324537d962438bb2719ef34453bd755df1ed6890/src/Actions/HandleLogin.php#L46