用devise gem rails注销用户 [英] Logout users with devise gem rails

查看:75
本文介绍了用devise gem rails注销用户的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在管理员部分中,我显示了当前登录用户的列表。
现在,管理员可以选择一个或多个用户并销毁他们的会话(注销他们)。
我不知道从哪里开始,请帮助我。

In admin section, I'm showing a list of currently logged in users. Now admin can select one or more user/users and destroy their session(logout them). I'm not able to figure where to start from,please help me.

推荐答案

您可以使用 sign_out 方法,通过传入用户对象来实现控制器操作:

You can use the sign_out method in the controller action by passing in the user object:

# Make sure only admins can do this
def sign_out_user
    @user = User.find(params[:id])    
    sign_out @user  
end

此处更多信息:

http://rubydoc.info/github/plataformatec/devise/master/Devise/TestHelpers%3asign_out

这篇关于用devise gem rails注销用户的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆