2017-10-23 16:50:48 -07:00
|
|
|
import Route from '@ember/routing/route';
|
2017-02-13 15:04:11 -08:00
|
|
|
import AuthenticatedRouteMixin from 'ember-simple-auth/mixins/authenticated-route-mixin';
|
2020-08-26 15:44:50 -07:00
|
|
|
import { logout } from 'datahub-web/utils/api/authentication';
|
2017-10-23 16:50:48 -07:00
|
|
|
import Session from 'ember-simple-auth/services/session';
|
2019-08-31 20:51:14 -07:00
|
|
|
import { action } from '@ember/object';
|
|
|
|
import { inject as service } from '@ember/service';
|
2017-02-13 15:04:11 -08:00
|
|
|
|
2017-10-23 16:50:48 -07:00
|
|
|
export default class Logout extends Route.extend(AuthenticatedRouteMixin) {
|
2017-05-22 19:55:07 -07:00
|
|
|
/**
|
2017-10-23 16:50:48 -07:00
|
|
|
* Reference to the application session service, implemented with Ember Simple Auth
|
2018-08-09 08:27:16 -07:00
|
|
|
* @type {Session}
|
2017-05-22 19:55:07 -07:00
|
|
|
*/
|
2018-08-09 08:27:16 -07:00
|
|
|
@service
|
|
|
|
session: Session;
|
2017-02-13 15:04:11 -08:00
|
|
|
|
2018-08-09 08:27:16 -07:00
|
|
|
/**
|
|
|
|
* Post transition, call endpoint then invalidate current session on client on success
|
|
|
|
*/
|
|
|
|
@action
|
2020-08-26 15:44:50 -07:00
|
|
|
async didTransition(this: Logout): Promise<void> {
|
|
|
|
await logout();
|
|
|
|
this.session.invalidate();
|
2018-08-09 08:27:16 -07:00
|
|
|
}
|
2017-10-23 16:50:48 -07:00
|
|
|
}
|