mirror of
https://github.com/internetee/registry.git
synced 2025-07-25 20:18:22 +02:00
Prepare view & controller
This commit is contained in:
parent
8ff92548bf
commit
ffeb1d4baa
6 changed files with 2612 additions and 388 deletions
|
@ -1,13 +1,13 @@
|
|||
require 'tampering_detected'
|
||||
|
||||
class TaraController < ApplicationController
|
||||
class Registrar
|
||||
class TaraController < ApplicationController
|
||||
rescue_from Errors::TamperingDetected do
|
||||
redirect_to root_url, alert: t('auth.tara.tampering')
|
||||
end
|
||||
|
||||
def callback
|
||||
session[:omniauth_hash] = user_hash
|
||||
|
||||
@user = User.from_omniauth(user_hash)
|
||||
|
||||
return unless @user.persisted?
|
||||
|
@ -18,6 +18,7 @@ class TaraController < ApplicationController
|
|||
|
||||
# rubocop:disable Metrics/MethodLength
|
||||
def create
|
||||
tara_logger.info create_params
|
||||
@user = User.new(create_params)
|
||||
check_for_tampering
|
||||
create_password
|
||||
|
@ -59,6 +60,12 @@ class TaraController < ApplicationController
|
|||
end
|
||||
|
||||
def user_hash
|
||||
tara_logger.info request.env
|
||||
request.env['omniauth.auth']
|
||||
end
|
||||
|
||||
def tara_logger
|
||||
@tara_logger ||= Logger.new(Rails.root.join('log', 'tara_auth2.log'))
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
|
@ -16,17 +16,18 @@ class User < ApplicationRecord
|
|||
|
||||
# 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
|
||||
# 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
|
||||
|
||||
|
|
|
@ -19,11 +19,15 @@
|
|||
|
||||
<hr>
|
||||
|
||||
<%= link_to '/registrar/login/mid', id: 'login-with-mobile-id-btn' do %>
|
||||
<%= image_tag 'mid.gif' %>
|
||||
<% end %>
|
||||
<%#= link_to '/registrar/login/mid', id: 'login-with-mobile-id-btn' do %>
|
||||
<%#= image_tag 'mid.gif' %>
|
||||
<%# end %>
|
||||
|
||||
<%= link_to registrar_id_card_sign_in_path, method: :post do %>
|
||||
<%#= link_to registrar_id_card_sign_in_path, method: :post do %>
|
||||
<%#= image_tag 'id_card.gif' %>
|
||||
<%# end %>
|
||||
|
||||
<%= link_to "/auth/tara", method: :post, class: "ui button big primary" do %>
|
||||
<%= image_tag 'id_card.gif' %>
|
||||
<% end %>
|
||||
</div>
|
||||
|
|
0
app/views/registrar/tara/callback.html.erb
Normal file
0
app/views/registrar/tara/callback.html.erb
Normal file
|
@ -7,3 +7,7 @@ en:
|
|||
login_mid:
|
||||
header: Log in with mobile-id
|
||||
submit_btn: Login
|
||||
tara:
|
||||
callback:
|
||||
header_html: "Eesti Interneti SA<br>Registrar Portal"
|
||||
submit_btn: Login
|
||||
|
|
2862
db/structure.sql
2862
db/structure.sql
File diff suppressed because it is too large
Load diff
Loading…
Add table
Add a link
Reference in a new issue