Skip to content
This repository has been archived by the owner on May 13, 2024. It is now read-only.

Commit

Permalink
chore(deps): upgrade ember-simple-auth-oidc
Browse files Browse the repository at this point in the history
  • Loading branch information
derrabauke committed Dec 8, 2022
1 parent 2abd269 commit 5290ceb
Show file tree
Hide file tree
Showing 9 changed files with 323 additions and 198 deletions.
16 changes: 11 additions & 5 deletions app/adapters/application.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@
* @submodule timed-adapters
* @public
*/
import JSONAPIAdapter from "@ember-data/adapter/json-api";
import OIDCAdapterMixin from "ember-simple-auth-oidc/mixins/oidc-adapter-mixin";
import { inject as service } from "@ember/service";
import OIDCJSONAPIAdapter from "ember-simple-auth-oidc/adapters/oidc-json-api-adapter";

/**
* The application adapter
Expand All @@ -14,6 +14,12 @@ import OIDCAdapterMixin from "ember-simple-auth-oidc/mixins/oidc-adapter-mixin";
* @uses EmberSimpleAuthOIDC.OIDCAdapterMixin
* @public
*/
export default JSONAPIAdapter.extend(OIDCAdapterMixin, {
namespace: "api/v1",
});
export default class ApplicationAdapter extends OIDCJSONAPIAdapter {
@service session;

namespace = "api/v1";

get headers() {
return { ...this.session.headers };
}
}
27 changes: 5 additions & 22 deletions app/application/route.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@
*/
import Route from "@ember/routing/route";
import { inject as service } from "@ember/service";
import OIDCApplicationRouteMixin from "ember-simple-auth-oidc/mixins/oidc-application-route-mixin";

/**
* The application route
Expand All @@ -15,26 +14,10 @@ import OIDCApplicationRouteMixin from "ember-simple-auth-oidc/mixins/oidc-applic
* @uses EmberSimpleAuth.ApplicationRouteMixin
* @public
*/
export default Route.extend(OIDCApplicationRouteMixin, {
autostartTour: service(),
export default class ApplicationRoute extends Route {
@service session;

/**
* The actions for the application route
*
* @property {Object} actions
* @public
*/
actions: {
/**
* Invalidate the session
*
* @method invalidateSession
* @public
*/
invalidateSession() {
this.set("autostartTour.done", []);

this.session.invalidate();
}
async beforeModel() {
await this.session.setup();
}
});
}
5 changes: 2 additions & 3 deletions app/login/route.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,7 @@
* @submodule timed-routes
* @public
*/
import Route from "@ember/routing/route";
import OIDCAuthenticationRouteMixin from "ember-simple-auth-oidc/mixins/oidc-authentication-route-mixin";
import OIDCAuthenticationRoute from "ember-simple-auth-oidc/routes/oidc-authentication";

/**
* The login route
Expand All @@ -13,4 +12,4 @@ import OIDCAuthenticationRouteMixin from "ember-simple-auth-oidc/mixins/oidc-aut
* @extends Ember.Route
* @public
*/
export default Route.extend(OIDCAuthenticationRouteMixin, {});
export default class LoginRoute extends OIDCAuthenticationRoute {}
93 changes: 91 additions & 2 deletions app/protected/controller.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,101 @@
* @public
*/
import Controller from "@ember/controller";

import { action } from "@ember/object";
import { inject as service } from "@ember/service";
import { tracked } from "@glimmer/tracking";
/**
* The protected controller
*
* @class ProtectedController
* @extends Ember.Controller
* @public
*/
export default Controller.extend({});
export default class ProtectedController extends Controller {
@service notify;
@service router;
@service session;
@service("autostart-tour") autostartTour;

@tracked visible;
@tracked loading;

/**
* Invalidate the session
*
* @method invalidateSession
* @public
*/
@action
invalidateSession() {
this.autostartTour.done = [];

this.session.invalidate();
this.router.transitionTo("login");
}

/**
* Close the current tour
*
* @method _closeCurrentTour
* @private
*/
_closeCurrentTour() {
const currentRoute = this.router.currentRouteName.replace(/\.index$/, "");

if (this.autostartTour.tours.includes(currentRoute)) {
this.controllerFor(currentRoute).get("tour").close();
}
}

/**
* Never start the tour, set the tour done property on the current user
*
* @method neverTour
* @public
*/
@action
async neverTour() {
try {
const user = this.model;

user.tourDone = true;

await user.save();

this._closeCurrentTour();
this.visible = false;
} catch (error) {
this.notify.error("Error while saving the user");
}
}

/**
* Skip the tour for now
*
* @method laterTour
* @public
*/
@action
laterTour() {
this._closeCurrentTour();
this.autostartTour.done = this.autostartTour.tours;
this.visible = false;

this.router.transitionTo("index.activities");
}

/**
* Start the tour
*
* @method startTour
* @public
*/
@action
startTour() {
this.autostartTour.done = [];
this.visible = false;

this.router.transitionTo("index.activities");
}
}
Loading

0 comments on commit 5290ceb

Please sign in to comment.