mirror of
https://github.com/internetee/registry.git
synced 2025-05-17 17:59:47 +02:00
Added registrar pki login
This commit is contained in:
parent
c8e9e35c57
commit
12eaea6bd8
2 changed files with 40 additions and 4 deletions
|
@ -6,6 +6,29 @@ class Registrar::SessionsController < ::SessionsController
|
|||
end
|
||||
|
||||
def login
|
||||
@user = Depp::User.new
|
||||
end
|
||||
|
||||
def create
|
||||
@user = Depp::User.new(params[:depp_user].merge(
|
||||
pki: request.env['HTTP_SSL_CLIENT_S_DN_CN'].present?
|
||||
)
|
||||
)
|
||||
|
||||
if @user.pki && request.env['HTTP_SSL_CLIENT_S_DN_CN'] != params[:depp_user][:tag]
|
||||
@user.errors.add(:base, :invalid_cert)
|
||||
end
|
||||
|
||||
if @user.errors.none? && @user.valid?
|
||||
session[:tag] = params[:depp_user][:tag]
|
||||
session[:password] = params[:depp_user][:password]
|
||||
session[:last_seen] = Time.now.to_i
|
||||
session[:pki] = @user.pki
|
||||
|
||||
redirect_to '/registrar'
|
||||
else
|
||||
render 'login'
|
||||
end
|
||||
end
|
||||
|
||||
def login_mid
|
||||
|
|
|
@ -1,8 +1,21 @@
|
|||
.row
|
||||
.form-signin.col-md-6.center-block.text-center
|
||||
%h2.form-signin-heading.text-center= t(:log_in)
|
||||
%hr
|
||||
= form_for @user, url: registrar_sessions_path, html: {class: 'form-signin'} do |f|
|
||||
= render 'registrar/shared/errors', object: f.object
|
||||
|
||||
- error_class = f.object.errors.any? ? 'has-error' : ''
|
||||
%div{class: error_class}
|
||||
= f.text_field :tag, class: 'form-control', placeholder: t(:username), required: true
|
||||
= f.password_field :password, class: 'form-control', placeholder: t(:password), required: true
|
||||
|
||||
%button.btn.btn-lg.btn-primary.btn-block{:type => 'submit'}= t(:log_in)
|
||||
|
||||
%hr
|
||||
= link_to '/registrar/login/mid' do
|
||||
= image_tag 'mid.gif'
|
||||
= link_to '/registrar/login/id' do
|
||||
= image_tag 'id_card.gif'
|
||||
-# = link_to '/registrar/login/id' do
|
||||
-# = image_tag 'id_card.gif'
|
||||
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue