mirror of
https://github.com/IT4Change/gradido.git
synced 2025-12-13 07:45:54 +00:00
password can be reseted
This commit is contained in:
parent
cd7f864a49
commit
a0dc2531ff
@ -5,6 +5,7 @@
|
|||||||
"logout":"Abmelden",
|
"logout":"Abmelden",
|
||||||
"login":"Login",
|
"login":"Login",
|
||||||
"signup": "Registrieren",
|
"signup": "Registrieren",
|
||||||
|
"reset": "Passwort zurücksetzen",
|
||||||
"imprint":"Impressum",
|
"imprint":"Impressum",
|
||||||
"privacy_policy":"Datenschutzerklärung",
|
"privacy_policy":"Datenschutzerklärung",
|
||||||
"members_area": "Mitgliedsbereich",
|
"members_area": "Mitgliedsbereich",
|
||||||
@ -110,5 +111,9 @@
|
|||||||
"submit":"Einreichen",
|
"submit":"Einreichen",
|
||||||
"hours_report":"Stundenbericht"
|
"hours_report":"Stundenbericht"
|
||||||
}
|
}
|
||||||
|
},
|
||||||
|
"reset-password": {
|
||||||
|
"title": "Passwort Zurücksetzen",
|
||||||
|
"text": "Jetzt kannst du ein neues Passwort speichern, mit dem du dich zukünfitg in der GRADIDO App anmelden kannst."
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -5,6 +5,7 @@
|
|||||||
"logout":"Logout",
|
"logout":"Logout",
|
||||||
"login":"Login",
|
"login":"Login",
|
||||||
"signup": "Sign up",
|
"signup": "Sign up",
|
||||||
|
"reset": "Reset password",
|
||||||
"imprint":"Legal notice",
|
"imprint":"Legal notice",
|
||||||
"privacy_policy":"Privacy policy",
|
"privacy_policy":"Privacy policy",
|
||||||
"members_area": "Member's area",
|
"members_area": "Member's area",
|
||||||
@ -110,5 +111,9 @@
|
|||||||
"submit":"submit",
|
"submit":"submit",
|
||||||
"hours_report":"Hourly report"
|
"hours_report":"Hourly report"
|
||||||
}
|
}
|
||||||
|
},
|
||||||
|
"reset-password": {
|
||||||
|
"title": "Reset Password",
|
||||||
|
"text": "Now you can save a new password to login to the GRADIDO App in the future."
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -111,7 +111,6 @@ export default {
|
|||||||
methods: {
|
methods: {
|
||||||
async onSubmit() {
|
async onSubmit() {
|
||||||
const result = await loginAPI.login(this.model.email, this.model.password)
|
const result = await loginAPI.login(this.model.email, this.model.password)
|
||||||
console.log(result.data)
|
|
||||||
if (result.success) {
|
if (result.success) {
|
||||||
this.$store.dispatch('login', {
|
this.$store.dispatch('login', {
|
||||||
session_id: result.result.data.session_id,
|
session_id: result.result.data.session_id,
|
||||||
|
|||||||
@ -1,35 +1,30 @@
|
|||||||
import { mount, RouterLinkStub } from '@vue/test-utils'
|
import { mount } from '@vue/test-utils'
|
||||||
import Vuex from 'vuex'
|
import VueRouter from 'vue-router'
|
||||||
import flushPromises from 'flush-promises'
|
import routes from '../../routes/routes'
|
||||||
|
|
||||||
import ResetPassword from './ResetPassword'
|
import ResetPassword from './ResetPassword'
|
||||||
|
|
||||||
const localVue = global.localVue
|
const localVue = global.localVue
|
||||||
|
|
||||||
|
const router = new VueRouter({ routes })
|
||||||
|
|
||||||
describe('ResetPassword', () => {
|
describe('ResetPassword', () => {
|
||||||
let wrapper
|
let wrapper
|
||||||
|
|
||||||
|
let emailVerification = jest.fn()
|
||||||
|
|
||||||
let mocks = {
|
let mocks = {
|
||||||
$i18n: {
|
$i18n: {
|
||||||
locale: 'en',
|
locale: 'en',
|
||||||
},
|
},
|
||||||
$t: jest.fn((t) => t),
|
$t: jest.fn((t) => t),
|
||||||
}
|
loginAPI: {
|
||||||
|
loginViaEmailVerificationCode: emailVerification,
|
||||||
let state = {
|
},
|
||||||
// loginfail: false,
|
|
||||||
}
|
|
||||||
|
|
||||||
let store = new Vuex.Store({
|
|
||||||
state,
|
|
||||||
})
|
|
||||||
|
|
||||||
let stubs = {
|
|
||||||
RouterLink: RouterLinkStub,
|
|
||||||
}
|
}
|
||||||
|
|
||||||
const Wrapper = () => {
|
const Wrapper = () => {
|
||||||
return mount(ResetPassword, { localVue, mocks, store, stubs })
|
return mount(ResetPassword, { localVue, mocks, router })
|
||||||
}
|
}
|
||||||
|
|
||||||
describe('mount', () => {
|
describe('mount', () => {
|
||||||
@ -37,7 +32,20 @@ describe('ResetPassword', () => {
|
|||||||
wrapper = Wrapper()
|
wrapper = Wrapper()
|
||||||
})
|
})
|
||||||
|
|
||||||
it('renders the Reset Password form', () => {
|
/*
|
||||||
|
it('calls the email verification when created', () => {
|
||||||
|
const spy = jest.spyOn(wrapper.vm, 'authenticate')
|
||||||
|
expect(spy).toBeCalled()
|
||||||
|
})
|
||||||
|
*/
|
||||||
|
|
||||||
|
it('does not render the Reset Password form when not authenticated', async () => {
|
||||||
|
expect(wrapper.find('div.resetpwd-form').exists()).toBeFalsy()
|
||||||
|
})
|
||||||
|
|
||||||
|
it('renders the Reset Password form', async () => {
|
||||||
|
wrapper.setData({ authenticated: true })
|
||||||
|
await wrapper.vm.$nextTick()
|
||||||
expect(wrapper.find('div.resetpwd-form').exists()).toBeTruthy()
|
expect(wrapper.find('div.resetpwd-form').exists()).toBeTruthy()
|
||||||
})
|
})
|
||||||
|
|
||||||
|
|||||||
@ -6,11 +6,8 @@
|
|||||||
<div class="header-body text-center mb-7">
|
<div class="header-body text-center mb-7">
|
||||||
<b-row class="justify-content-center">
|
<b-row class="justify-content-center">
|
||||||
<b-col xl="5" lg="6" md="8" class="px-2">
|
<b-col xl="5" lg="6" md="8" class="px-2">
|
||||||
<h1>Reset Password</h1>
|
<h1>{{ $t('reset-password.title') }}</h1>
|
||||||
<div class="pb-4">
|
<div class="pb-4">{{ $t('reset-password.text') }}</div>
|
||||||
Jetzt kannst du ein neues Passwort speichern, mit welchem du dich zukünfitg in der
|
|
||||||
GRADIDO App anmelden kannst.
|
|
||||||
</div>
|
|
||||||
</b-col>
|
</b-col>
|
||||||
</b-row>
|
</b-row>
|
||||||
</div>
|
</div>
|
||||||
@ -78,7 +75,7 @@
|
|||||||
v-if="passwordsFilled && samePasswords && passwordValidation.valid"
|
v-if="passwordsFilled && samePasswords && passwordValidation.valid"
|
||||||
>
|
>
|
||||||
<b-button type="submit" variant="secondary" class="mt-4">
|
<b-button type="submit" variant="secondary" class="mt-4">
|
||||||
{{ $t('signup') }}
|
{{ $t('reset') }}
|
||||||
</b-button>
|
</b-button>
|
||||||
</div>
|
</div>
|
||||||
</b-form>
|
</b-form>
|
||||||
@ -108,18 +105,32 @@ export default {
|
|||||||
submitted: false,
|
submitted: false,
|
||||||
authenticated: false,
|
authenticated: false,
|
||||||
session_id: null,
|
session_id: null,
|
||||||
|
email: null,
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
methods: {
|
methods: {
|
||||||
togglePasswordVisibility() {
|
togglePasswordVisibility() {
|
||||||
this.passwordVisible = !this.passwordVisible
|
this.passwordVisible = !this.passwordVisible
|
||||||
},
|
},
|
||||||
onSubmit() {
|
async onSubmit() {
|
||||||
this.$store.dispatch('createUser', {
|
const result = await loginAPI.changePassword(this.session_id, this.email, this.password)
|
||||||
password: this.model.password,
|
if (result.success) {
|
||||||
})
|
this.password = ''
|
||||||
this.model.password = ''
|
|
||||||
this.$router.push('/thx')
|
this.$router.push('/thx')
|
||||||
|
} else {
|
||||||
|
alert(result.result.message)
|
||||||
|
}
|
||||||
|
},
|
||||||
|
async authenticate() {
|
||||||
|
const optin = this.$route.params.optin
|
||||||
|
const result = await loginAPI.loginViaEmailVerificationCode(optin)
|
||||||
|
if (result.success) {
|
||||||
|
this.authenticated = true
|
||||||
|
this.session_id = result.result.data.session_id
|
||||||
|
this.email = result.result.data.user.email
|
||||||
|
} else {
|
||||||
|
alert(result.result.message)
|
||||||
|
}
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
computed: {
|
computed: {
|
||||||
@ -143,14 +154,7 @@ export default {
|
|||||||
},
|
},
|
||||||
},
|
},
|
||||||
async created() {
|
async created() {
|
||||||
const optin = this.$route.params.optin
|
this.authenticate()
|
||||||
const result = await loginAPI.loginViaEmailVerificationCode(optin)
|
|
||||||
if (result.success) {
|
|
||||||
this.authenticated = true
|
|
||||||
this.session_id = result.result.data.session_id
|
|
||||||
} else {
|
|
||||||
alert(result.result.message)
|
|
||||||
}
|
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
</script>
|
</script>
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user