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:
parent
23a6b25b0a
commit
35947ffbfc
1 changed files with 7 additions and 1 deletions
|
@ -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);
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue