Skip to content

Commit

Permalink
refactor: don't call authenticate on every visit to check session (#1262
Browse files Browse the repository at this point in the history
)
  • Loading branch information
jaredgalanis authored Apr 25, 2024
1 parent b39df3d commit 59eaf02
Showing 1 changed file with 1 addition and 10 deletions.
11 changes: 1 addition & 10 deletions app/routes/check-session-route.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,22 +12,13 @@ export default class CheckSessionRouteRoute extends Route {
errorHandler;

async beforeModel() {
// TODO: it is not ideal to have env checks in app code so it would be
// great to find another way to authenticate users in the development env
// with mirage at play. Note, we could direct people to go to the auth-callback
// route which would achieve a similar effect.
if (ENV.environment === 'development' && ENV['ember-cli-mirage']) {
if (!this.session.isAuthenticated) {
await this.session.authenticate('authenticator:http-only');
}

if (!this.currentUser.user) {
await this._loadCurrentUser();
}

if (!this.session.isAuthenticated) {
this.session.set('attemptedTransition', transition);
await this.session.invalidate();
}
}

_loadCurrentUser() {
Expand Down

0 comments on commit 59eaf02

Please sign in to comment.