标签: devise-confirmable

用户注册时设计"确认令牌无效"

在我的网络应用程序上使用Rails 4和Devise 3.1.0.我写了一个Cucumber测试来测试用户注册; 从电子邮件中单击"确认我的帐户"链接时失败.

Scenario: User signs up with valid data                                                           # features/users/sign_up.feature:9
    When I sign up with valid user data                                                             # features/step_definitions/user_steps.rb:87
    Then I should receive an email                                                                  # features/step_definitions/email_steps.rb:51
    When I open the email                                                                           # features/step_definitions/email_steps.rb:76
    Then I should see the email delivered from "no-reply@mysite.com"                                # features/step_definitions/email_steps.rb:116
    And I should see "You can confirm your account email through the link below:" in the email body # features/step_definitions/email_steps.rb:108
    When I follow "Confirm my account" in the email                                                 # features/step_definitions/email_steps.rb:178 …
Run Code Online (Sandbox Code Playgroud)

ruby-on-rails devise devise-confirmable

44
推荐指数
1
解决办法
2万
查看次数

确认链接点击使用设计宝石后避免登录?

我正在使用devisegem,点击确认链接后,我想直接登录.目前要求再次登录.

最近我在devise初始化文件中添加了以下内容:

config.allow_insecure_token_lookup = true
config.secret_key = 'a8d814803c0bcc735ce657adc77793459d00154cdd7532c13d3489600dc4e963f86e14beb593a32cbe9dbbe9197c9ce50a30102f363d90350052dc8d69930033'
Run Code Online (Sandbox Code Playgroud)

有什么建议?

ruby-on-rails devise ruby-on-rails-3 devise-confirmable

38
推荐指数
3
解决办法
1万
查看次数

设计再确认

我想在我的用户模型中使用设计选项:reconfirmable,因此每当用户更改其电子邮件时,他都需要通过电子邮件发送的链接进行确认.

最大的问题是,电子邮件从未被发送过......

我的设置是设计2.1.2是:

用户模型:

attr_accessible: unconfirmed_email, ...

devise :invitable, :database_authenticatable, :registerable, :recoverable, :rememberable, :trackable, :validatable, :confirmable, :omniauthable
Run Code Online (Sandbox Code Playgroud)

在initilizer devise.rb中:

config.reconfirmable = true
Run Code Online (Sandbox Code Playgroud)

在路线:

devise_for :users
Run Code Online (Sandbox Code Playgroud)

在模型字段unconfirmed_email正确设置的形式.我通过控制台检查了这个.

当用户在页面上注册时,第一个确认电子邮件会毫无问题地发送出去.

我尝试通过将此代码添加到初始化程序目录来调试问题,以覆盖作为after_update挂钩触发的设计方法:

module Devise::Models::Confirmable
  def send_confirmation_instructions
    debugger
  end
end
Run Code Online (Sandbox Code Playgroud)

似乎从未调用send_confirmation_instructions,因为我从未进入调试器.

我是否需要调用reconfirmable,或者在将模型属性"unconfirmed_email"设置为新的电子邮件地址时是否会自动触发?

感谢任何帮助,j.

devise ruby-on-rails-3 devise-confirmable

20
推荐指数
1
解决办法
8339
查看次数

使用可确认设计 - 当用户尝试使用未经证实的电子邮件登录时,将用户重定向到自定义页面

启用可确认模块后,Devise将不允许未经确认的用户在预定义的时间段过后登录.而是将用户重定向回登录页面,并显示"您必须先确认帐户才能继续".

这是一种不受欢迎的交互模型,因为闪存通知没有提供足够的空间来向用户正确解释访问被拒绝的原因,"确认您的帐户"的含义,提供重新发送确认的链接以及如何检查的说明您的垃圾邮件文件夹等.

有没有办法可以更改此行为以重定向到特定的URL?

ruby ruby-on-rails devise devise-confirmable

17
推荐指数
2
解决办法
8379
查看次数

我在哪里确认用FactoryGirl创建的用户?

使用rails,devise,rspec和factorygirl:

试图为我的网站创建一些测试.我正在使用确认模型进行设计,因此当我使用FactoryGirl创建用户时,用户未得到确认.

这是我的工厂.rb:

FactoryGirl.define do
  factory :user do
    full_name             "Aren Admin"
    email                 "aren@example.com"
    password              "arenaren"
    password_confirmation "arenaren"
    role_id               ADMIN
  end
end
Run Code Online (Sandbox Code Playgroud)

这是我的rspec测试文件:

require 'spec_helper'

describe "Admin pages" do

  subject { page }

  describe "home page" do
    let(:user) { FactoryGirl.create(:user) }
    before { visit admin_home_path }

    it { should have_content("#{ROLE_TYPES[user.role_id]}") }
  end
end
Run Code Online (Sandbox Code Playgroud)

我收到错误,因为用户未得到确认.通过搜索我很确定我需要使用'确认'方法!并且它属于factories.rb文件,但我不知道在哪里放它.

rspec ruby-on-rails devise-confirmable factory-bot

16
推荐指数
3
解决办法
7066
查看次数

禁用设计确认邮件

最近我将confirmable模块添加到了我的User类.我的应用程序中已经有一个非常好的邮件系统(Sidekiq,Sendgrid ......),因此我创建了自己的"确认帐户"邮件.现在的问题是禁用Devise发送其默认电子邮件.有没有办法完全禁用Devise邮件系统?

添加:

  • 我想维护confirmable模块,因为我正在使用它的属性和路由.
  • 我无法使用,skip_confirmation!因为我希望用户确认他们的帐户.
  • 我只是想禁用Devise邮件.

ruby-on-rails devise ruby-on-rails-3 devise-confirmable

16
推荐指数
3
解决办法
1万
查看次数

即使设置了allow_unconfirmed_access_for,为什么Devise不允许未经证实的用户登录?

我们有一个现有的用户群,并正在添加电子邮件确认.确认是可选的,但允许其他功能.用户无需确认.我添加了可确认模块并运行了迁移.确认按照广告宣传.

但是,用户无法登录,因为他们没有得到确认.所有当前用户都有零确认值,这是我们想要的(用户可以随时返回并确认他们的电子邮件).我已经关注了所有Devise wiki文章并在初始化程序中设置了allow_unconfirmed_access_for:

config.allow_unconfirmed_access_for = 10.years 
Run Code Online (Sandbox Code Playgroud)

我也尝试在我们的用户模型中设置它:

devise :confirmable, allow_unconfirmed_access_for: 10.years
Run Code Online (Sandbox Code Playgroud)

我也尝试过使用其他值(1.5年,500天等)

我的SessionsController,与Devise的方法没有太大区别(这里是github)

class Users::SessionsController < Devise::SessionsController
  respond_to :json

  def new
    redirect_to "/#login"
  end

  def create
    resource = warden.authenticate(auth_options)
    if !resource
      render json: {error: "Invalid email or password" }, status: 401 and return
    end

    sign_in(resource_name, resource)
    render "sign_in", formats: [:json], locals: { object: resource }
  end
end
Run Code Online (Sandbox Code Playgroud)

设计的回应:

{"error":"您必须在继续之前确认自己的帐户."}

使用Rails 3.2.9设计2.1.2.

devise ruby-on-rails-3 devise-confirmable

12
推荐指数
2
解决办法
5699
查看次数

用设计确认后自动登录

我正在使用设计确认.我有一些自定义的东西,我需要覆盖设计的确认!方法,所以在我的用户模型中,我有以下方法覆盖它:

def confirm!
  super
  gb = Gibbon::API.new(ENV['MAILCHIMP_API_KEY'])
  gb.lists.subscribe({:id => ENV['MAILCHIMP_ID'], :email => {:email => self.email }})
end
Run Code Online (Sandbox Code Playgroud)

这非常有效.现在我想要它,以便用户在确认后自动登录,但无法弄清楚如何.我知道这被认为是一个安全漏洞,但我已经承受了风险,因此我的网站用户体验值得.我不想对routes文件做任何事情,因为这个方法已经有效,所以我应该可以从这里开始.我已经尝试将以下内容放入我的配置文件中:

config.allow_insecure_sign_in_after_confirmation = true
Run Code Online (Sandbox Code Playgroud)

但它没有签署用户.

我看过堆栈溢出页面在使用devise gem确认链接点击后避免登录?它没有用,所以请不要将其标记为副本.

感谢大家.

ruby ruby-on-rails devise devise-confirmable ruby-on-rails-4

10
推荐指数
2
解决办法
5524
查看次数

删除密码确认; 设计

我在我的Rails 3.2.6应用程序中使用设计进行身份验证.我有password confirmation第一个,但现在我想删除它.怎么去那?

devise ruby-on-rails-3 devise-confirmable

9
推荐指数
1
解决办法
4211
查看次数

在设计电子邮件主题中添加动态值

好的,我已经看到很多关于自定义设计电子邮件主题的讨论,但似乎没有解决我想要的问题.目前,我的确认电子邮件主题为" 确认您的Qitch.com帐户 ".我想自定义此电子邮件主题并在其中添加用户名称的动态值,以便在用户ALEX注册帐户时,他应该获得主题为Welcome ALEX的电子邮件地址,确认您的Qitch.com帐户.我怎样才能在设计中实现这一目标?

devise.en.yml

mailer:
  confirmation_instructions:
    subject: 'Confirm your Qitch.com account'
  reset_password_instructions:
    subject: 'Reset your Qitch.com password'
  unlock_instructions:
    subject: 'Unlock your Qitch.com account'
Run Code Online (Sandbox Code Playgroud)

最后,如何在回复地址或地址中添加名称,目前当您收到邮件时,它说发件人:no-reply@qitch.com有没有办法我可以自定义它Qitch

谢谢

ruby-on-rails devise devise-confirmable

7
推荐指数
2
解决办法
4905
查看次数