This commit is contained in:
Alex Sherman 2020-09-29 14:17:00 +05:00
parent bb37527dae
commit 0d716e110a
4 changed files with 4 additions and 54 deletions

View file

@ -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

View file

@ -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)

View file

@ -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

View file

@ -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