如何从Rails控制台注销devise用户? [英] How can I sign out a devise user from the Rails console?

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

问题描述

我的设计用户是"database_authenticatable"和"token_authenticatable".我尝试从控制台中删除该用户的数据库中的"authentication_token"字段,但他们似乎仍然能够使用其现有的身份验证令牌.完全删除用户是可行的,但是我不想走那么远.

My devise users are "database_authenticatable" and "token_authenticatable". I've tried deleting the "authentication_token" field in the database for that user from the console, but they still seem to be able to use their existing auth token. Deleting the user entirely works, but I don't want to go that far.

为清楚起见.我想使用导轨控制台登出用户.即先运行rails console,然后运行一些命令.

for clarity. I want to use the rails console to sign out a user. i.e. run rails console and then some command.

推荐答案

Devise提供了辅助方法来完成这些操作.

Devise provide helper methods to do these things.

user = User.find(params[:id])
sign_in user
sign_out user

希望这会有所帮助.

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

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