split login/welcome and added direct link welcome
This commit is contained in:
@ -30,6 +30,6 @@ class ApplicationController < ActionController::Base
|
||||
end
|
||||
|
||||
def authorize_candidate
|
||||
redirect_to welcome_path unless current_candidate
|
||||
redirect_to login_path unless current_candidate
|
||||
end
|
||||
end
|
||||
|
@ -1,5 +1,14 @@
|
||||
class CandidateController < ApplicationController
|
||||
before_action :authorize_candidate, except: [:welcome, :validate, :live_coder]
|
||||
before_action :authorize_candidate, except: [:login, :validate, :live_coder]
|
||||
before_action :send_to_oops, only: [:login]
|
||||
|
||||
def login
|
||||
login_candidate
|
||||
redirect_to :thankyou and return if current_candidate && current_candidate.completed?
|
||||
redirect_to :welcome if current_candidate
|
||||
|
||||
flash[:error] = "Sorry, incorrect test id" if params[:test_hash].present?
|
||||
end
|
||||
|
||||
def welcome
|
||||
end
|
||||
@ -7,6 +16,9 @@ class CandidateController < ApplicationController
|
||||
def saved
|
||||
end
|
||||
|
||||
def oops
|
||||
end
|
||||
|
||||
def thankyou
|
||||
redirect_to root_path if session[:test_id].nil?
|
||||
reset_session
|
||||
@ -52,11 +64,22 @@ class CandidateController < ApplicationController
|
||||
|
||||
session[:test_id] = candidate.test_hash
|
||||
redirect_to :thankyou and return if candidate.completed?
|
||||
redirect_to :question
|
||||
redirect_to :welcome
|
||||
end
|
||||
|
||||
private
|
||||
|
||||
def login_candidate
|
||||
candidate = Candidate.find_by(test_hash: params['test_id'])
|
||||
return false if candidate.nil?
|
||||
|
||||
session[:test_id] = candidate.test_hash
|
||||
end
|
||||
|
||||
def send_to_oops
|
||||
redirect_to oops_path if current_candidate
|
||||
end
|
||||
|
||||
def prep_question qid
|
||||
@question = current_candidate.fetch_question(qid)
|
||||
end
|
||||
|
Reference in New Issue
Block a user