Merge pull request #1179 from gradido/wrong_login_is_not_password_reset

wrong_login_is_not_password_reset
This commit is contained in:
Hannes Heine 2021-12-21 15:43:44 +01:00 committed by GitHub
commit 0aa57dd38b
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 42 additions and 4 deletions

View File

@ -251,6 +251,44 @@ describe('Login', () => {
it('toasts an error message', () => {
expect(toastErrorMock).toBeCalledWith('error.no-account')
})
describe('login fails with "User email not validated"', () => {
beforeEach(async () => {
apolloQueryMock.mockRejectedValue({
message: 'User email not validated',
})
wrapper = Wrapper()
jest.clearAllMocks()
await wrapper.find('input[placeholder="Email"]').setValue('user@example.org')
await wrapper.find('input[placeholder="form.password"]').setValue('1234')
await flushPromises()
await wrapper.find('form').trigger('submit')
await flushPromises()
})
it('redirects to /thx/login', () => {
expect(mockRouterPush).toBeCalledWith('/thx/login')
})
})
describe('login fails with "User has no password set yet"', () => {
beforeEach(async () => {
apolloQueryMock.mockRejectedValue({
message: 'User has no password set yet',
})
wrapper = Wrapper()
jest.clearAllMocks()
await wrapper.find('input[placeholder="Email"]').setValue('user@example.org')
await wrapper.find('input[placeholder="form.password"]').setValue('1234')
await flushPromises()
await wrapper.find('form').trigger('submit')
await flushPromises()
})
it('redirects to /reset/login', () => {
expect(mockRouterPush).toBeCalledWith('/reset/login')
})
})
})
})
})

View File

@ -105,10 +105,10 @@ export default {
loader.hide()
})
.catch((error) => {
if (error.message.includes('No user with this credentials')) {
this.$toasted.global.error(this.$t('error.no-account'))
} else {
// : this.$t('error.no-email-verify')
this.$toasted.global.error(this.$t('error.no-account'))
if (error.message.includes('User email not validated')) {
this.$router.push('/thx/login')
} else if (error.message.includes('User has no password set yet')) {
this.$router.push('/reset/login')
}
loader.hide()