diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml new file mode 100644 index 0000000..40d00bd --- /dev/null +++ b/.github/workflows/test.yml @@ -0,0 +1,19 @@ +name: test + +on: + pull_request: + branches: [main] + +jobs: + build: + runs-on: ubuntu-latest + + steps: + - uses: actions/checkout@v3 + + - name: Build and Test + uses: qcastel/github-actions-maven-cmd@master + env: + CI: "" + with: + maven-args: "clean install -Dmaven.test.skip=true -Ddockerfile.skip -DdockerCompose.skip -Djib.skip" diff --git a/src/pages/profile/signin.tsx b/src/pages/profile/signin.tsx index 3686143..0cc691a 100644 --- a/src/pages/profile/signin.tsx +++ b/src/pages/profile/signin.tsx @@ -19,15 +19,15 @@ import { AIACommand } from "services/aia-command"; import P2Toast from "components/utils/toast"; import { Key, Lock, Smartphone } from "lucide-react"; -const PASSWORD = "password"; -const TWO_FACTOR_AUTH = "2fa"; -const WEB_AUTH_N = "webauthn"; -const WEB_AUTH_N_REGISTER = "webauthn-register"; -const WEB_AUTH_N_PASSWORDLESS = "webauthn-passwordless"; -const WEB_AUTH_N_PASSWORDLESS_REGISTER = "webauthn-register-passwordless"; -const OTP = "otp"; - -type CredentialType = PASSWORD | TWO_FACTOR_AUTH | WEB_AUTH_N | OTP; +enum CredentialType { + PASSWORD = "password", + TWO_FACTOR_AUTH = "2fa", + WEB_AUTH_N = "webauthn", + WEB_AUTH_N_REGISTER = "webauthn-register", + WEB_AUTH_N_PASSWORDLESS = "webauthn-passwordless", + WEB_AUTH_N_PASSWORDLESS_REGISTER = "webauthn-register-passwordless", + OTP = "otp", +} const time = (time: string | undefined): string => { if (time === undefined) return "unknown"; @@ -42,11 +42,13 @@ const SigninProfile = () => { }); const [deleteCredential] = useDeleteCredentialMutation(); - const hasWebAuthN = credentials.find((cred) => cred.type === WEB_AUTH_N); + const hasWebAuthN = credentials.find( + (cred) => cred.type === CredentialType.WEB_AUTH_N + ); const hasWebAuthNPasswordLess = credentials.find( - (cred) => cred.type === WEB_AUTH_N_PASSWORDLESS + (cred) => cred.type === CredentialType.WEB_AUTH_N_PASSWORDLESS ); - const hasOTP = credentials.find((cred) => cred.type === OTP); + const hasOTP = credentials.find((cred) => cred.type === CredentialType.OTP); const removeCredential = ( credential: CredentialMetadataRepresentation @@ -109,14 +111,16 @@ const SigninProfile = () => { isCompact className="inline-flex w-full justify-center sm:ml-3 sm:w-auto" onClick={() => { - if (credentialType === "password") { + if (credentialType === CredentialType.PASSWORD) { updateAIA("UPDATE_PASSWORD"); } else { removeCredential(metadata.credential!); } }} > - {credentialType === "password" ? t("update") : t("remove")} + {credentialType === CredentialType.PASSWORD + ? t("update") + : t("remove")} )} @@ -151,7 +155,7 @@ const SigninProfile = () => { /> @@ -172,7 +176,10 @@ const SigninProfile = () => { {isLoading && (
)} @@ -188,7 +195,8 @@ const SigninProfile = () => { variant="small" /> - {rowsForType(OTP, credentials).length !== 0 && ( + {rowsForType(CredentialType.OTP, credentials).length !== + 0 && (
@@ -223,10 +231,13 @@ const SigninProfile = () => { description={t("useYourSecurityKeyToSignIn")} variant="small" /> - {rowsForType(WEB_AUTH_N, credentials).length !== 0 && ( + {rowsForType(CredentialType.WEB_AUTH_N, credentials) + .length !== 0 && ( @@ -234,13 +245,15 @@ const SigninProfile = () => {
@@ -270,12 +283,16 @@ const SigninProfile = () => { description={t("useYourSecurityKeyForPasswordlessSignIn")} variant="small" /> - {rowsForType(WEB_AUTH_N_PASSWORDLESS, credentials).length !== - 0 && ( + {rowsForType( + CredentialType.WEB_AUTH_N_PASSWORDLESS, + credentials + ).length !== 0 && (