简体   繁体   English

设计Ruby On Rails管理员以注销用户

[英]Devise Ruby On Rails Admin to sign out user

I am trying disable a devise user from an admin account. 我正在尝试从管理员帐户禁用设备用户。 I want their current session killed and their account marked as disabled. 我希望他们当前的会话被终止,并且将其帐户标记为已禁用。

I figured out how to disable their account so they can't login again, but I don't know how to kill their sessions from outside a devise controller (AdminController 我想出了如何禁用他们的帐户,以便他们无法再次登录的方法,但是我不知道如何从设备控制器(AdminController)外部杀死他们的会话。

Any ideas? 有任何想法吗?

We have instructions on how to do that on the Devise wiki: 我们在Devise Wiki上有关于如何执行此操作的说明:

https://github.com/plataformatec/devise/wiki/How-To:-Require-admin-to-activate-account-before-sign_in https://github.com/plataformatec/devise/wiki/How-To:-Require-admin-to-activate-account-before-sign_in

Basically, create a new column on your database, it can be called enabled or approved , which is true by default. 基本上,在数据库上创建一个新列,可以将其称为enabledapproved ,默认情况下为true。 Then customize the active_for_authentication? 然后自定义active_for_authentication? and inactive_message as in the wiki. 和wiki中的inactive_message一样。

The active_for_authentication? active_for_authentication? check is asked before every request, so you will effectively disable the user access on his next request. 在每个请求之前都要先检查一下,这样您就可以有效地禁止用户访问下一个请求。 If you have ajax and javascript, remember to properly handle 401 requests. 如果您具有Ajax和JavaScript,请记住正确处理401请求。

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

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