|
1 | 1 | <template> |
2 | 2 | <div class="af-passkeys flex flex-col justify-center mr-6 md:mr-12"> |
3 | 3 | <h2 class="af-passkeys-title flex items-start justify-start leading-none text-gray-800 dark:text-gray-50 text-3xl font-semibold">{{$t('Passkeys')}}</h2> |
4 | | - <p class="af-passkeys-subtitle text-sm mt-3">Manage your passwordless authentication methods</p> |
| 4 | + <p class="af-passkeys-subtitle text-sm mt-3"> {{$t('Manage your passwordless authentication methods')}} </p> |
5 | 5 |
|
6 | 6 | <div class="af-passkeys-grid mt-6 flex flex-wrap gap-4"> |
7 | 7 | <div |
|
177 | 177 | isFetchingPasskey.value = true; |
178 | 178 | try { |
179 | 179 | const confirmationResult = await window.adminforthTwoFaModal |
180 | | - .get2FaConfirmationResult('To add passkey first verify yourself'); |
| 180 | + .get2FaConfirmationResult(t('To add passkey first verify yourself')); |
181 | 181 |
|
182 | 182 | if (!confirmationResult) return; |
183 | 183 |
|
184 | 184 | const { options, error } = await requestPasskeyChallenge(confirmationResult); |
185 | 185 | if (!options) { |
186 | | - adminforth.alert({ message: error ?? 'Verification failed.', variant: 'warning' }); |
| 186 | + adminforth.alert({ message: error ?? t('Verification failed.'), variant: 'warning' }); |
187 | 187 | return; |
188 | 188 | } |
189 | 189 |
|
|
210 | 210 | passkeys.value = response.data; |
211 | 211 | authenticatorAttachment.value = response.authenticatorAttachment; |
212 | 212 | } catch (error) { |
213 | | - console.error('Error fetching passkeys:', error); |
| 213 | + console.error(t('Error fetching passkeys:'), error); |
214 | 214 | if (coreStore.adminUser?.username) { |
215 | | - adminforth.alert({ message: 'Error fetching passkeys.', variant: 'warning' }); |
| 215 | + adminforth.alert({ message: t('Error fetching passkeys.'), variant: 'warning' }); |
216 | 216 | } |
217 | 217 | } |
218 | 218 | } |
|
226 | 226 | method: 'POST', |
227 | 227 | body: { mode: addPasskeyMode.value, confirmationResult }, |
228 | 228 | }); |
229 | | - if (!response.ok) return { error: response.error ?? 'Verification failed' }; |
| 229 | + if (!response.ok) return { error: response.error ?? t('Verification failed') }; |
230 | 230 | const options = PublicKeyCredential.parseCreationOptionsFromJSON(response.data); |
231 | 231 | return { options, challengeId: response.challengeId }; |
232 | 232 | } catch (error) { |
233 | | - console.error('Error requesting passkey challenge:', error); |
234 | | - return { error: 'Failed to request passkey challenge' }; |
| 233 | + console.error(t('Error requesting passkey challenge:', error)); |
| 234 | + return { error: t('Failed to request passkey challenge' )}; |
235 | 235 | } |
236 | 236 | } |
237 | 237 |
|
|
240 | 240 | const credential = await navigator.credentials.create({ publicKey: options }); |
241 | 241 | return JSON.stringify((credential as PublicKeyCredential).toJSON()); |
242 | 242 | } catch (error) { |
243 | | - console.error('Error creating WebAuthn credential:', error); |
244 | | - adminforth.alert({ message: 'Error creating passkey.', variant: 'warning' }); |
| 243 | + console.error(t('Error creating WebAuthn credential:', error)); |
| 244 | + adminforth.alert({ message: t('Error creating passkey.'), variant: 'warning' }); |
245 | 245 | return null; |
246 | 246 | } |
247 | 247 | } |
|
254 | 254 | body: { credential, origin: window.location.origin }, |
255 | 255 | }); |
256 | 256 | if (res.ok) { |
257 | | - adminforth.alert({ message: 'Passkey registered successfully!', variant: 'success' }); |
| 257 | + adminforth.alert({ message: t('Passkey registered successfully!'), variant: 'success' }); |
258 | 258 | getPasskeys(); |
259 | 259 | } else { |
260 | | - adminforth.alert({ message: 'Error registering passkey.', variant: 'warning' }); |
| 260 | + adminforth.alert({ message: t('Error registering passkey.'), variant: 'warning' }); |
261 | 261 | } |
262 | 262 | } catch (error) { |
263 | | - console.error('Error registering passkey:', error); |
| 263 | + console.error(t('Error registering passkey:', error)); |
264 | 264 | } |
265 | 265 | } |
266 | 266 |
|
|
283 | 283 | body: { passkeyId }, |
284 | 284 | }); |
285 | 285 | if (response.ok) { |
286 | | - adminforth.alert({ message: 'Passkey deleted successfully!', variant: 'success' }); |
| 286 | + adminforth.alert({ message: t('Passkey deleted successfully!'), variant: 'success' }); |
287 | 287 | getPasskeys(); |
288 | 288 | } else { |
289 | | - console.error('Error deleting passkey:', response?.error); |
290 | | - adminforth.alert({ message: 'Error deleting passkey.', variant: 'warning' }); |
| 289 | + console.error(t('Error deleting passkey:', response?.error)); |
| 290 | + adminforth.alert({ message: t('Error deleting passkey.'), variant: 'warning' }); |
291 | 291 | } |
292 | 292 | } catch (error) { |
293 | | - console.error('Error deleting passkey:', error); |
294 | | - adminforth.alert({ message: 'Error deleting passkey.', variant: 'warning' }); |
| 293 | + console.error(t('Error deleting passkey:', error)); |
| 294 | + adminforth.alert({ message: t('Error deleting passkey.'), variant: 'warning' }); |
295 | 295 | } |
296 | 296 | } |
297 | 297 |
|
|
303 | 303 | body: { passkeyId, newName: name }, |
304 | 304 | }); |
305 | 305 | if (response.ok) { |
306 | | - adminforth.alert({ message: 'Passkey updated successfully!', variant: 'success' }); |
| 306 | + adminforth.alert({ message: t('Passkey updated successfully!'), variant: 'success' }); |
307 | 307 | getPasskeys(); |
308 | 308 | } else { |
309 | | - console.error('Error updating passkey:', response.error); |
310 | | - adminforth.alert({ message: 'Error updating passkey.', variant: 'warning' }); |
| 309 | + console.error(t('Error updating passkey:', response.error)); |
| 310 | + adminforth.alert({ message: t('Error updating passkey.'), variant: 'warning' }); |
311 | 311 | } |
312 | 312 | } catch (error) { |
313 | | - console.error('Error updating passkey:', error); |
314 | | - adminforth.alert({ message: 'Error updating passkey.', variant: 'warning' }); |
| 313 | + console.error(t('Error updating passkey:', error)); |
| 314 | + adminforth.alert({ message: t('Error updating passkey.'), variant: 'warning' }); |
315 | 315 | } |
316 | 316 | } |
317 | 317 |
|
|
0 commit comments