0

亲爱的 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
4

1 回答 1

0

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

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

https://github.com/scambra/devise_invitable

Ruby on rails:设计,想要添加邀请码?

谢谢,

尼迪·萨瓦亚

于 2012-09-04T20:51:24.350 回答