我正在尝试 Devise 如何与我的一个项目一起进行用户身份验证。有一个用户要求他们的管理员应该能够不时生成一批用户名和用户密码,然后管理员将新的用户名和密码通过电子邮件发送给他的用户。
假设管理员具有 MySQL 数据库上的直接 SQL 知识,生成的用户名/密码如何被 Devise 识别?谢谢!
Use the Devise.friendly_token https://github.com/plataformatec/devise/blob/18b6064d74726147eccd69b24812000074261bbb/lib/devise.rb#L468 method:
password_length = 6
password = Devise.friendly_token.first(password_length)
User.create!(:email => '[email protected] /cdn-cgi/l/email-protection', :password => password, :password_confirmation => password)
FYI: Devise.friendly_token
返回 20 个字符的标记。在上面的例子中,我们砍掉了第一个password_length
使用生成的令牌的字符String#first http://api.rubyonrails.org/classes/String.html#method-i-firstRails 提供的方法。
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)