2017-10-23 16:50:48 -07:00
|
|
|
import Route from '@ember/routing/route';
|
|
|
|
import { get } from '@ember/object';
|
2017-02-13 15:04:11 -08:00
|
|
|
import AuthenticatedRouteMixin from 'ember-simple-auth/mixins/authenticated-route-mixin';
|
2017-09-10 19:31:54 -07:00
|
|
|
import { logout } from 'wherehows-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
|
|
|
|
didTransition(this: Logout) {
|
|
|
|
logout().then(() => get(this, 'session').invalidate());
|
|
|
|
}
|
2017-10-23 16:50:48 -07:00
|
|
|
}
|