Fix code formatting

This commit is contained in:
Oliver Traber 2023-10-29 15:05:46 +01:00
parent f2bc66c3ea
commit 627cfe6462
Signed by: Bluemedia
GPG Key ID: C0674B105057136C
10 changed files with 130 additions and 122 deletions

View File

@ -1,39 +1,39 @@
import { nextTick } from "vue"
import { createI18n } from "vue-i18n"
import { nextTick } from "vue";
import { createI18n } from "vue-i18n";
import { KcContextBase } from "~/types/context";
export const SUPPORT_LOCALES = ["en", "de"]
export const SUPPORT_LOCALES = ["en", "de"];
export function setupI18n(options = {}) {
let browserLocale = navigator.language.split("-")[0];
let defaultLocale = "en";
if (SUPPORT_LOCALES.includes(browserLocale)) {
defaultLocale = browserLocale;
}
const browserLocale = navigator.language.split("-")[0];
let defaultLocale = "en";
if (SUPPORT_LOCALES.includes(browserLocale)) {
defaultLocale = browserLocale;
}
const i18n = createI18n(options)
setI18nLanguage(i18n, defaultLocale)
return i18n
const i18n = createI18n(options);
setI18nLanguage(i18n, defaultLocale);
return i18n;
}
export function setI18nLanguage(i18n, locale) {
loadLocaleMessages(i18n, locale);
if (i18n.mode === "legacy") {
i18n.global.locale = locale;
} else {
i18n.global.locale.value = locale;
}
export function setI18nLanguage(i18n, locale) {
loadLocaleMessages(i18n, locale);
if (i18n.mode === 'legacy') {
i18n.global.locale = locale
} else {
i18n.global.locale.value = locale
}
}
export async function loadLocaleMessages(i18n, locale) {
// load locale messages with dynamic import
let context = (window as any).kcContext as KcContextBase.Common;
const messages = await import(
/* webpackIgnore: true */`${context.url.resourcesPath}/locales/${locale}.js`
)
// set locale and locale message
i18n.global.setLocaleMessage(locale, messages.content)
return nextTick()
}
}
export async function loadLocaleMessages(i18n, locale) {
// load locale messages with dynamic import
const context = (window as any).kcContext as KcContextBase.Common;
const messages = await import(
/* webpackIgnore: true */ `${context.url.resourcesPath}/locales/${locale}.js`
);
// set locale and locale message
i18n.global.setLocaleMessage(locale, messages.content);
return nextTick();
}

View File

@ -1,37 +1,40 @@
export const content = {
"login": {
"title": "Mit Ihrem Konto anmelden",
"noAccount": "Sie haben noch kein Konto?",
"signupLink": "Jetzt registrieren.",
"username": "Benutzername",
"usernameOrEmail": "Benutzername oder E-Mail-Adresse",
"password": "Passwort",
"forgotPassword": "Passwort vergessen?",
"rememberMe": "Angemeldet bleiben",
"login": "Anmelden",
"rety": "Erneut versuchen",
"welcome": "Willkommen!"
},
"2fa": {
"selectFactor": "Bitte wählen Sie einen zweiten Faktor aus:",
"hwSecKey": "Hardware Sicherheits-Schlüssel",
"hwSecKeyDesc": "Verwenden Sie ein WebAuthn kompatibles Gerät",
"otp": "Authenticator App",
"otpDesc": "Verwenden Sie einen Einmalcode aus ihrem Authenticator",
"recoveryCode": "Wiederherstellungsschlüssel",
"recoveryCodeDesc": "Verwenden Sie einen ihrer Wiederherstellungsschlüssel",
"tryAnotherWay": "Eine andere Option nutzen."
},
"webauthn": {
"title": "Bitte verwenden Sie eines ihrer Geräte, um fortzufahren:",
"registered": "Registriert: {date}",
"authenticate": "Fortfahren",
"noDevice": "Kein Gerät zur Hand?",
"noSupport": "Es scheint, als würde ihr Browser WebAuthn nicht unterstützen. Bitte nutzen Sie einen anderen Browser für die Anmeldung.",
"noSupportOtherMethod": "Es scheint, als würde ihr Browser WebAuthn nicht unterstützen. Bitte nutzen Sie einen anderen Browser für die Anmeldung, oder wählen Sie eine andere Anmeldeoption.",
"error": "Bei der Anmeldung mit ihrem Gerät ist etwas schief gelaufen. Bitte versuchen Sie es erneut, oder wählen Sie eine andere Anmeldeoption."
},
"redirect": {
"message": "Sie werden weitergeleitet..."
}
}
login: {
title: "Mit Ihrem Konto anmelden",
noAccount: "Sie haben noch kein Konto?",
signupLink: "Jetzt registrieren.",
username: "Benutzername",
usernameOrEmail: "Benutzername oder E-Mail-Adresse",
password: "Passwort",
forgotPassword: "Passwort vergessen?",
rememberMe: "Angemeldet bleiben",
login: "Anmelden",
rety: "Erneut versuchen",
welcome: "Willkommen!",
},
"2fa": {
selectFactor: "Bitte wählen Sie einen zweiten Faktor aus:",
hwSecKey: "Hardware Sicherheits-Schlüssel",
hwSecKeyDesc: "Verwenden Sie ein WebAuthn kompatibles Gerät",
otp: "Authenticator App",
otpDesc: "Verwenden Sie einen Einmalcode aus ihrem Authenticator",
recoveryCode: "Wiederherstellungsschlüssel",
recoveryCodeDesc: "Verwenden Sie einen ihrer Wiederherstellungsschlüssel",
tryAnotherWay: "Eine andere Option nutzen.",
},
webauthn: {
title: "Bitte verwenden Sie eines ihrer Geräte, um fortzufahren:",
registered: "Registriert: {date}",
authenticate: "Fortfahren",
noDevice: "Kein Gerät zur Hand?",
noSupport:
"Es scheint, als würde ihr Browser WebAuthn nicht unterstützen. Bitte nutzen Sie einen anderen Browser für die Anmeldung.",
noSupportOtherMethod:
"Es scheint, als würde ihr Browser WebAuthn nicht unterstützen. Bitte nutzen Sie einen anderen Browser für die Anmeldung, oder wählen Sie eine andere Anmeldeoption.",
error:
"Bei der Anmeldung mit ihrem Gerät ist etwas schief gelaufen. Bitte versuchen Sie es erneut, oder wählen Sie eine andere Anmeldeoption.",
},
redirect: {
message: "Sie werden weitergeleitet...",
},
};

View File

@ -1,37 +1,40 @@
export const content = {
"login": {
"title": "Login to your account",
"noAccount": "Don't have an account yet?",
"signupLink": "Sign up.",
"username": "Username",
"usernameOrEmail": "Email or Username",
"password": "Password",
"forgotPassword": "Forgot Password?",
"rememberMe": "Remember me",
"login": "Login",
"rety": "Retry",
"welcome": "Welcome!"
},
"2fa": {
"selectFactor": "Please select a second factor you would like to use:",
"hwSecKey": "Hardware Security Key",
"hwSecKeyDesc": "Authenticate using a WebAuthn capable device",
"otp": "Authenticator App",
"otpDesc": "Authenticate using a one time code from your authenticator app",
"recoveryCode": "Recovery Code",
"recoveryCodeDesc": "Authenticate using one of your recovery codes",
"tryAnotherWay": "Try another method."
},
"webauthn": {
"title": "Please use one of your registered devices to continue:",
"registered": "Registered: {date}",
"authenticate": "Continue",
"noDevice": "Don't have your device at hand?",
"noSupport": "It seems that your browser doesn't support WebAuthn. Please try logging in with a different browser.",
"noSupportOtherMethod": "It seems that your browser doesn't support WebAuthn. Please try logging in with a different browser, or try a different login method using the button below.",
"error": "Something went wrong during authentication using your device. Please try again, or use a different login method."
},
"redirect": {
"message": "Redirecting..."
}
}
login: {
title: "Login to your account",
noAccount: "Don't have an account yet?",
signupLink: "Sign up.",
username: "Username",
usernameOrEmail: "Email or Username",
password: "Password",
forgotPassword: "Forgot Password?",
rememberMe: "Remember me",
login: "Login",
rety: "Retry",
welcome: "Welcome!",
},
"2fa": {
selectFactor: "Please select a second factor you would like to use:",
hwSecKey: "Hardware Security Key",
hwSecKeyDesc: "Authenticate using a WebAuthn capable device",
otp: "Authenticator App",
otpDesc: "Authenticate using a one time code from your authenticator app",
recoveryCode: "Recovery Code",
recoveryCodeDesc: "Authenticate using one of your recovery codes",
tryAnotherWay: "Try another method.",
},
webauthn: {
title: "Please use one of your registered devices to continue:",
registered: "Registered: {date}",
authenticate: "Continue",
noDevice: "Don't have your device at hand?",
noSupport:
"It seems that your browser doesn't support WebAuthn. Please try logging in with a different browser.",
noSupportOtherMethod:
"It seems that your browser doesn't support WebAuthn. Please try logging in with a different browser, or try a different login method using the button below.",
error:
"Something went wrong during authentication using your device. Please try again, or use a different login method.",
},
redirect: {
message: "Redirecting...",
},
};

View File

@ -4,7 +4,7 @@
* MIT License
*
* Copyright (c) 2020 GitHub user u/garronej
*
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights

View File

@ -4,6 +4,6 @@ import { setupI18n } from "~/functions/i18n";
if ((window as any).kcContext) {
const app = createApp(index);
app.use(setupI18n())
app.use(setupI18n());
app.mount("#app");
}

View File

@ -22,7 +22,9 @@
method="post">
<div>
<label for="username" class="block text-sm text-gray-800">{{
context.realm.loginWithEmailAllowed ? $t("login.usernameOrEmail") : $t("login.username")
context.realm.loginWithEmailAllowed
? $t("login.usernameOrEmail")
: $t("login.username")
}}</label>
<input
name="username"
@ -37,9 +39,9 @@
</div>
<div class="mt-4">
<div>
<label for="password" class="block text-sm text-gray-800"
>{{ $t("login.password") }}</label
>
<label for="password" class="block text-sm text-gray-800">{{
$t("login.password")
}}</label>
<input
type="password"
name="password"
@ -60,9 +62,9 @@
type="checkbox"
name="rememberMe"
class="w-4 h-4 text-blue-500 bg-gray-100 border-gray-400 rounded dark:ring-offset-gray-800 dark:bg-gray-700 dark:border-gray-600" />
<label for="rememberMe" class="block ml-3 text-sm text-gray-800"
>{{ $t("login.rememberMe") }}</label
>
<label for="rememberMe" class="block ml-3 text-sm text-gray-800">{{
$t("login.rememberMe")
}}</label>
</div>
<input
type="hidden"

View File

@ -4,6 +4,6 @@ import { setupI18n } from "~/functions/i18n";
if ((window as any).kcContext) {
const app = createApp(index);
app.use(setupI18n())
app.use(setupI18n());
app.mount("#app");
}

View File

@ -12,7 +12,9 @@
stroke-dasharray="164 56" />
</svg>
</div>
<h1 class="mt-4 text-xl text-center text-gray-700">{{ $t("redirect.message") }}</h1>
<h1 class="mt-4 text-xl text-center text-gray-700">
{{ $t("redirect.message") }}
</h1>
</layout>
</template>
<script lang="ts">

View File

@ -4,6 +4,6 @@ import { setupI18n } from "~/functions/i18n";
if ((window as any).kcContext) {
const app = createApp(index);
app.use(setupI18n())
app.use(setupI18n());
app.mount("#app");
}

View File

@ -59,9 +59,7 @@
</button>
</div>
<div v-if="error" class="mt-5 flex flex-col">
<ErrorBox
>{{ $t("webauthn.error") }}</ErrorBox
>
<ErrorBox>{{ $t("webauthn.error") }}</ErrorBox>
<button
:onclick="retryAuth"
class="w-full mt-5 px-4 py-2 tracking-wide text-white transition-colors duration-200 transform bg-blue-500 rounded-md hover:bg-blue-400 focus:outline-none focus:bg-blue-400">
@ -105,7 +103,7 @@ export default defineComponent({
},
prepareAuthenticate() {
if (this.context.isUserIdentified) {
const allowedCredentials = new Array<PublicKeyCredentialDescriptor>();
const allowedCredentials: PublicKeyCredentialDescriptor[] = [];
this.context.authenticators.authenticators.forEach(authenticator => {
allowedCredentials.push({
id: base64url.parse(authenticator.credentialId, { loose: true }),
@ -118,7 +116,7 @@ export default defineComponent({
}
},
async authenticate(
allowedAuthenticators: Array<PublicKeyCredentialDescriptor>
allowedAuthenticators: PublicKeyCredentialDescriptor[]
) {
const publicKey: PublicKeyCredentialRequestOptions = {
rpId: this.context.rpId,