0

Dear Stackoverflowers,

I'm building an informationsystem where other users (called 'Owners' withing the system) can register other users. I'm using Devise Invitable to get the invitation functionality. Invited users will get an email with a verificationlink. If they click on it, they can set their password and log into the system.

I want to build an extra verification when the user is setting his or her password. The user has to enter his or her 'uni-code' which is given by the invitor to the invited user either in person, or phone etc.. The uni-code is stored in the database when inviting the user.

When the invited user enters an invalid uni-code,the user is redirected to the same page and he or she has to try again. How can I apply the check for the uni-code and if it fails, how can I appropriate redirect?

# 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
Nazeem
  • 746
  • 1
  • 10
  • 29

1 Answers1

0

Are you looking to add additional invite code to verify user.

Check out following links it may help

https://github.com/scambra/devise_invitable

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

Thanks,

Nidhi Sarvaiya

Community
  • 1
  • 1
Nidhi
  • 340
  • 2
  • 10
  • My case is slighty different @NidhiSarvaiya I'm already using Devise Invitable. When the user accepts an invitation, he/she has to enter a unique code which is given by the invitor (as an extra verification). When the unique code is wrong, the user has to be redirected to the page where he/she can enter the unique code again. See the method ' update' in my supplied code snippet – Nazeem Sep 05 '12 at 10:31