How to auto-generate passwords in Rails Devise?

后端 未结 4 1252
北海茫月
北海茫月 2021-02-03 20:26

I am trying out how Devise works with one of my projects for user authentication. There is a user requirement that their admin should be able to generate a batch of username and

4条回答
  •  你的背包
    2021-02-03 21:09

    One option would be to use the Devise.generate_token. I.e.

    password = User.generate_token('password')
    User.create!(:email => 'someone@something.com', :password => password, :password_confirmation => password)
    

    This option has not been available in Devise for quite a while. Please refer to the other answer (friendly_token).

提交回复
热议问题