简体   繁体   English

使用Django后端进行Ember简单Auth注销操作

[英]Ember Simple Auth Logout Action with Django Backend

I'm using ember simple-auth library with ember simple-auth-token. 我正在将ember simple-auth库与ember simple-auth-token一起使用。 However, every time I perform a logout action, django does not delete the token of the logged in user. 但是,每次执行注销操作时,django都不会删除已登录用户的令牌。

I should point out that the frontend works like a charm! 我应该指出,前端工作就像一个魅力!

I am wondering if there should be a change in the frontend or in the backend code. 我想知道前端或后端代码中是否应该进行更改。

The invalidate() method should normally take care of the token refresh action, right?. invalidate()方法通常应处理令牌刷新操作,对吗?

Here is my code, which is pretty much the same as the code presented in the README of ember simple auth. 这是我的代码,与ember simple auth的README中提供的代码几乎相同。

controller/application.js 控制器/的application.js

import Ember from 'ember';

export default Ember.Controller.extend({
    session: Ember.inject.service('session'),

        actions: {
            invalidateSession() {
                this.get('session').invalidate();
            }
        }
 });

Thanks in advance! 提前致谢!

ember-simple-auth-token's authenticators don't implement the invalidate method that called upon session invalidation and can be used to send a request to the backend to invalidate the token. ember-simple-auth-token的身份验证器未实现在会话无效时调用的invalidate方法,可用于向后端发送请求以使令牌无效。 Without that method being implemented Ember Simple Auth simply deletes the token on the client side. 如果没有实现该方法,Ember Simple Auth只会在客户端删除令牌。

You should be able to extend the ember-simple-auth-token authenticator you're using and implement the invalidate method so that it sends a token invalidation request to the backend. 您应该能够扩展正在使用的ember-simple-auth-token身份验证器,并实现invalidate方法,以便它将令牌无效请求发送到后端。 Be sure to return a promise though. 但是一定要保证兑现承诺。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM