diff --git a/app/controllers/registrar/tara_controller.rb b/app/controllers/registrar/tara_controller.rb index 4514655d0..31c812c73 100644 --- a/app/controllers/registrar/tara_controller.rb +++ b/app/controllers/registrar/tara_controller.rb @@ -11,47 +11,14 @@ class Registrar sign_in_and_redirect(:registrar_user, @api_user) end - # rubocop:disable Metrics/MethodLength - # def create - # @user = User.new(create_params) - # check_for_tampering - # create_password - # - # respond_to do |format| - # if @user.save - # format.html do - # sign_in(User, @user) - # redirect_to user_path(@user.uuid), notice: t(:created) - # end - # else - # format.html { render :callback } - # end - # end - # end - # rubocop:enable Metrics/MethodLength - def cancel redirect_to root_path, notice: t(:sign_in_cancelled) end private - # def create_params - # params.require(:user) - # .permit(:email, :identity_code, :country_code, :given_names, :surname, - # :accepts_terms_and_conditions, :locale, :uid, :provider) - # end - - # def create_password - # @user.password = Devise.friendly_token[0..20] - # end - def user_hash request.env['omniauth.auth'] end - - def tara_logger - @tara_logger ||= Logger.new(Rails.root.join('log', 'tara_auth4.log')) - end end end diff --git a/app/models/registrant_user.rb b/app/models/registrant_user.rb index e739d4a9d..efe5dd782 100644 --- a/app/models/registrant_user.rb +++ b/app/models/registrant_user.rb @@ -1,7 +1,7 @@ class RegistrantUser < User attr_accessor :idc_data - devise :trackable, :timeoutable#, :id_card_authenticatable + devise :trackable, :timeoutable def ability @ability ||= Ability.new(self) diff --git a/app/models/user.rb b/app/models/user.rb index c31cc6bbe..b28c16304 100644 --- a/app/models/user.rb +++ b/app/models/user.rb @@ -14,28 +14,12 @@ class User < ApplicationRecord "#{self.id}-#{self.class}: #{self.username}" end - # rubocop:disable Metrics/AbcSize - # def tampered_with?(omniauth_hash) - # # uid_from_hash = omniauth_hash['uid'] - # # provider_from_hash = omniauth_hash['provider'] - # # - # # begin - # # uid != uid_from_hash || - # # provider != provider_from_hash || - # # country_code != uid_from_hash.slice(0..1) || - # # identity_code != uid_from_hash.slice(2..-1) || - # # given_names != omniauth_hash.dig('info', 'first_name') || - # # surname != omniauth_hash.dig('info', 'last_name') - # # end - # false - # end - # rubocop:enable Metrics/AbcSize - def self.from_omniauth(omniauth_hash) uid = omniauth_hash['uid'] - # provider = omniauth_hash['provider'] + identity_code = uid.slice(2..-1) + country_code = uid.slice(0..1) - User.find_by(uid: uid) + User.find_by(identity_code: identity_code, country_code: country_code) end end diff --git a/config/routes.rb b/config/routes.rb index 5104a4ec5..04f12694e 100644 --- a/config/routes.rb +++ b/config/routes.rb @@ -89,7 +89,6 @@ Rails.application.routes.draw do match '/open_id/callback', via: %i[get post], to: 'tara#callback', as: :tara_callback match '/open_id/cancel', via: %i[get post delete], to: 'tara#cancel', as: :tara_cancel - # match '/open_id/create', via: [:post], to: 'tara#create', as: :tara_create end resources :invoices, except: %i[new create edit update destroy] do