diff --git a/src/boot/appwrite.ts b/src/boot/appwrite.ts index 91b50c7..d0d8f5c 100644 --- a/src/boot/appwrite.ts +++ b/src/boot/appwrite.ts @@ -14,7 +14,6 @@ import type { Router } from 'vue-router'; const client = new Client(); -console.log(import.meta.env); const VITE_APPWRITE_API_ENDPOINT = import.meta.env.VITE_APPWRITE_API_ENDPOINT; const VITE_APPWRITE_API_PROJECT = import.meta.env.VITE_APPWRITE_API_PROJECT; @@ -28,7 +27,6 @@ if (VITE_APPWRITE_API_ENDPOINT && VITE_APPWRITE_API_PROJECT) { ); } -console.log(process.env); const pwresetUrl = process.env.DEV ? 'http://localhost:4000/pwreset' : 'https://oys.undock.ca/pwreset'; diff --git a/src/components/NewPasswordComponent.vue b/src/components/NewPasswordComponent.vue new file mode 100644 index 0000000..8bbb60c --- /dev/null +++ b/src/components/NewPasswordComponent.vue @@ -0,0 +1,62 @@ + + + diff --git a/src/pages/LoginPage.vue b/src/pages/LoginPage.vue index 2d7bb2e..2a35038 100644 --- a/src/pages/LoginPage.vue +++ b/src/pages/LoginPage.vue @@ -29,35 +29,37 @@ color="darkblue" filled> + - - - Reset password - - - + +
+ +
+
+ +
diff --git a/src/pages/ResetPassword.vue b/src/pages/ResetPassword.vue index b302794..257ccc8 100644 --- a/src/pages/ResetPassword.vue +++ b/src/pages/ResetPassword.vue @@ -34,58 +34,27 @@ @click="resetPw" label="Send Reset Link" color="primary"> -
- - - - -
Enter a new password.
-
- - - - -
+
+ + + + + + +
Invalid reset link. - @@ -112,38 +81,11 @@ import { ref } from 'vue'; import { account, resetPassword } from 'boot/appwrite'; import { useRouter } from 'vue-router'; import { Dialog } from 'quasar'; -// import GoogleOauthComponent from 'src/components/GoogleOauthComponent.vue'; +import NewPasswordComponent from 'components/NewPasswordComponent.vue'; const email = ref(''); const router = useRouter(); -const password = ref(''); -const confirmPassword = ref(''); - -const validatePasswordStrength = (val: string) => { - const hasUpperCase = /[A-Z]/.test(val); - const hasLowerCase = /[a-z]/.test(val); - const hasNumbers = /[0-9]/.test(val); - const hasNonAlphas = /[\W_]/.test(val); - const isValidLength = val.length >= 8; - - return ( - (hasUpperCase && - hasLowerCase && - hasNumbers && - hasNonAlphas && - isValidLength) || - 'Password must be at least 8 characters long and include uppercase, lowercase, number, and special character.' - ); -}; - -const validatePasswordsMatch = (val: string) => { - return val === password.value || 'Passwords do not match.'; -}; - -function isPasswordResetLink() { - const query = router.currentRoute.value.query; - return query && query.secret && query.userId && query.expire; -} +const newPassword = ref(); function validResetLink(): boolean { const query = router.currentRoute.value.query; @@ -153,27 +95,34 @@ function validResetLink(): boolean { ); } +function isPasswordResetLink() { + const query = router.currentRoute.value.query; + return query && query.secret && query.userId && query.expire; +} + function submitNewPw() { const query = router.currentRoute.value.query; - if ( - validatePasswordStrength(password.value) === true && - validatePasswordsMatch(confirmPassword.value) === true - ) { + if (newPassword.value) { account .updateRecovery( query.userId as string, query.secret as string, - password.value + newPassword.value ) .then(() => { - Dialog.create({ message: 'Password Changed!' }); - router.replace('/login'); + Dialog.create({ message: 'Password Changed!' }).onOk(() => + router.replace('/login') + ); }) .catch((e) => Dialog.create({ message: 'Password change failed! Error: ' + e.message, }) ); + } else { + Dialog.create({ + message: 'Invalid password. Try again', + }); } } diff --git a/src/pages/SignupPage.vue b/src/pages/SignupPage.vue new file mode 100644 index 0000000..afea5ef --- /dev/null +++ b/src/pages/SignupPage.vue @@ -0,0 +1,86 @@ + + + + + diff --git a/src/router/routes.ts b/src/router/routes.ts index 9f6382b..2c24199 100644 --- a/src/router/routes.ts +++ b/src/router/routes.ts @@ -168,14 +168,14 @@ const routes: RouteRecordRaw[] = [ publicRoute: true, }, }, - // { - // path: '/register', - // component: () => import('pages/RegisterPage.vue'), - // name: 'register' - // meta: { - // accountRoute: true, - // } - // }, + { + path: '/signup', + component: () => import('pages/SignupPage.vue'), + name: 'signup', + meta: { + publicRoute: true, + }, + }, // Always leave this as last one, // but you can also remove it { diff --git a/src/stores/auth.ts b/src/stores/auth.ts index fcecfc6..eb9cfc6 100644 --- a/src/stores/auth.ts +++ b/src/stores/auth.ts @@ -48,8 +48,8 @@ export const useAuthStore = defineStore('auth', () => { async function googleLogin() { account.createOAuth2Session( OAuthProvider.Google, - 'https://undock.ca', - 'https://undock.ca/#/login' + 'https://oys.undock.ca', + 'https://oys.undock.ca/login' ); currentUser.value = await account.get(); } @@ -57,8 +57,8 @@ export const useAuthStore = defineStore('auth', () => { async function discordLogin() { account.createOAuth2Session( OAuthProvider.Discord, - 'https://undock.ca', - 'https://undock.ca/#/login' + 'https://oys.undock.ca', + 'https://oys.undock.ca/login' ); currentUser.value = await account.get(); }