mirror of
https://github.com/internetee/registry.git
synced 2025-06-08 21:54:48 +02:00
Refactor ID card sign-in
- Extract to Devise custom strategy - Use `SSL_CLIENT_S_DN_CN` env variable instead of `SSL_CLIENT_S_DN` to get ID card data - Remove `database_authenticatable` strategy from `RegistrantUser` Closes #1047
This commit is contained in:
parent
27976c3fbd
commit
a08f063640
20 changed files with 266 additions and 89 deletions
|
@ -1,26 +1,6 @@
|
|||
class Registrant::SessionsController < Devise::SessionsController
|
||||
layout 'registrant/application'
|
||||
|
||||
def new; end
|
||||
|
||||
def id
|
||||
client_certificate_subject = request.env['SSL_CLIENT_S_DN']
|
||||
client_certificate_issuer = request.env['SSL_CLIENT_I_DN_O']
|
||||
|
||||
if Rails.env.development?
|
||||
client_certificate_subject = 'test'
|
||||
client_certificate_issuer = RegistrantUser::ACCEPTED_ISSUER
|
||||
end
|
||||
|
||||
@user = RegistrantUser.find_or_create_by_idc_data(client_certificate_subject, client_certificate_issuer)
|
||||
if @user
|
||||
sign_in_and_redirect(:registrant_user, @user, event: :authentication)
|
||||
else
|
||||
flash[:alert] = t('login_failed_check_id_card')
|
||||
redirect_to new_registrant_user_session_url
|
||||
end
|
||||
end
|
||||
|
||||
def login_mid
|
||||
@user = User.new
|
||||
end
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue