kaze 2.1.0 → 2.2.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/CHANGELOG.md +69 -1
- data/README.md +42 -2
- data/lib/kaze/commands/app/base_stack.rb +14 -0
- data/lib/kaze/commands/app/hotwire_stack.rb +4 -1
- data/lib/kaze/commands/app/inertia_react_stack.rb +3 -1
- data/lib/kaze/commands/app/inertia_vue_stack.rb +3 -1
- data/lib/kaze/version.rb +1 -1
- data/stubs/default/app/forms/auth/login_form.rb +6 -1
- data/stubs/default/app/forms/auth/two_factor_challenge_form.rb +24 -0
- data/stubs/default/app/forms/confirm_two_factor_form.rb +5 -0
- data/stubs/default/app/forms/disable_two_factor_form.rb +7 -0
- data/stubs/default/app/models/concerns/two_factor_authenticatable.rb +112 -0
- data/stubs/default/app/models/session_guard.rb +8 -1
- data/stubs/default/app/models/two_factor_challenge.rb +55 -0
- data/stubs/default/app/models/user.rb +1 -0
- data/stubs/default/config/initializers/active_record_encryption.rb +20 -0
- data/stubs/default/config/routes.rb +9 -0
- data/stubs/default/db/migrate/20240101000001_add_two_factor_to_users.rb +15 -0
- data/stubs/default/test/integration/auth/rate_limiting_test.rb +64 -0
- data/stubs/default/test/integration/auth/two_factor_challenge_test.rb +114 -0
- data/stubs/default/test/integration/settings/two_factor_test.rb +104 -0
- data/stubs/default/test/models/two_factor_authenticatable_test.rb +143 -0
- data/stubs/default/test/test_helper.rb +16 -0
- data/stubs/hotwire/app/controllers/auth/authenticated_session_controller.rb +32 -1
- data/stubs/hotwire/app/controllers/auth/two_factor_challenge_controller.rb +59 -0
- data/stubs/hotwire/app/controllers/concerns/set_two_factor_challenge.rb +8 -0
- data/stubs/hotwire/app/controllers/settings/two_factor_controller.rb +48 -0
- data/stubs/hotwire/app/views/auth/forgot_password.html.erb +1 -1
- data/stubs/hotwire/app/views/auth/login.html.erb +1 -1
- data/stubs/hotwire/app/views/auth/register.html.erb +2 -2
- data/stubs/hotwire/app/views/auth/reset_password.html.erb +3 -3
- data/stubs/hotwire/app/views/auth/two_factor_challenge.html.erb +21 -0
- data/stubs/hotwire/app/views/auth/verify_email.html.erb +2 -2
- data/stubs/hotwire/app/views/layouts/_settings.html.erb +1 -0
- data/stubs/hotwire/app/views/layouts/_sidebar_user.html.erb +1 -1
- data/stubs/hotwire/app/views/settings/password/_update_password_form.html.erb +6 -6
- data/stubs/hotwire/app/views/settings/profile/_confirm_user_deletion_modal.html.erb +1 -1
- data/stubs/hotwire/app/views/settings/profile/_delete_user_form.html.erb +1 -1
- data/stubs/hotwire/app/views/settings/two_factor/_confirming.html.erb +20 -0
- data/stubs/hotwire/app/views/settings/two_factor/_disabled.html.erb +8 -0
- data/stubs/hotwire/app/views/settings/two_factor/_enabled.html.erb +29 -0
- data/stubs/hotwire/app/views/settings/two_factor/edit.html.erb +16 -0
- data/stubs/inertia-common/app/controllers/auth/authenticated_session_controller.rb +30 -1
- data/stubs/inertia-common/app/controllers/auth/two_factor_challenge_controller.rb +53 -0
- data/stubs/inertia-common/app/controllers/concerns/set_two_factor_challenge.rb +8 -0
- data/stubs/inertia-common/app/controllers/settings/two_factor_controller.rb +60 -0
- data/stubs/inertia-react-ts/app/javascript/Layouts/SettingsLayout.tsx +5 -1
- data/stubs/inertia-react-ts/app/javascript/Pages/Auth/ForgotPassword.tsx +2 -2
- data/stubs/inertia-react-ts/app/javascript/Pages/Auth/Register.tsx +1 -1
- data/stubs/inertia-react-ts/app/javascript/Pages/Auth/ResetPassword.tsx +3 -3
- data/stubs/inertia-react-ts/app/javascript/Pages/Auth/TwoFactorChallenge.tsx +71 -0
- data/stubs/inertia-react-ts/app/javascript/Pages/Auth/VerifyEmail.tsx +3 -3
- data/stubs/inertia-react-ts/app/javascript/Pages/Settings/Partials/DeleteUserForm.tsx +2 -2
- data/stubs/inertia-react-ts/app/javascript/Pages/Settings/Partials/UpdatePasswordForm.tsx +3 -3
- data/stubs/inertia-react-ts/app/javascript/Pages/Settings/TwoFactor.tsx +199 -0
- data/stubs/inertia-vue-ts/app/javascript/Layouts/SettingsLayout.vue +5 -1
- data/stubs/inertia-vue-ts/app/javascript/Pages/Auth/ForgotPassword.vue +2 -2
- data/stubs/inertia-vue-ts/app/javascript/Pages/Auth/Register.vue +1 -1
- data/stubs/inertia-vue-ts/app/javascript/Pages/Auth/ResetPassword.vue +3 -3
- data/stubs/inertia-vue-ts/app/javascript/Pages/Auth/TwoFactorChallenge.vue +60 -0
- data/stubs/inertia-vue-ts/app/javascript/Pages/Auth/VerifyEmail.vue +3 -3
- data/stubs/inertia-vue-ts/app/javascript/Pages/Settings/Partials/DeleteUserForm.vue +2 -2
- data/stubs/inertia-vue-ts/app/javascript/Pages/Settings/Partials/UpdatePasswordForm.vue +3 -3
- data/stubs/inertia-vue-ts/app/javascript/Pages/Settings/TwoFactor.vue +147 -0
- metadata +41 -1
|
@@ -0,0 +1,199 @@
|
|
|
1
|
+
import { Head, useForm } from '@inertiajs/react'
|
|
2
|
+
import { FormEventHandler } from 'react'
|
|
3
|
+
import AuthenticatedLayout from '@/Layouts/AuthenticatedLayout'
|
|
4
|
+
import SettingsLayout from '@/Layouts/SettingsLayout'
|
|
5
|
+
import Heading from '@/Components/Heading'
|
|
6
|
+
import InputError from '@/Components/InputError'
|
|
7
|
+
import { Button } from '@/Components/ui/button'
|
|
8
|
+
import { Input } from '@/Components/ui/input'
|
|
9
|
+
import { Label } from '@/Components/ui/label'
|
|
10
|
+
import {
|
|
11
|
+
two_factor_destroy_path,
|
|
12
|
+
two_factor_edit_path,
|
|
13
|
+
two_factor_recovery_codes_path,
|
|
14
|
+
two_factor_store_path,
|
|
15
|
+
two_factor_update_path,
|
|
16
|
+
} from '@/routes'
|
|
17
|
+
import { BreadcrumbItem } from '@/types'
|
|
18
|
+
|
|
19
|
+
const breadcrumbs: BreadcrumbItem[] = [
|
|
20
|
+
{
|
|
21
|
+
title: 'Two factor settings',
|
|
22
|
+
href: two_factor_edit_path(),
|
|
23
|
+
},
|
|
24
|
+
]
|
|
25
|
+
|
|
26
|
+
type Props = {
|
|
27
|
+
enabled: boolean
|
|
28
|
+
pending: boolean
|
|
29
|
+
qrCode: string | null
|
|
30
|
+
secret: string | null
|
|
31
|
+
recoveryCodes: string[]
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
export default function TwoFactor({ enabled, pending, qrCode, secret, recoveryCodes }: Props) {
|
|
35
|
+
return (
|
|
36
|
+
<AuthenticatedLayout breadcrumbs={breadcrumbs}>
|
|
37
|
+
<Head title="Two factor settings" />
|
|
38
|
+
|
|
39
|
+
<SettingsLayout>
|
|
40
|
+
<div className="space-y-6">
|
|
41
|
+
<Heading
|
|
42
|
+
variant="small"
|
|
43
|
+
title="Two factor authentication"
|
|
44
|
+
description="Add a second step to signing in, using an authenticator app"
|
|
45
|
+
/>
|
|
46
|
+
|
|
47
|
+
{enabled ? (
|
|
48
|
+
<Enabled recoveryCodes={recoveryCodes} />
|
|
49
|
+
) : pending ? (
|
|
50
|
+
<Confirming qrCode={qrCode} secret={secret} />
|
|
51
|
+
) : (
|
|
52
|
+
<Disabled />
|
|
53
|
+
)}
|
|
54
|
+
</div>
|
|
55
|
+
</SettingsLayout>
|
|
56
|
+
</AuthenticatedLayout>
|
|
57
|
+
)
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
function Disabled() {
|
|
61
|
+
const { post, processing } = useForm({})
|
|
62
|
+
|
|
63
|
+
const submit: FormEventHandler = (e) => {
|
|
64
|
+
e.preventDefault()
|
|
65
|
+
|
|
66
|
+
post(two_factor_store_path())
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
return (
|
|
70
|
+
<>
|
|
71
|
+
<p className="text-sm text-muted-foreground">
|
|
72
|
+
Two factor authentication is off. Turn it on and you will be asked for a code from your authenticator app each
|
|
73
|
+
time you sign in.
|
|
74
|
+
</p>
|
|
75
|
+
|
|
76
|
+
<form onSubmit={submit}>
|
|
77
|
+
<Button disabled={processing}>Turn on two factor authentication</Button>
|
|
78
|
+
</form>
|
|
79
|
+
</>
|
|
80
|
+
)
|
|
81
|
+
}
|
|
82
|
+
|
|
83
|
+
function Confirming({ qrCode, secret }: { qrCode: string | null; secret: string | null }) {
|
|
84
|
+
const { data, setData, patch, processing, errors } = useForm({ code: '' })
|
|
85
|
+
|
|
86
|
+
const submit: FormEventHandler = (e) => {
|
|
87
|
+
e.preventDefault()
|
|
88
|
+
|
|
89
|
+
patch(two_factor_update_path())
|
|
90
|
+
}
|
|
91
|
+
|
|
92
|
+
return (
|
|
93
|
+
<>
|
|
94
|
+
<p className="text-sm text-muted-foreground">
|
|
95
|
+
Scan this with your authenticator app, then enter the code it shows to finish turning it on.
|
|
96
|
+
</p>
|
|
97
|
+
|
|
98
|
+
{qrCode && (
|
|
99
|
+
<div
|
|
100
|
+
className="w-44 rounded-lg border border-sidebar-border/70 bg-white p-2 dark:border-sidebar-border"
|
|
101
|
+
dangerouslySetInnerHTML={{ __html: qrCode }}
|
|
102
|
+
/>
|
|
103
|
+
)}
|
|
104
|
+
|
|
105
|
+
<p className="text-sm text-muted-foreground">
|
|
106
|
+
Cannot scan it? Enter this key instead:{' '}
|
|
107
|
+
<code className="rounded bg-muted px-1.5 py-0.5 font-mono text-xs text-foreground">{secret}</code>
|
|
108
|
+
</p>
|
|
109
|
+
|
|
110
|
+
<form onSubmit={submit} className="space-y-6">
|
|
111
|
+
<div>
|
|
112
|
+
<Label htmlFor="code">Code</Label>
|
|
113
|
+
|
|
114
|
+
<Input
|
|
115
|
+
id="code"
|
|
116
|
+
name="code"
|
|
117
|
+
value={data.code}
|
|
118
|
+
className="mt-1 block w-full max-w-xs"
|
|
119
|
+
inputMode="numeric"
|
|
120
|
+
autoComplete="one-time-code"
|
|
121
|
+
autoFocus
|
|
122
|
+
onChange={(e) => setData('code', e.target.value)}
|
|
123
|
+
/>
|
|
124
|
+
|
|
125
|
+
<InputError message={errors.code} className="mt-2" />
|
|
126
|
+
</div>
|
|
127
|
+
|
|
128
|
+
<Button disabled={processing}>Confirm</Button>
|
|
129
|
+
</form>
|
|
130
|
+
</>
|
|
131
|
+
)
|
|
132
|
+
}
|
|
133
|
+
|
|
134
|
+
function Enabled({ recoveryCodes }: { recoveryCodes: string[] }) {
|
|
135
|
+
const regenerate = useForm({})
|
|
136
|
+
const disable = useForm({ password: '' })
|
|
137
|
+
|
|
138
|
+
const submitRegenerate: FormEventHandler = (e) => {
|
|
139
|
+
e.preventDefault()
|
|
140
|
+
|
|
141
|
+
regenerate.post(two_factor_recovery_codes_path())
|
|
142
|
+
}
|
|
143
|
+
|
|
144
|
+
const submitDisable: FormEventHandler = (e) => {
|
|
145
|
+
e.preventDefault()
|
|
146
|
+
|
|
147
|
+
disable.delete(two_factor_destroy_path())
|
|
148
|
+
}
|
|
149
|
+
|
|
150
|
+
return (
|
|
151
|
+
<>
|
|
152
|
+
<p className="text-sm text-muted-foreground">
|
|
153
|
+
Two factor authentication is on. You will be asked for a code each time you sign in.
|
|
154
|
+
</p>
|
|
155
|
+
|
|
156
|
+
<div className="space-y-3 rounded-xl border border-sidebar-border/70 p-4 dark:border-sidebar-border">
|
|
157
|
+
<div className="text-sm font-medium">Recovery codes</div>
|
|
158
|
+
|
|
159
|
+
<p className="text-sm text-muted-foreground">
|
|
160
|
+
Keep these somewhere safe. Each one can be used once to sign in if you cannot reach your authenticator app.
|
|
161
|
+
</p>
|
|
162
|
+
|
|
163
|
+
<ul className="grid grid-cols-2 gap-1 font-mono text-xs">
|
|
164
|
+
{recoveryCodes.map((recoveryCode) => (
|
|
165
|
+
<li key={recoveryCode}>{recoveryCode}</li>
|
|
166
|
+
))}
|
|
167
|
+
</ul>
|
|
168
|
+
|
|
169
|
+
<form onSubmit={submitRegenerate}>
|
|
170
|
+
<Button variant="outline" disabled={regenerate.processing}>
|
|
171
|
+
Generate new codes
|
|
172
|
+
</Button>
|
|
173
|
+
</form>
|
|
174
|
+
</div>
|
|
175
|
+
|
|
176
|
+
<form onSubmit={submitDisable} className="space-y-6">
|
|
177
|
+
<div>
|
|
178
|
+
<Label htmlFor="password">Current password</Label>
|
|
179
|
+
|
|
180
|
+
<Input
|
|
181
|
+
id="password"
|
|
182
|
+
type="password"
|
|
183
|
+
name="password"
|
|
184
|
+
value={disable.data.password}
|
|
185
|
+
className="mt-1 block w-full max-w-xs"
|
|
186
|
+
autoComplete="current-password"
|
|
187
|
+
onChange={(e) => disable.setData('password', e.target.value)}
|
|
188
|
+
/>
|
|
189
|
+
|
|
190
|
+
<InputError message={disable.errors.password} className="mt-2" />
|
|
191
|
+
</div>
|
|
192
|
+
|
|
193
|
+
<Button variant="destructive" disabled={disable.processing}>
|
|
194
|
+
Turn off two factor authentication
|
|
195
|
+
</Button>
|
|
196
|
+
</form>
|
|
197
|
+
</>
|
|
198
|
+
)
|
|
199
|
+
}
|
|
@@ -4,7 +4,7 @@ import Heading from '@/Components/Heading.vue'
|
|
|
4
4
|
import { Button } from '@/Components/ui/button'
|
|
5
5
|
import { Separator } from '@/Components/ui/separator'
|
|
6
6
|
import { cn } from '@/lib/utils'
|
|
7
|
-
import { appearance_edit_path, password_edit_path, profile_edit_path } from '@/routes'
|
|
7
|
+
import { appearance_edit_path, password_edit_path, profile_edit_path, two_factor_edit_path } from '@/routes'
|
|
8
8
|
import { NavItem } from '@/types'
|
|
9
9
|
|
|
10
10
|
const sidebarNavItems: NavItem[] = [
|
|
@@ -16,6 +16,10 @@ const sidebarNavItems: NavItem[] = [
|
|
|
16
16
|
title: 'Password',
|
|
17
17
|
href: password_edit_path(),
|
|
18
18
|
},
|
|
19
|
+
{
|
|
20
|
+
title: 'Two factor',
|
|
21
|
+
href: two_factor_edit_path(),
|
|
22
|
+
},
|
|
19
23
|
{
|
|
20
24
|
title: 'Appearance',
|
|
21
25
|
href: appearance_edit_path(),
|
|
@@ -22,7 +22,7 @@ const submit = () => {
|
|
|
22
22
|
|
|
23
23
|
<template>
|
|
24
24
|
<GuestLayout>
|
|
25
|
-
<Head title="Forgot
|
|
25
|
+
<Head title="Forgot password" />
|
|
26
26
|
|
|
27
27
|
<div class="mb-4 text-sm text-gray-600 dark:text-gray-400">
|
|
28
28
|
Forgot your password? No problem. Just let us know your email address and we will email you a password reset link
|
|
@@ -52,7 +52,7 @@ const submit = () => {
|
|
|
52
52
|
|
|
53
53
|
<div class="flex items-center justify-end mt-4">
|
|
54
54
|
<Button :class="{ 'opacity-25': form.processing }" :disabled="form.processing">
|
|
55
|
-
Email
|
|
55
|
+
Email password reset link
|
|
56
56
|
</Button>
|
|
57
57
|
</div>
|
|
58
58
|
</form>
|
|
@@ -28,7 +28,7 @@ const submit = () => {
|
|
|
28
28
|
|
|
29
29
|
<template>
|
|
30
30
|
<GuestLayout>
|
|
31
|
-
<Head title="Reset
|
|
31
|
+
<Head title="Reset password" />
|
|
32
32
|
|
|
33
33
|
<form @submit.prevent="submit">
|
|
34
34
|
<div>
|
|
@@ -48,7 +48,7 @@ const submit = () => {
|
|
|
48
48
|
</div>
|
|
49
49
|
|
|
50
50
|
<div class="mt-4">
|
|
51
|
-
<Label for="password_confirmation">Confirm
|
|
51
|
+
<Label for="password_confirmation">Confirm password</Label>
|
|
52
52
|
|
|
53
53
|
<Input
|
|
54
54
|
id="password_confirmation"
|
|
@@ -63,7 +63,7 @@ const submit = () => {
|
|
|
63
63
|
</div>
|
|
64
64
|
|
|
65
65
|
<div class="flex items-center justify-end mt-4">
|
|
66
|
-
<Button :class="{ 'opacity-25': form.processing }" :disabled="form.processing"> Reset
|
|
66
|
+
<Button :class="{ 'opacity-25': form.processing }" :disabled="form.processing"> Reset password </Button>
|
|
67
67
|
</div>
|
|
68
68
|
</form>
|
|
69
69
|
</GuestLayout>
|
|
@@ -0,0 +1,60 @@
|
|
|
1
|
+
<script setup lang="ts">
|
|
2
|
+
import GuestLayout from '@/Layouts/GuestLayout.vue'
|
|
3
|
+
import { Button } from '@/Components/ui/button'
|
|
4
|
+
import { Input } from '@/Components/ui/input'
|
|
5
|
+
import { Label } from '@/Components/ui/label'
|
|
6
|
+
import InputError from '@/Components/InputError.vue'
|
|
7
|
+
import { Head, useForm } from '@inertiajs/vue3'
|
|
8
|
+
import { two_factor_challenge_store_path } from '@/routes'
|
|
9
|
+
|
|
10
|
+
const form = useForm({
|
|
11
|
+
code: '',
|
|
12
|
+
recovery_code: '',
|
|
13
|
+
})
|
|
14
|
+
</script>
|
|
15
|
+
|
|
16
|
+
<template>
|
|
17
|
+
<GuestLayout>
|
|
18
|
+
<Head title="Two factor authentication" />
|
|
19
|
+
|
|
20
|
+
<div class="mb-4 text-sm text-muted-foreground">
|
|
21
|
+
Enter the code from your authenticator app to finish signing in.
|
|
22
|
+
</div>
|
|
23
|
+
|
|
24
|
+
<form @submit.prevent="form.post(two_factor_challenge_store_path())">
|
|
25
|
+
<div>
|
|
26
|
+
<Label for="code">Code</Label>
|
|
27
|
+
|
|
28
|
+
<Input
|
|
29
|
+
id="code"
|
|
30
|
+
v-model="form.code"
|
|
31
|
+
name="code"
|
|
32
|
+
class="mt-1 block w-full"
|
|
33
|
+
inputmode="numeric"
|
|
34
|
+
autocomplete="one-time-code"
|
|
35
|
+
autofocus
|
|
36
|
+
/>
|
|
37
|
+
|
|
38
|
+
<InputError :message="form.errors.code" class="mt-2" />
|
|
39
|
+
</div>
|
|
40
|
+
|
|
41
|
+
<div class="mt-4">
|
|
42
|
+
<Label for="recovery_code">Or a recovery code</Label>
|
|
43
|
+
|
|
44
|
+
<Input
|
|
45
|
+
id="recovery_code"
|
|
46
|
+
v-model="form.recovery_code"
|
|
47
|
+
name="recovery_code"
|
|
48
|
+
class="mt-1 block w-full"
|
|
49
|
+
autocomplete="one-time-code"
|
|
50
|
+
/>
|
|
51
|
+
|
|
52
|
+
<InputError :message="form.errors.recovery_code" class="mt-2" />
|
|
53
|
+
</div>
|
|
54
|
+
|
|
55
|
+
<div class="flex items-center justify-end mt-4">
|
|
56
|
+
<Button class="ms-4" :class="{ 'opacity-25': form.processing }" :disabled="form.processing"> Continue </Button>
|
|
57
|
+
</div>
|
|
58
|
+
</form>
|
|
59
|
+
</GuestLayout>
|
|
60
|
+
</template>
|
|
@@ -20,7 +20,7 @@ const verificationLinkSent = computed(() => props.status === 'verification-link-
|
|
|
20
20
|
|
|
21
21
|
<template>
|
|
22
22
|
<GuestLayout>
|
|
23
|
-
<Head title="Email
|
|
23
|
+
<Head title="Email verification" />
|
|
24
24
|
|
|
25
25
|
<div class="mb-4 text-sm text-gray-600 dark:text-gray-400">
|
|
26
26
|
Thanks for signing up! Before getting started, could you verify your email address by clicking on the link we just
|
|
@@ -34,7 +34,7 @@ const verificationLinkSent = computed(() => props.status === 'verification-link-
|
|
|
34
34
|
<form @submit.prevent="submit">
|
|
35
35
|
<div class="mt-4 flex items-center justify-between">
|
|
36
36
|
<Button :class="{ 'opacity-25': form.processing }" :disabled="form.processing">
|
|
37
|
-
Resend
|
|
37
|
+
Resend verification email
|
|
38
38
|
</Button>
|
|
39
39
|
|
|
40
40
|
<Link
|
|
@@ -42,7 +42,7 @@ const verificationLinkSent = computed(() => props.status === 'verification-link-
|
|
|
42
42
|
method="post"
|
|
43
43
|
as="button"
|
|
44
44
|
class="underline text-sm text-gray-600 dark:text-gray-400 hover:text-gray-900 dark:hover:text-gray-100 rounded-md focus:outline-hidden focus:ring-2 focus:ring-offset-2 focus:ring-indigo-500 dark:focus:ring-offset-gray-800"
|
|
45
|
-
>Log
|
|
45
|
+
>Log out</Link
|
|
46
46
|
>
|
|
47
47
|
</div>
|
|
48
48
|
</form>
|
|
@@ -49,7 +49,7 @@ const closeModal = () => {
|
|
|
49
49
|
|
|
50
50
|
<template>
|
|
51
51
|
<section class="space-y-6">
|
|
52
|
-
<Button variant="destructive" @click="confirmUserDeletion">Delete
|
|
52
|
+
<Button variant="destructive" @click="confirmUserDeletion">Delete account</Button>
|
|
53
53
|
|
|
54
54
|
<Dialog v-model:open="confirmingUserDeletion">
|
|
55
55
|
<DialogContent>
|
|
@@ -87,7 +87,7 @@ const closeModal = () => {
|
|
|
87
87
|
:disabled="form.processing"
|
|
88
88
|
@click="deleteUser"
|
|
89
89
|
>
|
|
90
|
-
Delete
|
|
90
|
+
Delete account
|
|
91
91
|
</Button>
|
|
92
92
|
</DialogFooter>
|
|
93
93
|
</DialogContent>
|
|
@@ -40,7 +40,7 @@ const updatePassword = () => {
|
|
|
40
40
|
<section>
|
|
41
41
|
<form @submit.prevent="updatePassword" class="space-y-6">
|
|
42
42
|
<div>
|
|
43
|
-
<Label for="current_password">Current
|
|
43
|
+
<Label for="current_password">Current password</Label>
|
|
44
44
|
|
|
45
45
|
<Input
|
|
46
46
|
id="current_password"
|
|
@@ -55,7 +55,7 @@ const updatePassword = () => {
|
|
|
55
55
|
</div>
|
|
56
56
|
|
|
57
57
|
<div>
|
|
58
|
-
<Label for="password">New
|
|
58
|
+
<Label for="password">New password</Label>
|
|
59
59
|
|
|
60
60
|
<Input
|
|
61
61
|
id="password"
|
|
@@ -70,7 +70,7 @@ const updatePassword = () => {
|
|
|
70
70
|
</div>
|
|
71
71
|
|
|
72
72
|
<div>
|
|
73
|
-
<Label for="password_confirmation">Confirm
|
|
73
|
+
<Label for="password_confirmation">Confirm password</Label>
|
|
74
74
|
|
|
75
75
|
<Input
|
|
76
76
|
id="password_confirmation"
|
|
@@ -0,0 +1,147 @@
|
|
|
1
|
+
<script setup lang="ts">
|
|
2
|
+
import { Head, useForm } from '@inertiajs/vue3'
|
|
3
|
+
import AuthenticatedLayout from '@/Layouts/AuthenticatedLayout.vue'
|
|
4
|
+
import SettingsLayout from '@/Layouts/SettingsLayout.vue'
|
|
5
|
+
import Heading from '@/Components/Heading.vue'
|
|
6
|
+
import InputError from '@/Components/InputError.vue'
|
|
7
|
+
import { Button } from '@/Components/ui/button'
|
|
8
|
+
import { Input } from '@/Components/ui/input'
|
|
9
|
+
import { Label } from '@/Components/ui/label'
|
|
10
|
+
import {
|
|
11
|
+
two_factor_destroy_path,
|
|
12
|
+
two_factor_edit_path,
|
|
13
|
+
two_factor_recovery_codes_path,
|
|
14
|
+
two_factor_store_path,
|
|
15
|
+
two_factor_update_path,
|
|
16
|
+
} from '@/routes'
|
|
17
|
+
import { BreadcrumbItem } from '@/types'
|
|
18
|
+
|
|
19
|
+
defineProps<{
|
|
20
|
+
enabled: boolean
|
|
21
|
+
pending: boolean
|
|
22
|
+
qrCode: string | null
|
|
23
|
+
secret: string | null
|
|
24
|
+
recoveryCodes: string[]
|
|
25
|
+
}>()
|
|
26
|
+
|
|
27
|
+
const breadcrumbs: BreadcrumbItem[] = [
|
|
28
|
+
{
|
|
29
|
+
title: 'Two factor settings',
|
|
30
|
+
href: two_factor_edit_path(),
|
|
31
|
+
},
|
|
32
|
+
]
|
|
33
|
+
|
|
34
|
+
const enableForm = useForm({})
|
|
35
|
+
const confirmForm = useForm({ code: '' })
|
|
36
|
+
const regenerateForm = useForm({})
|
|
37
|
+
const disableForm = useForm({ password: '' })
|
|
38
|
+
</script>
|
|
39
|
+
|
|
40
|
+
<template>
|
|
41
|
+
<Head title="Two factor settings" />
|
|
42
|
+
|
|
43
|
+
<AuthenticatedLayout :breadcrumbs="breadcrumbs">
|
|
44
|
+
<SettingsLayout>
|
|
45
|
+
<div class="space-y-6">
|
|
46
|
+
<Heading
|
|
47
|
+
variant="small"
|
|
48
|
+
title="Two factor authentication"
|
|
49
|
+
description="Add a second step to signing in, using an authenticator app"
|
|
50
|
+
/>
|
|
51
|
+
|
|
52
|
+
<template v-if="enabled">
|
|
53
|
+
<p class="text-sm text-muted-foreground">
|
|
54
|
+
Two factor authentication is on. You will be asked for a code each time you sign in.
|
|
55
|
+
</p>
|
|
56
|
+
|
|
57
|
+
<div class="space-y-3 rounded-xl border border-sidebar-border/70 p-4 dark:border-sidebar-border">
|
|
58
|
+
<div class="text-sm font-medium">Recovery codes</div>
|
|
59
|
+
|
|
60
|
+
<p class="text-sm text-muted-foreground">
|
|
61
|
+
Keep these somewhere safe. Each one can be used once to sign in if you cannot reach your authenticator
|
|
62
|
+
app.
|
|
63
|
+
</p>
|
|
64
|
+
|
|
65
|
+
<ul class="grid grid-cols-2 gap-1 font-mono text-xs">
|
|
66
|
+
<li v-for="recoveryCode in recoveryCodes" :key="recoveryCode">{{ recoveryCode }}</li>
|
|
67
|
+
</ul>
|
|
68
|
+
|
|
69
|
+
<form @submit.prevent="regenerateForm.post(two_factor_recovery_codes_path())">
|
|
70
|
+
<Button variant="outline" :disabled="regenerateForm.processing">Generate new codes</Button>
|
|
71
|
+
</form>
|
|
72
|
+
</div>
|
|
73
|
+
|
|
74
|
+
<form class="space-y-6" @submit.prevent="disableForm.delete(two_factor_destroy_path())">
|
|
75
|
+
<div>
|
|
76
|
+
<Label for="password">Current password</Label>
|
|
77
|
+
|
|
78
|
+
<Input
|
|
79
|
+
id="password"
|
|
80
|
+
v-model="disableForm.password"
|
|
81
|
+
type="password"
|
|
82
|
+
name="password"
|
|
83
|
+
class="mt-1 block w-full max-w-xs"
|
|
84
|
+
autocomplete="current-password"
|
|
85
|
+
/>
|
|
86
|
+
|
|
87
|
+
<InputError :message="disableForm.errors.password" class="mt-2" />
|
|
88
|
+
</div>
|
|
89
|
+
|
|
90
|
+
<Button variant="destructive" :disabled="disableForm.processing">
|
|
91
|
+
Turn off two factor authentication
|
|
92
|
+
</Button>
|
|
93
|
+
</form>
|
|
94
|
+
</template>
|
|
95
|
+
|
|
96
|
+
<template v-else-if="pending">
|
|
97
|
+
<p class="text-sm text-muted-foreground">
|
|
98
|
+
Scan this with your authenticator app, then enter the code it shows to finish turning it on.
|
|
99
|
+
</p>
|
|
100
|
+
|
|
101
|
+
<!-- eslint-disable-next-line vue/no-v-html -->
|
|
102
|
+
<div
|
|
103
|
+
v-if="qrCode"
|
|
104
|
+
class="w-44 rounded-lg border border-sidebar-border/70 bg-white p-2 dark:border-sidebar-border"
|
|
105
|
+
v-html="qrCode"
|
|
106
|
+
/>
|
|
107
|
+
|
|
108
|
+
<p class="text-sm text-muted-foreground">
|
|
109
|
+
Cannot scan it? Enter this key instead:
|
|
110
|
+
<code class="rounded bg-muted px-1.5 py-0.5 font-mono text-xs text-foreground">{{ secret }}</code>
|
|
111
|
+
</p>
|
|
112
|
+
|
|
113
|
+
<form class="space-y-6" @submit.prevent="confirmForm.patch(two_factor_update_path())">
|
|
114
|
+
<div>
|
|
115
|
+
<Label for="code">Code</Label>
|
|
116
|
+
|
|
117
|
+
<Input
|
|
118
|
+
id="code"
|
|
119
|
+
v-model="confirmForm.code"
|
|
120
|
+
name="code"
|
|
121
|
+
class="mt-1 block w-full max-w-xs"
|
|
122
|
+
inputmode="numeric"
|
|
123
|
+
autocomplete="one-time-code"
|
|
124
|
+
autofocus
|
|
125
|
+
/>
|
|
126
|
+
|
|
127
|
+
<InputError :message="confirmForm.errors.code" class="mt-2" />
|
|
128
|
+
</div>
|
|
129
|
+
|
|
130
|
+
<Button :disabled="confirmForm.processing">Confirm</Button>
|
|
131
|
+
</form>
|
|
132
|
+
</template>
|
|
133
|
+
|
|
134
|
+
<template v-else>
|
|
135
|
+
<p class="text-sm text-muted-foreground">
|
|
136
|
+
Two factor authentication is off. Turn it on and you will be asked for a code from your authenticator app
|
|
137
|
+
each time you sign in.
|
|
138
|
+
</p>
|
|
139
|
+
|
|
140
|
+
<form @submit.prevent="enableForm.post(two_factor_store_path())">
|
|
141
|
+
<Button :disabled="enableForm.processing">Turn on two factor authentication</Button>
|
|
142
|
+
</form>
|
|
143
|
+
</template>
|
|
144
|
+
</div>
|
|
145
|
+
</SettingsLayout>
|
|
146
|
+
</AuthenticatedLayout>
|
|
147
|
+
</template>
|