mirror of
https://github.com/documize/community.git
synced 2025-07-21 14:19:43 +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
|
// https://documize.com
|
||||||
|
|
||||||
import { computed } from '@ember/object';
|
import { computed } from '@ember/object';
|
||||||
|
|
||||||
import { inject as service } from '@ember/service';
|
import { inject as service } from '@ember/service';
|
||||||
import AjaxService from 'ember-ajax/services/ajax';
|
import AjaxService from 'ember-ajax/services/ajax';
|
||||||
import config from '../config/environment';
|
import config from '../config/environment';
|
||||||
|
@ -36,6 +35,13 @@ export default AjaxService.extend({
|
||||||
try {
|
try {
|
||||||
let user = this.get('session.session.content.authenticated.user');
|
let user = this.get('session.session.content.authenticated.user');
|
||||||
let userUpdate = headers['x-documize-status'];
|
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)) {
|
if (is.not.empty(userUpdate)) {
|
||||||
let latest = JSON.parse(userUpdate);
|
let latest = JSON.parse(userUpdate);
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue