diff --git a/configs/login_server/grd_login.properties b/configs/login_server/grd_login.properties index 47dc81229..f14568a16 100644 --- a/configs/login_server/grd_login.properties +++ b/configs/login_server/grd_login.properties @@ -22,7 +22,7 @@ loginServer.db.user = root loginServer.db.password = loginServer.db.port = 3306 -frontend.checkEmailPath = http://localhost/account/checkEmail +frontend.checkEmailPath = http://localhost/reset email.disable = true diff --git a/frontend/src/apis/loginAPI.js b/frontend/src/apis/loginAPI.js index 91020ddbb..a31a4062e 100644 --- a/frontend/src/apis/loginAPI.js +++ b/frontend/src/apis/loginAPI.js @@ -64,7 +64,6 @@ const loginAPI = { return apiPost(CONFIG.LOGIN_API_URL + 'createUser', payload) }, sendEmail: async (email, email_text = 7, email_verification_code_type = 'resetPassword') => { - //console.log('api email', email) const payload = { email, email_text, @@ -72,6 +71,21 @@ const loginAPI = { } return apiPost(CONFIG.LOGIN_API_URL + 'sendEmail', payload) }, + loginViaEmailVerificationCode: async (optin) => { + return apiGet( + CONFIG.LOGIN_API_URL + 'loginViaEmailVerificationCode?emailVerificationCode=' + optin, + ) + }, + changePassword: async (session_id, email, password) => { + const payload = { + session_id, + email, + update: { + 'User.password': password, + }, + } + return apiPost(CONFIG.LOGIN_API_URL + 'updateUserInfos', payload) + }, } export default loginAPI diff --git a/frontend/src/locales/de.json b/frontend/src/locales/de.json index 0e60a3094..e3868124c 100644 --- a/frontend/src/locales/de.json +++ b/frontend/src/locales/de.json @@ -5,6 +5,7 @@ "logout":"Abmelden", "login":"Login", "signup": "Registrieren", + "reset": "Passwort zurücksetzen", "imprint":"Impressum", "privacy_policy":"Datenschutzerklärung", "members_area": "Mitgliedsbereich", @@ -110,5 +111,9 @@ "submit":"Einreichen", "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." } } diff --git a/frontend/src/locales/en.json b/frontend/src/locales/en.json index 1dc703f14..521f68f0d 100644 --- a/frontend/src/locales/en.json +++ b/frontend/src/locales/en.json @@ -5,6 +5,7 @@ "logout":"Logout", "login":"Login", "signup": "Sign up", + "reset": "Reset password", "imprint":"Legal notice", "privacy_policy":"Privacy policy", "members_area": "Member's area", @@ -110,5 +111,9 @@ "submit":"submit", "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." } } diff --git a/frontend/src/routes/routes.js b/frontend/src/routes/routes.js index adae0be07..bfaff9de6 100755 --- a/frontend/src/routes/routes.js +++ b/frontend/src/routes/routes.js @@ -59,7 +59,7 @@ const routes = [ component: () => import('../views/Pages/ForgotPassword.vue'), }, { - path: '/reset', + path: '/reset/:optin', component: () => import('../views/Pages/ResetPassword.vue'), }, { path: '*', component: NotFound }, diff --git a/frontend/src/views/Pages/Login.vue b/frontend/src/views/Pages/Login.vue index a9c5f0f09..f7c002d2a 100755 --- a/frontend/src/views/Pages/Login.vue +++ b/frontend/src/views/Pages/Login.vue @@ -53,7 +53,7 @@ - +
- - reset - diff --git a/frontend/src/views/Pages/ResetPassword.spec.js b/frontend/src/views/Pages/ResetPassword.spec.js index ebff0fc20..7e87bb90f 100644 --- a/frontend/src/views/Pages/ResetPassword.spec.js +++ b/frontend/src/views/Pages/ResetPassword.spec.js @@ -1,35 +1,30 @@ -import { mount, RouterLinkStub } from '@vue/test-utils' -import Vuex from 'vuex' -import flushPromises from 'flush-promises' +import { mount } from '@vue/test-utils' +import VueRouter from 'vue-router' +import routes from '../../routes/routes' import ResetPassword from './ResetPassword' const localVue = global.localVue +const router = new VueRouter({ routes }) + describe('ResetPassword', () => { let wrapper + let emailVerification = jest.fn() + let mocks = { $i18n: { locale: 'en', }, $t: jest.fn((t) => t), - } - - let state = { - // loginfail: false, - } - - let store = new Vuex.Store({ - state, - }) - - let stubs = { - RouterLink: RouterLinkStub, + loginAPI: { + loginViaEmailVerificationCode: emailVerification, + }, } const Wrapper = () => { - return mount(ResetPassword, { localVue, mocks, store, stubs }) + return mount(ResetPassword, { localVue, mocks, router }) } describe('mount', () => { @@ -37,7 +32,20 @@ describe('ResetPassword', () => { 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() }) diff --git a/frontend/src/views/Pages/ResetPassword.vue b/frontend/src/views/Pages/ResetPassword.vue index 145fba404..c1e74855f 100644 --- a/frontend/src/views/Pages/ResetPassword.vue +++ b/frontend/src/views/Pages/ResetPassword.vue @@ -1,16 +1,13 @@