mirror of
https://github.com/IT4Change/gradido.git
synced 2025-12-13 07:45:54 +00:00
pre merge moritz
This commit is contained in:
parent
00fc4056b1
commit
e61ca1ffa4
@ -3,6 +3,7 @@
|
||||
<b-row class="mb-2">
|
||||
<b-col>
|
||||
<input-password
|
||||
id="inputPassword"
|
||||
:rules="{
|
||||
required: true,
|
||||
containsLowercaseCharacter: true,
|
||||
@ -10,11 +11,11 @@
|
||||
containsNumericCharacter: true,
|
||||
atLeastEightCharactera: true,
|
||||
}"
|
||||
:label="$t('form.password_new')"
|
||||
:label="register ? $t('form.password') : $t('form.password_new')"
|
||||
:showAllErrors="true"
|
||||
:immediate="true"
|
||||
:name="$t('form.password_new')"
|
||||
:placeholder="$t('form.password_new')"
|
||||
:name="register ? $t('form.password') : $t('form.password_new')"
|
||||
:placeholder="register ? $t('form.password') : $t('form.password_new')"
|
||||
v-model="password"
|
||||
></input-password>
|
||||
</b-col>
|
||||
@ -22,9 +23,10 @@
|
||||
<b-row class="mb-2">
|
||||
<b-col>
|
||||
<input-password
|
||||
id="inputPasswordRepeat"
|
||||
:rules="{ samePassword: value.password }"
|
||||
:label="$t('form.password_new_repeat')"
|
||||
:placeholder="$t('form.password_new_repeat')"
|
||||
:label="register ? $t('form.passwordRepeat') : $t('form.password_new_repeat')"
|
||||
:placeholder="register ? $t('form.passwordRepeat') : $t('form.password_new_repeat')"
|
||||
v-model="passwordRepeat"
|
||||
></input-password>
|
||||
</b-col>
|
||||
@ -44,6 +46,10 @@ export default {
|
||||
type: Object,
|
||||
required: true,
|
||||
},
|
||||
register: {
|
||||
type: Boolean,
|
||||
required: false,
|
||||
}
|
||||
},
|
||||
data() {
|
||||
return {
|
||||
|
||||
@ -61,15 +61,15 @@ describe('Register', () => {
|
||||
})
|
||||
|
||||
it('has email input fields', () => {
|
||||
expect(wrapper.find('#registerEmail').exists()).toBeTruthy()
|
||||
expect(wrapper.find('#Email-input-field').exists()).toBeTruthy()
|
||||
})
|
||||
|
||||
it('has password input fields', () => {
|
||||
expect(wrapper.find('#registerPassword').exists()).toBeTruthy()
|
||||
expect(wrapper.find('#inputPassword').exists()).toBeTruthy()
|
||||
})
|
||||
|
||||
it('has password repeat input fields', () => {
|
||||
expect(wrapper.find('#registerPasswordRepeat').exists()).toBeTruthy()
|
||||
expect(wrapper.find('#inputPasswordRepeat').exists()).toBeTruthy()
|
||||
})
|
||||
|
||||
it('has 1 checkbox input fields', () => {
|
||||
@ -80,11 +80,10 @@ describe('Register', () => {
|
||||
expect(wrapper.find('button[type="submit"]').exists()).toBe(false)
|
||||
})
|
||||
|
||||
|
||||
it('shows a warning when no valid Email is entered', async () => {
|
||||
wrapper.find('#registerEmail').setValue('no_valid@Email')
|
||||
wrapper.find('#Email-input-field').setValue('no_valid@Email')
|
||||
await flushPromises()
|
||||
await expect(wrapper.find('#registerEmailLiveFeedback').text()).toEqual(
|
||||
await expect(wrapper.find('#Email-input-field b-form-invalid-feedback').text()).toEqual(
|
||||
'validations.messages.email',
|
||||
)
|
||||
})
|
||||
|
||||
@ -76,27 +76,14 @@
|
||||
</b-form-group>
|
||||
</validation-provider>
|
||||
|
||||
<input-email v-model="form.email" id="registerEmail"></input-email>
|
||||
<input-email v-model="form.email" ></input-email>
|
||||
|
||||
<hr />
|
||||
<!--<input-password v-model="form.password" id="registerPassword"></input-password>-->
|
||||
<input-password-confirmation v-model="form.passwordRepeat" ></input-password-confirmation>
|
||||
<input-password-confirmation
|
||||
v-model="form.password"
|
||||
:register="register"
|
||||
></input-password-confirmation>
|
||||
|
||||
<transition name="hint" appear>
|
||||
<div v-if="passwordValidation.errors.length > 0 && !submitted" class="hints">
|
||||
<ul>
|
||||
<li v-for="error in passwordValidation.errors" :key="error">
|
||||
<small>{{ error }}</small>
|
||||
</li>
|
||||
</ul>
|
||||
</div>
|
||||
<div class="matches" v-else-if="!samePasswords">
|
||||
<p>
|
||||
{{ $t('site.signup.dont_match') }}
|
||||
<i class="ni ni-active-40" color="danger"></i>
|
||||
</p>
|
||||
</div>
|
||||
</transition>
|
||||
<b-row class="my-4">
|
||||
<b-col cols="12">
|
||||
<b-form-checkbox
|
||||
@ -127,7 +114,6 @@
|
||||
v-if="
|
||||
passwordsFilled &&
|
||||
samePasswords &&
|
||||
passwordValidation.valid &&
|
||||
namesFilled &&
|
||||
emailFilled &&
|
||||
form.agree
|
||||
@ -153,11 +139,10 @@
|
||||
<script>
|
||||
import loginAPI from '../../apis/loginAPI'
|
||||
import InputEmail from '../../components/Inputs/InputEmail.vue'
|
||||
import InputPassword from '../../components/Inputs/InputPassword.vue'
|
||||
import InputPasswordConfirmation from '../../components/Inputs/InputPasswordConfirmation.vue'
|
||||
|
||||
export default {
|
||||
components: { InputPassword, InputPasswordConfirmation, InputEmail },
|
||||
components: { InputPasswordConfirmation, InputEmail },
|
||||
name: 'register',
|
||||
data() {
|
||||
return {
|
||||
@ -166,15 +151,15 @@ export default {
|
||||
lastname: '',
|
||||
email: '',
|
||||
agree: false,
|
||||
password: '',
|
||||
passwordRepeat: '',
|
||||
password: {
|
||||
password: '',
|
||||
passwordRepeat: '',
|
||||
},
|
||||
},
|
||||
|
||||
passwordVisible: false,
|
||||
passwordVisibleRepeat: false,
|
||||
submitted: false,
|
||||
showError: false,
|
||||
messageError: '',
|
||||
register: true,
|
||||
}
|
||||
},
|
||||
methods: {
|
||||
@ -186,25 +171,22 @@ export default {
|
||||
firstname: '',
|
||||
lastname: '',
|
||||
email: '',
|
||||
password: '',
|
||||
passwordRepeat: '',
|
||||
password: {
|
||||
password: '',
|
||||
passwordRepeat: '',
|
||||
},
|
||||
}
|
||||
this.$nextTick(() => {
|
||||
this.$refs.observer.reset()
|
||||
})
|
||||
},
|
||||
togglePasswordVisibility() {
|
||||
this.passwordVisible = !this.passwordVisible
|
||||
},
|
||||
togglePasswordRepeatVisibility() {
|
||||
this.passwordVisibleRepeat = !this.passwordVisibleRepeat
|
||||
},
|
||||
|
||||
async onSubmit() {
|
||||
const result = await loginAPI.create(
|
||||
this.form.email,
|
||||
this.form.firstname,
|
||||
this.form.lastname,
|
||||
this.form.password,
|
||||
this.form.password.password,
|
||||
)
|
||||
if (result.success) {
|
||||
this.$store.dispatch('login', {
|
||||
@ -214,8 +196,8 @@ export default {
|
||||
this.form.email = ''
|
||||
this.form.firstname = ''
|
||||
this.form.lastname = ''
|
||||
this.password = ''
|
||||
this.passwordVisibleRepeat = ''
|
||||
this.form.password.password = ''
|
||||
|
||||
this.$router.push('/thx/register')
|
||||
} else {
|
||||
this.showError = true
|
||||
@ -228,15 +210,15 @@ export default {
|
||||
this.form.email = ''
|
||||
this.form.firstname = ''
|
||||
this.form.lastname = ''
|
||||
this.form.password = ''
|
||||
this.form.password.password = ''
|
||||
},
|
||||
},
|
||||
computed: {
|
||||
samePasswords() {
|
||||
return this.form.password === this.form.passwordRepeat
|
||||
return this.form.password.password === this.form.password.passwordRepeat
|
||||
},
|
||||
passwordsFilled() {
|
||||
return this.form.password !== '' && this.form.passwordRepeat !== ''
|
||||
return this.form.password.password !== '' && this.form.password.passwordRepeat !== ''
|
||||
},
|
||||
namesFilled() {
|
||||
return (
|
||||
@ -249,26 +231,6 @@ export default {
|
||||
emailFilled() {
|
||||
return this.form.email !== ''
|
||||
},
|
||||
rules() {
|
||||
return [
|
||||
{ message: this.$t('site.signup.lowercase'), regex: /[a-z]+/ },
|
||||
{ message: this.$t('site.signup.uppercase'), regex: /[A-Z]+/ },
|
||||
{ message: this.$t('site.signup.minimum'), regex: /.{8,}/ },
|
||||
{ message: this.$t('site.signup.one_number'), regex: /[0-9]+/ },
|
||||
]
|
||||
},
|
||||
passwordValidation() {
|
||||
const errors = []
|
||||
for (const condition of this.rules) {
|
||||
if (!condition.regex.test(this.form.password)) {
|
||||
errors.push(condition.message)
|
||||
}
|
||||
}
|
||||
if (errors.length === 0) {
|
||||
return { valid: true, errors }
|
||||
}
|
||||
return { valid: false, errors }
|
||||
},
|
||||
},
|
||||
}
|
||||
</script>
|
||||
|
||||
@ -26,7 +26,7 @@
|
||||
<b-card-body class="p-4">
|
||||
<validation-observer ref="observer" v-slot="{ handleSubmit }">
|
||||
<b-form role="form" @submit.prevent="handleSubmit(onSubmit)">
|
||||
<input-password-confirmation v-model="form" />
|
||||
<input-password-confirmation v-model="form" :register="register"/>
|
||||
<div class="text-center">
|
||||
<b-button type="submit" variant="primary" class="mt-4">
|
||||
{{ $t('reset') }}
|
||||
@ -65,6 +65,7 @@ export default {
|
||||
sessionId: null,
|
||||
email: null,
|
||||
pending: true,
|
||||
register: false,
|
||||
}
|
||||
},
|
||||
methods: {
|
||||
|
||||
@ -28,7 +28,7 @@
|
||||
></input-password>
|
||||
</b-col>
|
||||
</b-row>
|
||||
<input-password-confirmation v-model="form.newPassword" />
|
||||
<input-password-confirmation v-model="form.newPassword" :register="register"/>
|
||||
<b-row class="text-right">
|
||||
<b-col>
|
||||
<div class="text-right">
|
||||
@ -66,6 +66,7 @@ export default {
|
||||
passwordRepeat: '',
|
||||
},
|
||||
},
|
||||
register: false,
|
||||
}
|
||||
},
|
||||
methods: {
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user