/** * @param LoginCommand $command * @return string */ public function handleLoginCommand(LoginCommand $command) { if ($command->getUsername() == "admin" && $command->getPassword() == "singo") { /** * notify all AfterLoginEvent subscriber */ $this->dispatcher->dispatch(AfterLoginEvent::EVENT, new AfterLoginEvent($command->getUsername())); return $this->encoder->encode(["name" => $command->getUsername()]); } throw new InvalidUsernamePasswordException("invalid username or password"); }
/** * @param $username * @return string */ private function signToken($username) { return $this->jwt_encoder->encode(["name" => $username]); }