Merge branch 'master' of github.com:domify/registry

This commit is contained in:
Priit Tark 2015-05-26 18:25:46 +03:00
commit dcfafdc2d7
4 changed files with 15 additions and 3 deletions

View file

@ -4,7 +4,7 @@
25.05.2015
* Added iptables counter commant to application-example.yml
* Added iptables counter command to application-example.yml
* Add update application.yml with correct `sk_digi_doc_service_endpoint`
22.05.2015

View file

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

View file

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

View file

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