|
2 | 2 | <div class="session-expiry"> |
3 | 3 | <button v-if="isWarning" class="session-expiry-stripe" @click="extend" v-text="warningText" /> |
4 | 4 |
|
5 | | - <modal name="session-timeout-login" v-if="isShowingLogin" height="auto" :width="500"> |
6 | | - <div class="-max-h-screen-px"> |
7 | | - <div |
8 | | - class="flex items-center justify-between rounded-t-lg border-b bg-gray-200 px-5 py-3 text-lg font-semibold dark:border-dark-900 dark:bg-dark-550" |
9 | | - > |
10 | | - {{ __('Resume Your Session') }} |
11 | | - </div> |
12 | | - |
13 | | - <div v-if="isUsingOauth" class="p-5"> |
14 | | - <a :href="oauthProvider.loginUrl" target="_blank" class="btn-primary"> |
15 | | - {{ __('Log in with :provider', { provider: oauthProvider.label }) }} |
16 | | - </a> |
17 | | - <div class="mt-4 text-2xs text-gray"> |
18 | | - {{ __('messages.session_expiry_new_window') }} |
19 | | - </div> |
| 5 | + <Modal :title="__('Resume Your Session')" :open="isShowingLogin" height="auto" :width="500"> |
| 6 | + <div v-if="isUsingOauth" class="p-5"> |
| 7 | + <a :href="oauthProvider.loginUrl" target="_blank" class="btn-primary"> |
| 8 | + {{ __('Log in with :provider', { provider: oauthProvider.label }) }} |
| 9 | + </a> |
| 10 | + <div class="mt-4 text-2xs text-gray"> |
| 11 | + {{ __('messages.session_expiry_new_window') }} |
20 | 12 | </div> |
| 13 | + </div> |
21 | 14 |
|
22 | | - <div v-if="!isUsingOauth" class="publish-fields p-2"> |
23 | | - <div class="form-group w-full"> |
24 | | - <label v-text="__('messages.session_expiry_enter_password')" /> |
25 | | - <small class="help-block text-red-500" v-if="errors.email" v-text="errors.email[0]" /> |
26 | | - <small class="help-block text-red-500" v-if="errors.password" v-text="errors.password[0]" /> |
27 | | - <div class="flex items-center"> |
28 | | - <input |
29 | | - type="password" |
30 | | - v-model="password" |
31 | | - ref="password" |
32 | | - class="input-text" |
33 | | - tabindex="1" |
34 | | - autofocus |
35 | | - @keydown.enter.prevent="submit" |
36 | | - /> |
37 | | - <button @click="submit" class="btn-primary ltr:ml-2 rtl:mr-2" v-text="__('Log in')" /> |
38 | | - </div> |
| 15 | + <div v-if="!isUsingOauth" class="publish-fields p-2"> |
| 16 | + <div class="form-group w-full"> |
| 17 | + <label v-text="__('messages.session_expiry_enter_password')" /> |
| 18 | + <small class="help-block text-red-500" v-if="errors.email" v-text="errors.email[0]" /> |
| 19 | + <small class="help-block text-red-500" v-if="errors.password" v-text="errors.password[0]" /> |
| 20 | + <div class="flex items-center"> |
| 21 | + <Input |
| 22 | + type="password" |
| 23 | + v-model="password" |
| 24 | + ref="password" |
| 25 | + tabindex="1" |
| 26 | + autofocus |
| 27 | + @keydown.enter.prevent="submit" |
| 28 | + /> |
| 29 | + <Button @click="submit" class="ms-2" variant="primary" :text="__('Log in')" /> |
39 | 30 | </div> |
40 | 31 | </div> |
41 | 32 | </div> |
42 | | - </modal> |
43 | | - |
44 | | - <modal name="session-timeout-login" v-if="isShowingTwoFactorChallenge" height="auto" :width="500"> |
45 | | - <div class="-max-h-screen-px"> |
46 | | - <div |
47 | | - class="flex items-center justify-between rounded-t-lg border-b bg-gray-200 px-5 py-3 text-lg font-semibold dark:border-dark-900 dark:bg-dark-550" |
48 | | - > |
49 | | - {{ __('Resume Your Session') }} |
50 | | - </div> |
51 | | - |
52 | | - <div class="publish-fields p-2"> |
53 | | - <div v-if="twoFactorMode === 'code'" class="form-group w-full"> |
54 | | - <label v-text="__('messages.session_expiry_enter_two_factor_code')" /> |
55 | | - <small class="help-block text-red-500" v-if="errors.code" v-text="errors.code[0]" /> |
56 | | - <div class="flex items-center"> |
57 | | - <input |
58 | | - type="text" |
59 | | - name="code" |
60 | | - v-model="twoFactorCode" |
61 | | - ref="twoFactorCode" |
62 | | - class="input-text" |
63 | | - tabindex="1" |
64 | | - pattern="[0-9]*" |
65 | | - maxlength="6" |
66 | | - inputmode="numeric" |
67 | | - autofocus |
68 | | - autocomplete="one-time-code" |
69 | | - @keydown.enter.prevent="submitTwoFactorChallenge" |
70 | | - /> |
71 | | - </div> |
| 33 | + </Modal> |
| 34 | + |
| 35 | + <Modal :title="__('Resume Your Session')" :open="isShowingTwoFactorChallenge" height="auto" :width="500"> |
| 36 | + <div class="publish-fields p-2"> |
| 37 | + <div v-if="twoFactorMode === 'code'" class="form-group w-full"> |
| 38 | + <label v-text="__('messages.session_expiry_enter_two_factor_code')" /> |
| 39 | + <small class="help-block text-red-500" v-if="errors.code" v-text="errors.code[0]" /> |
| 40 | + <div class="flex items-center"> |
| 41 | + <Input |
| 42 | + name="code" |
| 43 | + v-model="twoFactorCode" |
| 44 | + ref="twoFactorCode" |
| 45 | + tabindex="1" |
| 46 | + pattern="[0-9]*" |
| 47 | + maxlength="6" |
| 48 | + inputmode="numeric" |
| 49 | + autofocus |
| 50 | + autocomplete="one-time-code" |
| 51 | + @keydown.enter.prevent="submitTwoFactorChallenge" |
| 52 | + /> |
72 | 53 | </div> |
| 54 | + </div> |
73 | 55 |
|
74 | | - <div v-if="twoFactorMode === 'recovery_code'" class="form-group w-full"> |
75 | | - <label v-text="__('messages.session_expiry_enter_two_factor_recovery_code')" /> |
76 | | - <small |
77 | | - class="help-block text-red-500" |
78 | | - v-if="errors.recovery_code" |
79 | | - v-text="errors.recovery_code[0]" |
| 56 | + <div v-if="twoFactorMode === 'recovery_code'" class="form-group w-full"> |
| 57 | + <label v-text="__('messages.session_expiry_enter_two_factor_recovery_code')" /> |
| 58 | + <small |
| 59 | + class="help-block text-red-500" |
| 60 | + v-if="errors.recovery_code" |
| 61 | + v-text="errors.recovery_code[0]" |
| 62 | + /> |
| 63 | + <div class="flex items-center"> |
| 64 | + <Input |
| 65 | + name="recovery_code" |
| 66 | + v-model="twoFactorRecoveryCode" |
| 67 | + ref="twoFactorRecoveryCode" |
| 68 | + tabindex="1" |
| 69 | + maxlength="21" |
| 70 | + autofocus |
| 71 | + autocomplete="off" |
| 72 | + @keydown.enter.prevent="submitTwoFactorChallenge" |
80 | 73 | /> |
81 | | - <div class="flex items-center"> |
82 | | - <input |
83 | | - type="text" |
84 | | - name="recovery_code" |
85 | | - v-model="twoFactorRecoveryCode" |
86 | | - ref="twoFactorRecoveryCode" |
87 | | - class="input-text" |
88 | | - tabindex="1" |
89 | | - maxlength="21" |
90 | | - autofocus |
91 | | - autocomplete="off" |
92 | | - @keydown.enter.prevent="submitTwoFactorChallenge" |
93 | | - /> |
94 | | - </div> |
95 | 74 | </div> |
96 | 75 | </div> |
| 76 | + </div> |
97 | 77 |
|
98 | | - <div |
99 | | - class="flex items-center justify-end border-t bg-gray-200 p-4 text-sm dark:border-dark-900 dark:bg-dark-550" |
100 | | - > |
101 | | - <button |
| 78 | + <template #footer> |
| 79 | + <div class="flex items-center justify-end space-x-3 pt-3 pb-1"> |
| 80 | + <Button |
102 | 81 | v-if="twoFactorMode === 'code'" |
103 | | - class="text-gray hover:text-gray-900 dark:text-dark-150 dark:hover:text-dark-100" |
| 82 | + variant="ghost" |
104 | 83 | @click="twoFactorMode = 'recovery_code'" |
105 | | - v-text="__('Use recovery code')" |
| 84 | + :text="__('Use recovery code')" |
106 | 85 | /> |
107 | | - <button |
| 86 | + <Button |
108 | 87 | v-if="twoFactorMode === 'recovery_code'" |
109 | | - class="text-gray hover:text-gray-900 dark:text-dark-150 dark:hover:text-dark-100" |
| 88 | + variant="ghost" |
110 | 89 | @click="twoFactorMode = 'code'" |
111 | | - v-text="__('Use one-time code')" |
| 90 | + :text="__('Use one-time code')" |
112 | 91 | /> |
113 | | - <button |
114 | | - class="btn-primary ltr:ml-4 rtl:mr-4" |
| 92 | + <Button |
| 93 | + variant="primary" |
115 | 94 | @click="submitTwoFactorChallenge" |
116 | | - v-text="__('Continue')" |
| 95 | + :text="__('Continue')" |
117 | 96 | /> |
118 | 97 | </div> |
119 | | - </div> |
120 | | - </modal> |
| 98 | + </template> |
| 99 | + </Modal> |
121 | 100 | </div> |
122 | 101 | </template> |
123 | 102 |
|
124 | 103 | <script> |
| 104 | +import { Modal, Input, Button } from '@statamic/ui'; |
| 105 | +
|
125 | 106 | var counter; |
126 | 107 |
|
127 | 108 | export default { |
| 109 | + components: { |
| 110 | + Modal, |
| 111 | + Input, |
| 112 | + Button, |
| 113 | + }, |
| 114 | +
|
128 | 115 | props: { |
129 | 116 | warnAt: Number, |
130 | 117 | lifetime: Number, |
|
0 commit comments