Skip to content
Snippets Groups Projects
Commit 6f16b7b4 authored by pabois's avatar pabois
Browse files

change registration context

parent bf2b03bb
No related branches found
No related tags found
No related merge requests found
......@@ -52,7 +52,6 @@ class Users::RegistrationsController < Devise::RegistrationsController
end
def sign_up_params
devise_parameter_sanitized = devise_parameter_sanitizer.sanitize(:sign_up)
current_mode == 'extranet' ? devise_parameter_sanitized.merge(extranet_to_validate: current_extranet) : devise_parameter_sanitized
devise_parameter_sanitized = devise_parameter_sanitizer.sanitize(:sign_up).merge(registration_context: current_context)
end
end
......@@ -131,7 +131,7 @@ class Education::Program < ApplicationRecord
}
def to_short_s
short_name.empty? ? to_s : short_name
short_name.blank? ? to_s : short_name
end
def to_s
......
......@@ -56,7 +56,7 @@
#
class User < ApplicationRecord
include WithAvatar
include WithExtranet
include WithRegistrationContext
include WithUniversity
include WithAuthentication
include WithOmniauth
......
module User::WithExtranet
extend ActiveSupport::Concern
included do
attr_accessor :extranet_to_validate
validate :extranet_access, unless: -> { extranet_to_validate.blank? }
private
def extranet_access
# do extranet_to_validate alumni include current email?
# TODO
# if extranet_to_validate.registration_contact.present?
# errors.add :email, I18n.t('extranet.errors.email_not_allowed_with_contact', contact: extranet_to_validate.registration_contact)
# else
# errors.add :email, I18n.t('extranet.errors.email_not_allowed')
# end
end
end
end
module User::WithRegistrationContext
extend ActiveSupport::Concern
included do
attr_accessor :registration_context
validate :extranet_access, if: -> { registration_context.is_a?(Communication::Extranet) }
private
def extranet_access
unless registration_context.alumni.where(email: email).any?
if registration_context.registration_contact.present?
errors.add :email, I18n.t('extranet.errors.email_not_allowed_with_contact', contact: registration_context.registration_contact)
else
errors.add :email, I18n.t('extranet.errors.email_not_allowed')
end
end
end
end
end
......@@ -44,7 +44,7 @@ ActiveRecord::Schema.define(version: 2022_10_17_142108) do
t.text "metadata"
t.string "service_name", null: false
t.bigint "byte_size", null: false
t.string "checksum"
t.string "checksum", null: false
t.datetime "created_at", null: false
t.uuid "university_id"
t.index ["key"], name: "index_active_storage_blobs_on_key", unique: true
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment