Skip to content
Snippets Groups Projects
Commit 62c30eab authored by m431m's avatar m431m :speech_balloon:
Browse files

Merge branch 'fix/terms-of-use-agreement' into 'develop'

REDMINE_ISSUE-17159

See merge request onegeo-suite/sites/onegeo-suite-site-login-vuejs!44
parents 9a918022 51ead394
No related branches found
No related tags found
No related merge requests found
Pipeline #13726 passed with warnings
......@@ -12,11 +12,8 @@ const state = {
const getters = {
};
export const GET_TERMS_OF_USE = 'GET_TERMS_OF_USE';
export const AGREE_TO_TERMS_OF_USE = 'AGREE_TO_TERMS_OF_USE';
const actions = {
[GET_TERMS_OF_USE]: async ({ commit }) => {
GET_TERMS_OF_USE: async ({ commit }) => {
const response = await client.getTermsOfUse();
if (response.status === 200) {
commit('SET_TERMS', response.data);
......@@ -32,21 +29,21 @@ const actions = {
});
}
},
[AGREE_TO_TERMS_OF_USE]: async ({ commit }, data) => {
const response = await client.postTermsOfUseAgreement(data);
AGREE_TO_TERMS_OF_USE: async ({ commit }, { has_agreed, authorizedRedirections}) => {
const response = await client.postTermsOfUseAgreement({ has_agreed: has_agreed });
if (response.status === 200) {
commit('SET_SUCCESS', {
response: response,
message: ''
});
if (
this.$config.authorizedRedirections.some(reg => {
authorizedRedirections.some(reg => {
return reg.test(decodeURIComponent(router.currentRoute.query.next))
})
) {
window.location.href = router.currentRoute.query.next;
} else {
this.$router.push({ name: 'NotFound' });
router.push({ name: 'NotFound' });
}
}
if (response.status === 404) {
......@@ -58,20 +55,16 @@ const actions = {
}
};
export const SET_TERMS = 'SET_TERMS';
export const SET_ERROR = 'SET_ERROR';
export const SET_SUCCESS = 'SET_SUCCESS';
const mutations = {
[SET_TERMS]: (state, payload) => {
SET_TERMS: (state, payload) => {
state.terms = payload;
},
[SET_ERROR]: (state, payload) => {
SET_ERROR: (state, payload) => {
state.success = null;
ErrorService.onError(payload.response);
state.error = payload.message;
},
[SET_SUCCESS]: (state, payload) => {
SET_SUCCESS: (state, payload) => {
state.error = null;
state.success = payload.message;
},
......
......@@ -102,7 +102,8 @@ export default {
acceptTermsOfUse() {
this.AGREE_TO_TERMS_OF_USE({
has_agreed: true
has_agreed: true,
authorizedRedirections: this.$config.authorizedRedirections
});
},
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment