Fixed redirect not working, added autoComplete attribute to login form and hidden lobby button when not logged in
This commit is contained in:
parent
e850391056
commit
c5490ec332
@ -32,7 +32,7 @@ const Secured: FC<{ secured: boolean } & ChildProps> = ({children, secured}) =>
|
||||
if (redirect) {
|
||||
navigate("/login");
|
||||
}
|
||||
}, []);
|
||||
});
|
||||
|
||||
if (!redirect) {
|
||||
return (
|
||||
|
@ -8,8 +8,10 @@ const Input: FRComponent<InputProps, HTMLInputElement> = forwardRef((
|
||||
placeholder,
|
||||
required = false,
|
||||
name,
|
||||
autoComplete = "off",
|
||||
}, ref) => (
|
||||
<input type={type}
|
||||
autoComplete={autoComplete}
|
||||
ref={ref}
|
||||
id={id}
|
||||
name={name}
|
||||
|
@ -15,12 +15,14 @@ const NavMenu: FC = () => {
|
||||
|
||||
<ul className="inline-flex gap-2 items-center mr-5 relative">
|
||||
<NavItem to="/">Home</NavItem>
|
||||
<NavItem to={"/lobby"}>Lobby</NavItem>
|
||||
{
|
||||
player === undefined ?
|
||||
<NavItem className={"mx-2"} to={"/login"}>Login</NavItem>
|
||||
:
|
||||
<ProfileDropdown className={"mx-2"}/>
|
||||
<>
|
||||
<NavItem to={"/lobby"}>Lobby</NavItem>
|
||||
<ProfileDropdown className={"mx-2"}/>
|
||||
</>
|
||||
}
|
||||
</ul>
|
||||
</nav>
|
||||
|
@ -49,9 +49,10 @@ const LoginPage: FC = () => {
|
||||
<h1 className={"my-5"}>Login</h1>
|
||||
{error && <p className={"text-red-500"}>{error}</p>}
|
||||
<label htmlFor={username}>Username:</label>
|
||||
<Input id={username} name={username} placeholder={"Username"} required/>
|
||||
<Input id={username} name={username} placeholder={"Username"} autoComplete={"username"} required/>
|
||||
<label htmlFor={password}>Password:</label>
|
||||
<Input id={password} name={password} type={"password"} placeholder={"Password"} required/>
|
||||
<Input id={password} name={password} type={"password"} placeholder={"Password"}
|
||||
autoComplete={"current-password"} required/>
|
||||
<Button type={"submit"}>Login</Button>
|
||||
</form>
|
||||
);
|
||||
|
@ -23,10 +23,11 @@ interface ButtonProps extends ChildProps {
|
||||
}
|
||||
|
||||
interface InputProps extends ComponentProps {
|
||||
type?: string,
|
||||
placeholder?: string,
|
||||
required?: boolean,
|
||||
name?: string,
|
||||
type?: string
|
||||
placeholder?: string
|
||||
required?: boolean
|
||||
name?: string
|
||||
autoComplete?: string
|
||||
}
|
||||
|
||||
interface CharacterProps {
|
||||
|
@ -78,7 +78,6 @@ public class ActionService : IActionService
|
||||
|
||||
public List<Player> FindGame(JsonElement? jsonElement)
|
||||
{
|
||||
// TODO Receive Username and GameId
|
||||
var data = jsonElement?.Deserialize<JoinGameData>() ?? throw new NullReferenceException("Data is null");
|
||||
|
||||
var game = _gameService.Games.FirstOrDefault(game => game.Id == data.GameId) ??
|
||||
|
@ -5,7 +5,7 @@ using pacMan.GameStuff.Items;
|
||||
|
||||
namespace pacMan.Services;
|
||||
|
||||
public class Game // TODO handle disconnects and reconnects
|
||||
public class Game
|
||||
{
|
||||
private readonly Random _random = new();
|
||||
private int _currentPlayerIndex;
|
||||
@ -29,11 +29,11 @@ public class Game // TODO handle disconnects and reconnects
|
||||
}).ToList();
|
||||
}
|
||||
|
||||
[JsonIgnore] public List<Character> Ghosts { get; set; } = new();
|
||||
[JsonIgnore] public List<Character> Ghosts { get; set; } = new(); // TODO include
|
||||
|
||||
[JsonIgnore] private Queue<DirectionalPosition> Spawns { get; }
|
||||
|
||||
[JsonIgnore] public DiceCup DiceCup { get; } = new();
|
||||
[JsonIgnore] public DiceCup DiceCup { get; } = new(); // TODO include
|
||||
|
||||
[JsonInclude] public int Count => Players.Count;
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user