Skip to content

Commit f0ec12f

Browse files
committed
feat: enhance login UI and 2FA handling
1 parent d563c26 commit f0ec12f

File tree

1 file changed

+43
-37
lines changed

1 file changed

+43
-37
lines changed

src/ui/src/components/Login.jsx

Lines changed: 43 additions & 37 deletions
Original file line numberDiff line numberDiff line change
@@ -38,19 +38,19 @@ export function Login({ onLogin }) {
3838
onLogin();
3939
} else {
4040
if (data.code === "2FA_REQUIRED") {
41-
setShowTotp(true);
42-
notifications.show({
43-
title: "Authentication Required",
44-
message: "Please enter your 2FA code",
45-
color: "blue",
46-
icon: <IconDeviceMobile size={16} />
47-
});
41+
setShowTotp(true);
42+
notifications.show({
43+
title: "Authentication Required",
44+
message: "Please enter your 2FA code",
45+
color: "blue",
46+
icon: <IconDeviceMobile size={16} />,
47+
});
4848
} else {
49-
notifications.show({
49+
notifications.show({
5050
title: "Login Failed",
5151
message: data.error || "Invalid credentials",
5252
color: "red",
53-
});
53+
});
5454
}
5555
}
5656
} catch (error) {
@@ -73,14 +73,17 @@ export function Login({ onLogin }) {
7373
backgroundColor: "#FBFAF8",
7474
}}
7575
>
76-
<Container size={420}>
76+
<Container size={420} w={"100%"}>
7777
<Stack align="center" mb="xl">
7878
<ThemeIcon size={60} radius="md" color="dark">
7979
<IconDatabase size={34} />
8080
</ThemeIcon>
8181
<Title order={1} fw={700}>
8282
SQLite Login
8383
</Title>
84+
<Text c="dimmed" size="sm" ta="center">
85+
Enter your credentials to log in.
86+
</Text>
8487
</Stack>
8588

8689
<Paper withBorder shadow="md" p={30} radius="md">
@@ -102,42 +105,45 @@ export function Login({ onLogin }) {
102105
onChange={(e) => setPassword(e.target.value)}
103106
disabled={showTotp}
104107
/>
105-
108+
106109
{showTotp && (
107-
<TextInput
108-
label="Authenticator Code (2FA)"
109-
placeholder="000 000"
110-
required
111-
autoFocus
112-
value={totpCode}
113-
onChange={(e) => setTotpCode(e.target.value)}
114-
leftSection={<IconDeviceMobile size={16} />}
115-
maxLength={6}
116-
/>
110+
<TextInput
111+
label="Authenticator Code (2FA)"
112+
placeholder="000 000"
113+
required
114+
autoFocus
115+
value={totpCode}
116+
onChange={(e) => setTotpCode(e.target.value)}
117+
leftSection={<IconDeviceMobile size={16} />}
118+
maxLength={6}
119+
/>
117120
)}
118121

119122
<Group mt="lg">
120-
<Button
121-
type="submit"
122-
color="dark"
123-
fullWidth
124-
loading={loading}
125-
leftSection={<IconLock size={18} />}
123+
<Button
124+
type="submit"
125+
color="dark"
126+
fullWidth
127+
loading={loading}
128+
leftSection={<IconLock size={18} />}
126129
>
127130
{showTotp ? "Verify & Login" : "Login"}
128131
</Button>
129132
</Group>
130-
133+
131134
{showTotp && (
132-
<Text
133-
size="xs"
134-
c="dimmed"
135-
ta="center"
136-
style={{ cursor: 'pointer' }}
137-
onClick={() => { setShowTotp(false); setTotpCode(""); }}
138-
>
139-
Cancel
140-
</Text>
135+
<Text
136+
size="xs"
137+
c="dimmed"
138+
ta="center"
139+
style={{ cursor: "pointer" }}
140+
onClick={() => {
141+
setShowTotp(false);
142+
setTotpCode("");
143+
}}
144+
>
145+
Cancel
146+
</Text>
141147
)}
142148
</Stack>
143149
</form>

0 commit comments

Comments
 (0)