【问题标题】:How to add extra verification when accepting invitation with DeviseInvitable使用 DeviseInvitable 接受邀请时如何添加额外验证
【发布时间】:2012-09-04 17:08:35
【问题描述】:

亲爱的 Stackoverflowers,

我正在构建一个信息系统,其他用户(在系统中称为“所有者”)可以注册其他用户。我正在使用 Devise Invitable 来获取邀请功能。 受邀用户将收到一封包含验证链接的电子邮件。如果他们点击它,他们可以设置他们的密码并登录系统。

我想在用户设置密码时构建额外的验证。 用户必须输入他或她的“uni-code”,该“uni-code”由邀请者亲自或通过电话等方式提供给被邀请的用户。邀请用户时,uni-code 存储在数据库中。

当受邀用户输入无效的 uni-code 时,用户将被重定向到同一页面,他或她必须重试。 如何应用检查 uni -code,如果失败,我该如何进行适当的重定向?

# Controller for handling Owners
# This class uses Devise-Invite methods for inviting new Owners
class Devise::Invitations::OwnerInvitationsController < Devise::InvitationsController

  # GET /owners/new
  def new
    super
  end

  # POST /owners
  def create
    params[:owner][:parent_id] = current_inviter
    super
  end

  #  PUT /owners
  def update
    if true #TODO: check if entered uni-code equals the owner's uni-code
      super
    else
      #TODO: uni-code does not match, redirect (howto do a proper redirect)?
    end
  end

# GET  /owners/invitation/accept?invitation_token={abcdef}
  def edit
      super
  end

【问题讨论】:

    标签: ruby-on-rails devise


    【解决方案1】:

    您是否希望添加额外的邀请码来验证用户。

    查看以下链接可能会有所帮助

    https://github.com/scambra/devise_invitable

    Ruby on rails: Devise, want to add invite code?

    谢谢,

    Nidhi Sarvaiya

    【讨论】:

    • 我的情况略有不同@NidhiSarvaiya 我已经在使用 Devise Invitable。当用户接受邀请时,他/她必须输入邀请者提供的唯一代码(作为额外验证)。当唯一代码错误时,用户必须被重定向到他/她可以再次输入唯一代码的页面。在我提供的代码 sn-p 中查看方法“更新”
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2018-06-18
    • 1970-01-01
    • 2016-05-24
    • 1970-01-01
    • 1970-01-01
    • 2012-04-15
    相关资源
    最近更新 更多