1
0
Fork 0
mirror of https://github.com/documize/community.git synced 2025-07-20 13:49:42 +02:00

direct 401 API calls and redirect to login page

This commit is contained in:
Harvey Kandola 2017-12-08 14:34:21 +00:00
parent 23a6b25b0a
commit 35947ffbfc

View file

@ -10,7 +10,6 @@
// https://documize.com
import { computed } from '@ember/object';
import { inject as service } from '@ember/service';
import AjaxService from 'ember-ajax/services/ajax';
import config from '../config/environment';
@ -36,6 +35,13 @@ export default AjaxService.extend({
try {
let user = this.get('session.session.content.authenticated.user');
let userUpdate = headers['x-documize-status'];
let appVersion = headers['x-documize-version'];
// when unauthorized on local API AJAX calls, redirect to app root
if (status === 401 && is.not.undefined(appVersion)) {
window.location.href = 'auth/login';
}
if (is.not.empty(userUpdate)) {
let latest = JSON.parse(userUpdate);