2019-08-31 20:51:14 -07:00

25 lines
821 B
TypeScript

import Route from '@ember/routing/route';
import { get } from '@ember/object';
import AuthenticatedRouteMixin from 'ember-simple-auth/mixins/authenticated-route-mixin';
import { logout } from 'wherehows-web/utils/api/authentication';
import Session from 'ember-simple-auth/services/session';
import { action } from '@ember/object';
import { inject as service } from '@ember/service';
export default class Logout extends Route.extend(AuthenticatedRouteMixin) {
/**
* Reference to the application session service, implemented with Ember Simple Auth
* @type {Session}
*/
@service
session: Session;
/**
* Post transition, call endpoint then invalidate current session on client on success
*/
@action
didTransition(this: Logout) {
logout().then(() => get(this, 'session').invalidate());
}
}