-
Notifications
You must be signed in to change notification settings - Fork 4
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Initial implementation of the passwordreset page #27
Merged
Merged
Changes from all commits
Commits
Show all changes
3 commits
Select commit
Hold shift + click to select a range
bfea398
Initial implementation of the passwordreset page, additionally index.…
noelvandevrie 69fbd8e
Changed password2 to passwordConfirm and removed console.logs
noelvandevrie e222239
Added the password field validations for strength, length and matchin…
noelvandevrie File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,2 +1,2 @@ | ||
VITE_APP_API_BASE=https://sudosos.test.gewis.nl/api/v1 | ||
VITE_APP_GEWIS_TOKEN=sudosos | ||
VITE_APP_GEWIS_TOKEN=sudosos-dev |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -54,7 +54,7 @@ | |
*::before, | ||
*::after { | ||
box-sizing: border-box; | ||
margin: 0; | ||
/*margin: 0;*/ | ||
font-weight: normal; | ||
} | ||
|
||
|
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,234 @@ | ||
<template> | ||
<div> | ||
<main> | ||
<img id="reset-image" src="../assets/img/bier.png" alt="logo"/> | ||
<h1>{{ $t('login.Reset') }}</h1> | ||
<Form v-if="passwordResetMode === 0" class="login-form" @submit="resetPasswordRequest"> | ||
<span class="p-float-label with-error"> | ||
<InputText v-bind="email" id="email" size="large" name="email" :class="{'p-invalid': emailForm.errors.value.email}"/> | ||
<label :class="{'contains-text': email.modelValue }" for="email">{{ $t('login.Enter email') }}</label> | ||
</span> | ||
<small v-if="emailForm.errors.value.email" class="p-error"><i class="pi pi-exclamation-circle"/>{{ emailForm.errors.value.email }}</small> | ||
<Button type="submit" id="reset-button" severity="danger">{{ $t('login.Reset') }}</Button> | ||
<div class="backtologin" @click="backToLogin">{{ $t('login.Back to login') }}</div> | ||
</Form> | ||
<div v-else-if="passwordResetMode === 1" class="login-form"> | ||
<div class="sent-email">{{ $t('login.Email sent') }}</div> | ||
<div class="backtologin" @click="backToLogin">{{ $t('login.Back to login') }}</div> | ||
</div> | ||
<Form v-else class="login-form" @submit="setNewPassword"> | ||
<span class="p-float-label with-error"> | ||
<InputText v-bind="password" id="password" size="large" name="password" type="password" :class="{'p-invalid': passwordForm.errors.value.password}"/> | ||
<label :class="{'contains-text': password.modelValue }" for="password">{{ $t('login.New password') }}</label> | ||
</span> | ||
<small v-if="passwordForm.errors.value.password" class="p-error"><i class="pi pi-exclamation-circle"/>{{ passwordForm.errors.value.password }}</small> | ||
<span class="p-float-label with-error"> | ||
<InputText v-bind="passwordConfirm" id="passwordConfirm" size="large" name="passwordConfirm" type="password" :class="{'p-invalid': passwordForm.errors.value.passwordConfirm}"/> | ||
<label :class="{'contains-text': passwordConfirm.modelValue }" for="passwordConfirm">{{ $t('login.Confirm password') }}</label> | ||
</span> | ||
<small v-if="passwordForm.errors.value.passwordConfirm" class="p-error"><i class="pi pi-exclamation-circle"/>{{ passwordForm.errors.value.passwordConfirm }}</small> | ||
<Button type="submit" id="reset-button" severity="danger">{{ $t('login.Reset') }}</Button> | ||
<div class="backtologin" @click="backToLogin">{{ $t('login.Back to login') }}</div> | ||
</Form> | ||
</main> | ||
<CopyrightBanner/> | ||
</div> | ||
</template> | ||
|
||
<script setup lang="ts"> | ||
import { Form } from 'vee-validate'; | ||
import CopyrightBanner from "@/components/CopyrightBanner.vue"; | ||
import apiService from "@/services/ApiService"; | ||
import router from "@/router"; | ||
import { useForm } from "vee-validate"; | ||
import InputText from "primevue/inputtext"; | ||
import { onBeforeMount, ref } from "vue"; | ||
import { useRoute } from "vue-router"; | ||
import * as yup from "yup"; | ||
import { toTypedSchema } from "@vee-validate/yup"; | ||
|
||
const emailSchema = toTypedSchema( | ||
yup.object({ | ||
email: yup | ||
.string() | ||
.email() | ||
.required(), | ||
}) | ||
); | ||
|
||
const atLeastOneUppercase = /^(?=.*[A-Z])/; | ||
const atLeastOneLowercase = /^(?=.*[a-z])/; | ||
const atLeastOneDigit = /^(?=.*\d)/; | ||
const atLeastOneSpecialChar = /^(?=.*[@$!%*?&])/; | ||
const allowedCharacters = /^[A-Za-z\d@$!%*?& ]{8,}$/; | ||
|
||
const passwordSchema = toTypedSchema( | ||
yup.object({ | ||
password: yup | ||
.string() | ||
.required("This is a required field") | ||
.matches(atLeastOneUppercase, 'At least one uppercase letter is required') | ||
.matches(atLeastOneLowercase, 'At least one lowercase letter is required') | ||
.matches(atLeastOneDigit, 'At least one digit is required') | ||
.matches(atLeastOneSpecialChar, 'At least one special character is required') | ||
.matches(allowedCharacters, 'Password must be at least 8 characters long and only contain allowed characters'), | ||
passwordConfirm: yup | ||
.string() | ||
.required("This is a required field") | ||
.oneOf([yup.ref("password")], "Passwords do not match"), | ||
}) | ||
); | ||
|
||
const emailForm = useForm({ | ||
validationSchema: emailSchema, | ||
}); | ||
|
||
const passwordForm = useForm({ | ||
validationSchema: passwordSchema, | ||
}); | ||
|
||
const passwordResetMode = ref(0); | ||
const email = emailForm.defineComponentBinds('email'); | ||
const password = passwordForm.defineComponentBinds('password'); | ||
const passwordConfirm = passwordForm.defineComponentBinds('passwordConfirm'); | ||
|
||
const route = useRoute(); | ||
|
||
onBeforeMount(async () => { | ||
if (route.query.token !== undefined && route.query.email !== undefined) { | ||
passwordResetMode.value = 2; | ||
} | ||
}); | ||
|
||
const resetPasswordRequest = emailForm.handleSubmit(async () => { | ||
await apiService.authenticate.resetLocal({ accountMail: email.value.modelValue }) | ||
.then(() => { | ||
passwordResetMode.value = 1; | ||
}); | ||
}); | ||
|
||
const setNewPassword = passwordForm.handleSubmit(async () => { | ||
await apiService.authenticate.resetLocalWithToken({ | ||
accountMail: route.query.email as string, | ||
token: route.query.token as string, | ||
password: password.value.modelValue as string, | ||
}).then(); | ||
}); | ||
|
||
const backToLogin = () => { | ||
router.push({ name: 'login' }); | ||
}; | ||
|
||
</script> | ||
|
||
<style scoped lang="scss"> | ||
//TODO Cleanup and fix, related to issue #14 and #25 | ||
form { | ||
display: flex; | ||
flex-direction: column; | ||
} | ||
|
||
h1 { | ||
color: black; | ||
max-width: 350px; | ||
width: 100%; | ||
margin: 0 auto; | ||
font-size: 2.5rem; | ||
margin-bottom: 1.5rem; | ||
} | ||
|
||
#reset-image { | ||
max-height: 150px; | ||
|
||
display: block; | ||
margin: 0 auto; | ||
} | ||
|
||
main { | ||
display: flex; | ||
flex-direction: column; | ||
text-align: center; | ||
max-width: 350px; | ||
margin: 4rem auto; | ||
} | ||
|
||
.p-button { | ||
margin: 1rem auto; | ||
max-width: 350px; | ||
width: 100%; | ||
max-height: 38px; | ||
display: flex; | ||
align-items: center; | ||
justify-content: center; | ||
} | ||
|
||
#gewis-branding { | ||
max-height: 24px; | ||
margin-right: 1rem; | ||
} | ||
|
||
.p-error { | ||
display: block; | ||
font-size: 12px; | ||
text-align: left; | ||
line-height:18px; | ||
} | ||
|
||
.p-error > i { | ||
font-size:12px; | ||
margin-right: 3.6px; | ||
line-height:12px; | ||
} | ||
|
||
#email { | ||
width: 100%; | ||
padding-top: 18px; | ||
padding-left: 12px; | ||
padding-bottom: 0px; | ||
height: 60px; | ||
} | ||
|
||
#password { | ||
width: 100%; | ||
padding-top: 18px; | ||
padding-left: 12px; | ||
padding-bottom: 0px; | ||
height: 60px; | ||
} | ||
|
||
#passwordConfirm { | ||
width: 100%; | ||
padding-top: 18px; | ||
padding-left: 12px; | ||
padding-bottom: 0px; | ||
height: 60px; | ||
} | ||
|
||
.p-float-label label { | ||
top: 30%; | ||
margin-top: 0; | ||
left: 12px; | ||
} | ||
|
||
.contains-text, .p-float-label input:focus ~ label, .p-float-label label ~ input:focus { | ||
margin-top: 0; | ||
top: 8px!important; | ||
} | ||
|
||
.p-invalid { | ||
background-color: #fef0f0; | ||
} | ||
|
||
.p-inputtext { | ||
margin-bottom: 0.5rem; | ||
} | ||
|
||
.sent-email { | ||
color: black; | ||
} | ||
|
||
.backtologin { | ||
color: black; | ||
text-decoration-line: underline; | ||
} | ||
</style> |
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There are some console logs left in there.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
These are now gone in the latest commit to this branch.