我正在尝试从 Rails 控制台设置用户(管理员)密码:
bundle exec rails console
> Spree::User.first.email
=> "admin@mysite.com"
> Spree::User.first.encrypted_password
Spree::User Load (1.1ms) SELECT "spree_users".* FROM "spree_users" LIMIT 1
=> "4ec556............................................."
> Spree::User.first.password='spree123'
Spree::User Load (1.0ms) SELECT "spree_users".* FROM "spree_users" LIMIT 1
=> "spree123"
> Spree::User.first.password_confirmation='spree123'
Spree::User Load (1.0ms) SELECT "spree_users".* FROM "spree_users" LIMIT 1
=> "spree123"
> Spree::User.first.save!
Spree::User Load (1.0ms) SELECT "spree_users".* FROM "spree_users" LIMIT 1
(0.3ms) BEGIN
(1.3ms) SELECT COUNT(DISTINCT "spree_users"."id") FROM "spree_users" LEFT OUTER JOIN "spree_roles_users" ON "spree_roles_users"."user_id" = "spree_users"."id" LEFT OUTER JOIN "spree_roles" ON "spree_roles"."id" = "spree_roles_users"."role_id" WHERE "spree_roles"."name" = 'admin'
(0.3ms) COMMIT
=> true
> Spree::User.first.encrypted_password
Spree::User Load (1.0ms) SELECT "spree_users".* FROM "spree_users" LIMIT 1
=> "1bc15d.............................................."
到目前为止,一切都很好。看起来用户的新密码已更改并提交到数据库。但是,当我稍后尝试使用 Web 客户端登录并使用新密码时,它会失败并显示无效的身份/密码消息。我什至尝试更新密码,Spree::User.first.reset_password!('spree123', 'spree123')
但仍然无法登录。
Rails 3.2.12 大礼包 1.3.2
知道我在做什么错吗?如何正确设置新密码?
谢谢。