From 4b8ae76132d2342f40cec703b3d5145ea075c451 Mon Sep 17 00:00:00 2001 From: vnugent Date: Wed, 13 Dec 2023 17:58:51 -0500 Subject: log time coming ui and lib updates --- .../views/Account/components/profile/Profile.vue | 55 +++++++--------------- .../src/views/Account/components/settings/Fido.vue | 4 +- .../Account/components/settings/PasswordReset.vue | 16 +++---- .../src/views/Account/components/settings/Pki.vue | 46 ++++++++---------- .../views/Account/components/settings/Security.vue | 31 ++++++------ .../views/Account/components/settings/Settings.vue | 2 +- .../Account/components/settings/TotpSettings.vue | 40 +++++++--------- 7 files changed, 81 insertions(+), 113 deletions(-) (limited to 'front-end/src/views/Account/components') diff --git a/front-end/src/views/Account/components/profile/Profile.vue b/front-end/src/views/Account/components/profile/Profile.vue index 0b0a6dd..0db7192 100644 --- a/front-end/src/views/Account/components/profile/Profile.vue +++ b/front-end/src/views/Account/components/profile/Profile.vue @@ -2,10 +2,10 @@
-
+
-
+
@@ -28,7 +28,7 @@
-

+

You may set or change your profile information here. All fields are optional, but some features may not work without some information.

@@ -36,7 +36,7 @@
Email: - {{ data.email }} + {{ store.userProfile.data.email }}
Created: @@ -62,43 +62,28 @@ import { defaultTo } from 'lodash-es' import useVuelidate from '@vuelidate/core' import { ref, computed, watch } from 'vue' import { Rules, FormSchema } from './profile-schema.ts' -import { apiCall, useMessage, useWait, useDataBuffer, useUser, useVuelidateWrapper, IUserProfile } from '@vnuge/vnlib.browser' - -const ACCOUNT_URL = '/account/profile' - -interface UserProfile extends IUserProfile{ - created : string | Date -} +import { apiCall, useMessage, useWait, useVuelidateWrapper, WebMessage } from '@vnuge/vnlib.browser' +import { useStore } from '../../../../store' const { waiting } = useWait() -const { getProfile } = useUser() const { onInput, clearMessage } = useMessage() -const { data, buffer, apply, revert, modified } = useDataBuffer({} as UserProfile) + +const store = useStore() const editMode = ref(false) // Create validator based on the profile buffer as a data model -const v$ = useVuelidate(Rules, buffer, { $lazy:true, $autoDirty:false }) +const v$ = useVuelidate(Rules, store.userProfile.buffer, { $lazy:true }) // Setup the validator wrapper const { validate } = useVuelidateWrapper(v$); //const modified = computed(() => profile.value.Modified) -const createdTime = computed(() => defaultTo(data.created?.toLocaleString(), '')) - -const loadProfileData = async () => { - await apiCall(async () => { - // Get the user's profile - const profile = await getProfile() - profile.created = new Date(profile.created) - //Apply the profile to the buffer - apply(profile) - }) -} +const createdTime = computed(() => defaultTo(store.userProfile.data.created?.toLocaleString(), '')) const revertProfile = () => { //Revert the buffer - revert() + store.userProfile.revert() clearMessage() editMode.value = false } @@ -112,32 +97,24 @@ const onSubmit = async () => { return } // Init the api call - await apiCall(async ({ axios, toaster }) => { - // Apply the buffer to the profile - const response = await axios.post(ACCOUNT_URL, buffer) - - if(!response.data.success){ - throw { response } - } + await apiCall(async ({ toaster }) => { + const res = await store.userProfile.update(); + const successm = (res as WebMessage).getResultOrThrow(); + //No longer in edit mode editMode.value = false //Show success message toaster.general.success({ title: 'Update successful', - text: response.data.result, + text: successm, }) - - //reload the profile data - loadProfileData() }) } watch(editMode, () => v$.value.$reset()) -//Inital profile data load, dont await -loadProfileData() diff --git a/front-end/src/views/Account/components/settings/Fido.vue b/front-end/src/views/Account/components/settings/Fido.vue index f319cd3..d453378 100644 --- a/front-end/src/views/Account/components/settings/Fido.vue +++ b/front-end/src/views/Account/components/settings/Fido.vue @@ -18,13 +18,13 @@
-
-

+

WebAuthN/FIDO is not yet supported, due to complexity and browser support.

diff --git a/front-end/src/views/Account/components/settings/PasswordReset.vue b/front-end/src/views/Account/components/settings/PasswordReset.vue index f90bce8..24dced6 100644 --- a/front-end/src/views/Account/components/settings/PasswordReset.vue +++ b/front-end/src/views/Account/components/settings/PasswordReset.vue @@ -2,24 +2,22 @@
-
Password Reset
- -
+
- -
- Click to reset + +
+
Password Reset
-
-

+

You may only reset your password if you have an internal user account. If you exclusivly use an external authentication provider (like GitHub or Discord), you will need to reset your password externally.

@@ -61,7 +59,7 @@ diff --git a/front-end/src/views/Account/components/settings/Settings.vue b/front-end/src/views/Account/components/settings/Settings.vue index cd2ab48..fb86951 100644 --- a/front-end/src/views/Account/components/settings/Settings.vue +++ b/front-end/src/views/Account/components/settings/Settings.vue @@ -7,7 +7,7 @@ diff --git a/front-end/src/views/Account/components/settings/TotpSettings.vue b/front-end/src/views/Account/components/settings/TotpSettings.vue index 9760806..0fcfe31 100644 --- a/front-end/src/views/Account/components/settings/TotpSettings.vue +++ b/front-end/src/views/Account/components/settings/TotpSettings.vue @@ -24,13 +24,13 @@ Your secret, if your application requires it.

-

+

{{ code }}

-

+

Please enter your code from your authenticator app to continue.

@@ -58,7 +58,7 @@
TOTP Authenticator App
- @@ -74,7 +74,7 @@ Setup
-

+

TOTP is a time based one time password. You can use it as a form of Multi Factor Authentication when using another device such as a smart phone or TOTP hardware device. You can use TOTP with your smart phone @@ -91,21 +91,21 @@ -- cgit