mirror of
https://github.com/internetee/registry.git
synced 2025-07-03 01:33:36 +02:00
Add mid login to registrant
This commit is contained in:
parent
869c3fa95e
commit
8f109718c7
3 changed files with 14 additions and 2 deletions
|
@ -49,9 +49,10 @@ class Registrant::SessionsController < Devise::SessionsController
|
|||
return
|
||||
end
|
||||
|
||||
@user = find_user_by_idc(response.user_id_code)
|
||||
@user = RegistrantUser.find_or_create_by_mid_data(response)
|
||||
|
||||
if @user.persisted?
|
||||
session[:user_country] = response.user_country
|
||||
session[:user_id_code] = response.user_id_code
|
||||
session[:mid_session_code] = client.session_code
|
||||
render json: { message: t(:check_your_phone_for_confirmation_code) }, status: :ok
|
||||
|
@ -72,7 +73,8 @@ class Registrant::SessionsController < Devise::SessionsController
|
|||
when 'OUTSTANDING_TRANSACTION'
|
||||
render json: { message: t(:check_your_phone_for_confirmation_code) }, status: :ok
|
||||
when 'USER_AUTHENTICATED'
|
||||
@user = find_user_by_idc(session[:user_id_code])
|
||||
@user = RegistrantUser.find_by(registrant_ident: "#{session[:user_country]}-#{session[:user_id_code]}")
|
||||
|
||||
sign_in @user
|
||||
flash[:notice] = t(:welcome)
|
||||
flash.keep(:notice)
|
||||
|
|
|
@ -29,5 +29,13 @@ class RegistrantUser < User
|
|||
|
||||
u
|
||||
end
|
||||
|
||||
def find_or_create_by_mid_data(response)
|
||||
u = where(registrant_ident: "#{response.user_country}-#{response.user_id_code}").first_or_create
|
||||
u.username = "#{response.user_givenname} #{response.user_surname}"
|
||||
u.save
|
||||
|
||||
u
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
|
@ -2,5 +2,7 @@
|
|||
.form-signin.col-md-6.center-block.text-center
|
||||
%h2.form-signin-heading.text-center= t(:log_in)
|
||||
%hr
|
||||
= link_to '/registrant/login/mid' do
|
||||
= image_tag 'mid.gif'
|
||||
= link_to '/registrant/id', method: :post do
|
||||
= image_tag 'id_card.gif'
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue