我正在使用Devise for Rails.在默认注册过程中,Devise要求用户键入两次密码以进行验证和身份验证.我该如何禁用它?
谢谢大家.:)
使用Devise on Rails,是否有一些方法可以列出当前有活动会话的所有用户,即当前登录的用户?
PS.我正在寻找一个强大的解决方案,而不是像这个问题中那样简单化的东西
设备中的控制器是否自动生成?你如何访问它们?
我知道你的观点
rails generate devise_views.
使用Devise管理用户会话/注册我需要每次用户登录时,以及在通过设计重定向到主页以进行连接之前执行特定任务(例如,更新此特定用户的users表中的某些字段)用户.
我是否必须覆盖设计SessionsController,如果是,如何?
解
感谢史蒂文哈曼的这个要点,我得到了它的工作.devise_mail_helpers.rb
module Features
module MailHelpers
def last_email
ActionMailer::Base.deliveries[0]
end
# Can be used like:
# extract_token_from_email(:reset_password)
def extract_token_from_email(token_name)
mail_body = last_email.body.to_s
mail_body[/#{token_name.to_s}_token=([^"]+)/, 1]
end
end
end
Run Code Online (Sandbox Code Playgroud)
我将文件添加devise_mail_helpers.rb到功能规格所在的文件夹中并编写了此规范.
require 'devise_mail_helpers.rb'
include Features
include MailHelpers
describe "PasswordResets" do
it "emails user when requesting password reset" do
user = FactoryGirl.create(:user)
visit root_url
find("#login_link").click
click_link "Forgot your password?"
fill_in "Email", :with => user.email
click_button "Send instructions"
current_path.should eq('/users/sign_in')
page.should have_content("You will receive an email with instructions about how to …Run Code Online (Sandbox Code Playgroud) 使用Devise,我想知道是否有办法删除特定的Flash消息?(成功签署).
我关心视图中的其他消息,所以它只适用于已登录和已签名的消息.我是否必须覆盖控制器或还有其他方法?
谢谢!
我开始在我的Rails应用程序中使用Devise,但是Token Authenticatable:基于身份验证令牌(也称为"单一访问令牌")模块的用户登录让我感到困惑.
用户是否仅针对其当前会话进行了身份验证?如果他现在使用包含令牌的URL,他可以在以后的时间重新使用它并仍然可以访问,或者他是否可以获得单一访问权限?
可以使用相同的令牌同时对多个用户进行身份验证吗?
我已经广泛搜索了一个有效的例子; 如果在别处解释,请原谅我.任何指针都会受到欢迎.谢谢你的帮助.
我想知道如何集成这两个宝石(设计+强参数),因为强的params可能会被添加到4.0中的rails core
欢迎任何帮助谢谢
我正在尝试通过使用factorygirl创建用户创建一个注销流程规范,然后使用Devise的sign_in方法对用户进行身份验证,然后使用capybara单击"注销"链接.
当我运行规范时,我得到(在我看来是什么)一个奇怪的错误:
Failures:
1) Sign out flow successfully redirects to the welcome index (root)
Failure/Error: Unable to find matching line from backtrace
NoMethodError:
undefined method `env' for nil:NilClass
# /home/vagrant/.rvm/gems/ruby-2.0.0-p576/gems/devise-3.4.1/lib/devise/test_helpers.rb:24:in `setup_controller_for_warden'
Finished in 0.00226 seconds (files took 3.32 seconds to load)
1 example, 1 failure
Run Code Online (Sandbox Code Playgroud)
这是规格:
require 'rails_helper'
describe "Sign out flow" do
include Devise::TestHelpers
describe "successfully" do
it "redirects to the welcome index (root)" do
user = create(:user)
sign_in user
within '.user-info' do
click_link 'Sign Out'
end …Run Code Online (Sandbox Code Playgroud)