0
Fork 0
mirror of https://github.com/TryGhost/Ghost.git synced 2025-02-24 23:48:13 -05:00

Fixed "Authorization failed" errors during setup and signin

no issue

- the `custom-views` and `navigation` services would trigger their observers immediately when `this.session.user` changed but that would occur before authentication had fully finished which was resulting in the `this.session.user` access triggering a request with no cookie/an old cookie set and causing a 403 error that interrupted the setup and authentication flows
This commit is contained in:
Kevin Ansfield 2020-02-03 12:27:18 +00:00
parent 2226861e17
commit 7c205c1a55
2 changed files with 14 additions and 2 deletions

View file

@ -115,8 +115,14 @@ export default class CustomViewsService extends Service {
} }
// eslint-disable-next-line ghost/ember/no-observers // eslint-disable-next-line ghost/ember/no-observers
@observes('session.user.accessibility') @observes('session.isAuthenticated', 'session.user.accessibility')
async updateViewList() { async updateViewList() {
// avoid fetching user before authenticated otherwise the 403 can fire
// during authentication and cause errors during setup/signin
if (!this.session.isAuthenticated) {
return;
}
let user = await this.session.user; let user = await this.session.user;
let userSettings = user.get('accessibility'); let userSettings = user.get('accessibility');

View file

@ -22,8 +22,14 @@ export default class NavigationService extends Service {
} }
// eslint-disable-next-line ghost/ember/no-observers // eslint-disable-next-line ghost/ember/no-observers
@observes('session.user.accessibility') @observes('session.isAuthenticated', 'session.user.accessibility')
async updateSettings() { async updateSettings() {
// avoid fetching user before authenticated otherwise the 403 can fire
// during authentication and cause errors during setup/signin
if (!this.session.isAuthenticated) {
return;
}
let user = await this.session.user; let user = await this.session.user;
let userSettings = JSON.parse(user.get('accessibility')) || {}; let userSettings = JSON.parse(user.get('accessibility')) || {};
this.settings = userSettings.navigation || Object.assign({}, DEFAULT_SETTINGS); this.settings = userSettings.navigation || Object.assign({}, DEFAULT_SETTINGS);