Merge 7bdfb9ade5 into 50e75c6dd4
This commit is contained in:
commit
dfc4dd2e7e
5 changed files with 44 additions and 3 deletions
|
|
@ -35,7 +35,7 @@ class ApplicationController < ActionController::Base
|
|||
:authenticate_user!
|
||||
|
||||
if (current_user.nil?)
|
||||
redirect_to new_user_session_path
|
||||
redirect_to new_user_registration_path
|
||||
return false
|
||||
end
|
||||
|
||||
|
|
|
|||
40
app/controllers/confirmations_controller.rb
Normal file
40
app/controllers/confirmations_controller.rb
Normal file
|
|
@ -0,0 +1,40 @@
|
|||
class ConfirmationsController < Devise::ConfirmationsController
|
||||
def show
|
||||
self.resource = resource_class.confirm_by_token(params[:confirmation_token])
|
||||
yield resource if block_given?
|
||||
|
||||
if Conference.all.count == 1 && Conference.first.registration_open?
|
||||
@conference = Conference.first
|
||||
@conference.registrations.create!(user_id: self.resource.id)
|
||||
@redirection_path = register_conference_path(@conference.short_title)
|
||||
end
|
||||
|
||||
sign_in resource if resource
|
||||
|
||||
if resource.errors.empty?
|
||||
if @redirection_path.blank?
|
||||
set_flash_message(:notice, :confirmed) if is_flashing_format?
|
||||
else
|
||||
set_flash_message(:notice, :confirmed_registered) if is_flashing_format?
|
||||
end
|
||||
respond_with_navigational(resource){ redirect_to after_confirmation_path_for(resource_name, resource) } and return
|
||||
else
|
||||
respond_with_navigational(resource.errors, status: :unprocessable_entity){ render :new } and return
|
||||
end
|
||||
end
|
||||
|
||||
private
|
||||
|
||||
def after_confirmation_path_for(resource_name, resource)
|
||||
|
||||
if @redirection_path.blank?
|
||||
if signed_in?
|
||||
signed_in_root_path(resource)
|
||||
else
|
||||
new_session_path(resource_name)
|
||||
end
|
||||
else
|
||||
@redirection_path
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
@ -34,6 +34,7 @@ en:
|
|||
send_instructions: 'You will receive an email with instructions about how to confirm your account in a few minutes.'
|
||||
send_paranoid_instructions: 'If your email address exists in our database, you will receive an email with instructions about how to confirm your account in a few minutes.'
|
||||
confirmed: 'Your account was successfully confirmed. NOTE: You have not been automatically registered to attend a conference!'
|
||||
confirmed_registered: 'Your account was successfully confirmed and you have been automatically registered to attend the conference. You can update or cancel your registration below.'
|
||||
registrations:
|
||||
signed_up: 'Welcome! You have signed up successfully.'
|
||||
signed_up_but_unconfirmed: 'A message with a confirmation link has been sent to your email address. Please open the link to activate your account.'
|
||||
|
|
|
|||
|
|
@ -2,7 +2,7 @@ Osem::Application.routes.draw do
|
|||
|
||||
get 'conference/show'
|
||||
|
||||
devise_for :users, controllers: { registrations: :registrations,
|
||||
devise_for :users, controllers: { registrations: :registrations, confirmations: :confirmations,
|
||||
omniauth_callbacks: 'users/omniauth_callbacks' },
|
||||
path: 'accounts'
|
||||
|
||||
|
|
|
|||
|
|
@ -265,7 +265,7 @@ describe Admin::ConferenceController do
|
|||
|
||||
describe 'guest access' do
|
||||
|
||||
it_behaves_like 'access as participant or guest', :new_user_session_path
|
||||
it_behaves_like 'access as participant or guest', :new_user_registration_path
|
||||
|
||||
end
|
||||
end
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue