mirror of
https://github.com/internetee/registry.git
synced 2025-06-12 07:34:45 +02:00
Fix mess with registrant user routes
This commit is contained in:
parent
94b8ffd158
commit
6e99521d59
6 changed files with 54 additions and 55 deletions
|
@ -2,7 +2,7 @@ require 'open3'
|
||||||
|
|
||||||
class ApiUser < User
|
class ApiUser < User
|
||||||
include EppErrors
|
include EppErrors
|
||||||
devise :database_authenticatable, :trackable, :timeoutable, #:id_card_authenticatable,
|
devise :database_authenticatable, :trackable, :timeoutable,
|
||||||
authentication_keys: [:username]
|
authentication_keys: [:username]
|
||||||
|
|
||||||
def epp_code_map
|
def epp_code_map
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
class RegistrantUser < User
|
class RegistrantUser < User
|
||||||
attr_accessor :idc_data
|
attr_accessor :idc_data
|
||||||
|
|
||||||
devise :trackable, :timeoutable
|
devise :trackable, :timeoutable, :id_card_authenticatable
|
||||||
|
|
||||||
def ability
|
def ability
|
||||||
@ability ||= Ability.new(self)
|
@ability ||= Ability.new(self)
|
||||||
|
|
|
@ -21,5 +21,4 @@ class User < ApplicationRecord
|
||||||
|
|
||||||
User.find_by(identity_code: identity_code, country_code: country_code)
|
User.find_by(identity_code: identity_code, country_code: country_code)
|
||||||
end
|
end
|
||||||
|
|
||||||
end
|
end
|
||||||
|
|
|
@ -281,9 +281,9 @@ Devise.setup do |config|
|
||||||
# so you need to do it manually. For the users scope, it would be:
|
# so you need to do it manually. For the users scope, it would be:
|
||||||
# config.omniauth_path_prefix = '/my_engine/users/auth'
|
# config.omniauth_path_prefix = '/my_engine/users/auth'
|
||||||
|
|
||||||
# require 'devise/models/id_card_authenticatable'
|
require 'devise/models/id_card_authenticatable'
|
||||||
# require 'devise/strategies/id_card_authenticatable'
|
require 'devise/strategies/id_card_authenticatable'
|
||||||
|
|
||||||
# routes = [nil, :new, :destroy]
|
routes = [nil, :new, :destroy]
|
||||||
# config.add_module :id_card_authenticatable, strategy: true, route: { session: routes }
|
config.add_module :id_card_authenticatable, strategy: true, route: { session: routes }
|
||||||
end
|
end
|
||||||
|
|
|
@ -77,14 +77,14 @@ Rails.application.routes.draw do
|
||||||
devise_for :users, path: '', class_name: 'ApiUser', skip: %i[sessions]
|
devise_for :users, path: '', class_name: 'ApiUser', skip: %i[sessions]
|
||||||
|
|
||||||
devise_scope :registrar_user do
|
devise_scope :registrar_user do
|
||||||
# get 'login/mid' => 'sessions#login_mid'
|
get 'login/mid' => 'sessions#login_mid'
|
||||||
# post 'login/mid' => 'sessions#mid'
|
post 'login/mid' => 'sessions#mid'
|
||||||
# post 'login/mid_status' => 'sessions#mid_status'
|
post 'login/mid_status' => 'sessions#mid_status'
|
||||||
|
|
||||||
# /registrar/id path is hardcoded in Apache config for authentication with Estonian ID-card
|
# /registrar/id path is hardcoded in Apache config for authentication with Estonian ID-card
|
||||||
# post 'id' => 'sessions#id_card', as: :id_card_sign_in
|
post 'id' => 'sessions#id_card', as: :id_card_sign_in
|
||||||
#
|
|
||||||
# post 'mid' => 'sessions#mid'
|
post 'mid' => 'sessions#mid'
|
||||||
|
|
||||||
match '/open_id/callback', via: %i[get post], to: 'tara#callback', as: :tara_callback
|
match '/open_id/callback', via: %i[get post], to: 'tara#callback', as: :tara_callback
|
||||||
match '/open_id/cancel', via: %i[get post delete], to: 'tara#cancel',
|
match '/open_id/cancel', via: %i[get post delete], to: 'tara#cancel',
|
||||||
|
|
|
@ -1,49 +1,49 @@
|
||||||
module Devise
|
module Devise
|
||||||
module Strategies
|
module Strategies
|
||||||
class IdCardAuthenticatable < Devise::Strategies::Authenticatable
|
class IdCardAuthenticatable < Devise::Strategies::Authenticatable
|
||||||
# def valid?
|
def valid?
|
||||||
# env['SSL_CLIENT_S_DN_CN'].present?
|
env['SSL_CLIENT_S_DN_CN'].present?
|
||||||
# end
|
end
|
||||||
#
|
|
||||||
# def authenticate!
|
def authenticate!
|
||||||
# resource = mapping.to
|
resource = mapping.to
|
||||||
# user = resource.find_by_id_card(id_card)
|
user = resource.find_by_id_card(id_card)
|
||||||
#
|
|
||||||
# if user
|
if user
|
||||||
# success!(user)
|
success!(user)
|
||||||
# else
|
else
|
||||||
# fail
|
fail
|
||||||
# end
|
end
|
||||||
# end
|
end
|
||||||
#
|
|
||||||
# private
|
private
|
||||||
#
|
|
||||||
# def id_card
|
def id_card
|
||||||
# id_card = IdCard.new
|
id_card = IdCard.new
|
||||||
# id_card.first_name = first_name
|
id_card.first_name = first_name
|
||||||
# id_card.last_name = last_name
|
id_card.last_name = last_name
|
||||||
# id_card.personal_code = personal_code
|
id_card.personal_code = personal_code
|
||||||
# id_card.country_code = country_code
|
id_card.country_code = country_code
|
||||||
# id_card
|
id_card
|
||||||
# end
|
end
|
||||||
#
|
|
||||||
# def first_name
|
def first_name
|
||||||
# env['SSL_CLIENT_S_DN_CN'].split(',').second.force_encoding('utf-8')
|
env['SSL_CLIENT_S_DN_CN'].split(',').second.force_encoding('utf-8')
|
||||||
# end
|
end
|
||||||
#
|
|
||||||
# def last_name
|
def last_name
|
||||||
# env['SSL_CLIENT_S_DN_CN'].split(',').first.force_encoding('utf-8')
|
env['SSL_CLIENT_S_DN_CN'].split(',').first.force_encoding('utf-8')
|
||||||
# end
|
end
|
||||||
#
|
|
||||||
# def personal_code
|
def personal_code
|
||||||
# env['SSL_CLIENT_S_DN_CN'].split(',').last
|
env['SSL_CLIENT_S_DN_CN'].split(',').last
|
||||||
# end
|
end
|
||||||
#
|
|
||||||
# def country_code
|
def country_code
|
||||||
# env['SSL_CLIENT_I_DN_C']
|
env['SSL_CLIENT_I_DN_C']
|
||||||
# end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
# Warden::Strategies.add(:id_card_authenticatable, Devise::Strategies::IdCardAuthenticatable)
|
Warden::Strategies.add(:id_card_authenticatable, Devise::Strategies::IdCardAuthenticatable)
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue