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