Sfoglia il codice sorgente

Merge branch 'master' of git.bubblev.org:bubblev/bubble-web into sfedoriv/Add_auto_login_vue_template_and_route

pull/5/head
Jonathan Cobb 4 anni fa
parent
commit
463dda88dc
2 ha cambiato i file con 14 aggiunte e 4 eliminazioni
  1. +13
    -3
      src/_helpers/util.js
  2. +1
    -1
      src/_store/account.module.js

+ 13
- 3
src/_helpers/util.js Vedi File

@@ -132,9 +132,14 @@ export const util = {
return response.text().then(text => {
const data = text && JSON.parse(text);
if (!response.ok) {
if (response.status === 404) {
if (response.status === 401) {
console.log('handleCrudResponse: unauthenticated request: ' + JSON.stringify(data));
util.logout();
vue.$route.replace('/login');
} else if (response.status === 404) {
// todo: show nicer error message
console.log('handleCrudResponse: received 404: ' + JSON.stringify(data));
console.log('handleCrudResponse: received 404: ' + JSON.stringify(data));

} else if (response.status === 422) {
// console.log('handleCrudResponseA: errors='+JSON.stringify(errors));
@@ -158,7 +163,12 @@ export const util = {
let errData = JSON.parse('' + text) || text;
if (Array.isArray(errData)) errData = errData[0];

if (response.status === 404) {
if (response.status === 401) {
console.log('handlePlaintextResponse: unauthenticated request: ' + JSON.stringify(data));
util.logout();
vue.$route.replace('/login');
} else if (response.status === 404) {
// todo: show nicer error message
console.log('handlePlaintextResponse: received 404: ' + (errData.resource || errData));



+ 1
- 1
src/_store/account.module.js Vedi File

@@ -45,7 +45,7 @@ const actions = {
user => commit('checkSessionSuccess', user),
error => {
commit('checkSessionFailure', error);
if (error === 'Not Found' || error === 'Forbidden') {
if (error ==== 'Unauthorized' || error === 'Not Found' || error === 'Forbidden' ) {
userService.logout(messages, errors).then(
ok => router.replace('/login'),
error => router.replace('/login')


Caricamento…
Annulla
Salva