mirror of
https://github.com/internetee/registry.git
synced 2025-08-12 04:29:33 +02:00
Merge branch 'master' of github.com:domify/registry
This commit is contained in:
commit
e27132bab7
15 changed files with 99 additions and 67 deletions
|
@ -1,14 +1,27 @@
|
||||||
class Admin::SessionsController < SessionsController
|
class Admin::SessionsController < Devise::SessionsController
|
||||||
|
skip_authorization_check only: :create
|
||||||
layout 'admin/application'
|
layout 'admin/application'
|
||||||
|
|
||||||
def create
|
|
||||||
super
|
|
||||||
end
|
|
||||||
|
|
||||||
def login
|
def login
|
||||||
|
@admin_user = AdminUser.new
|
||||||
end
|
end
|
||||||
|
|
||||||
def find_user_by_idc(idc)
|
def create
|
||||||
AdminUser.find_by(identity_code: idc)
|
if params[:admin_user].blank?
|
||||||
|
@admin_user = AdminUser.new
|
||||||
|
flash[:alert] = 'Something went wrong'
|
||||||
|
return render 'login'
|
||||||
|
end
|
||||||
|
|
||||||
|
@admin_user = AdminUser.find_by(username: params[:admin_user][:username])
|
||||||
|
@admin_user ||= AdminUser.new(username: params[:admin_user][:username])
|
||||||
|
|
||||||
|
if @admin_user.valid_password?(params[:admin_user][:password])
|
||||||
|
sign_in @admin_user, event: :authentication
|
||||||
|
redirect_to admin_root_url, notice: I18n.t(:welcome)
|
||||||
|
else
|
||||||
|
flash[:alert] = 'Authorization error'
|
||||||
|
render 'login'
|
||||||
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
class Registrant::SessionsController < ::SessionsController
|
class Registrant::SessionsController < Devise::SessionsController
|
||||||
layout 'registrant/application'
|
layout 'registrant/application'
|
||||||
helper_method :depp_controller?
|
helper_method :depp_controller?
|
||||||
def depp_controller?
|
def depp_controller?
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
class Registrar::SessionsController < ::SessionsController
|
class Registrar::SessionsController < Devise::SessionsController
|
||||||
layout 'registrar/application'
|
layout 'registrar/application'
|
||||||
helper_method :depp_controller?
|
helper_method :depp_controller?
|
||||||
def depp_controller?
|
def depp_controller?
|
||||||
|
|
|
@ -1,17 +0,0 @@
|
||||||
class SessionsController < Devise::SessionsController
|
|
||||||
skip_authorization_check only: :create
|
|
||||||
|
|
||||||
def create
|
|
||||||
# TODO: Create ID Card login here:
|
|
||||||
# this is just testing config
|
|
||||||
# if Rails.env.development? || Rails.env.test?
|
|
||||||
@user = AdminUser.first if params[:user1]
|
|
||||||
@user = AdminUser.second if params[:user2]
|
|
||||||
|
|
||||||
return redirect_to :back, alert: 'No user' if @user.blank?
|
|
||||||
|
|
||||||
flash[:notice] = I18n.t('welcome')
|
|
||||||
sign_in_and_redirect @user, event: :authentication
|
|
||||||
# end
|
|
||||||
end
|
|
||||||
end
|
|
|
@ -91,6 +91,7 @@ class Ability
|
||||||
can :manage, DomainVersion
|
can :manage, DomainVersion
|
||||||
can :manage, User
|
can :manage, User
|
||||||
can :manage, ApiUser
|
can :manage, ApiUser
|
||||||
|
can :manage, AdminUser
|
||||||
can :manage, Certificate
|
can :manage, Certificate
|
||||||
can :manage, Keyrelay
|
can :manage, Keyrelay
|
||||||
can :manage, LegalDocument
|
can :manage, LegalDocument
|
||||||
|
|
|
@ -8,6 +8,8 @@ class AdminUser < User
|
||||||
|
|
||||||
ROLES = %w(user customer_service admin)
|
ROLES = %w(user customer_service admin)
|
||||||
|
|
||||||
|
devise :database_authenticatable, :rememberable, :trackable, :validatable, :lockable
|
||||||
|
|
||||||
def to_s
|
def to_s
|
||||||
username
|
username
|
||||||
end
|
end
|
||||||
|
|
|
@ -8,11 +8,18 @@
|
||||||
= f.label :username
|
= f.label :username
|
||||||
.col-md-8
|
.col-md-8
|
||||||
= f.text_field(:username, class: 'form-control')
|
= f.text_field(:username, class: 'form-control')
|
||||||
.form-group
|
- if @admin_user.new_record? || can?(:update, AdminUser)
|
||||||
.col-md-4.control-label
|
.form-group
|
||||||
= f.label :password
|
.col-md-4.control-label
|
||||||
.col-md-8
|
= f.label :password
|
||||||
= f.text_field(:password, class: 'form-control')
|
.col-md-8
|
||||||
|
= f.text_field(:password, class: 'form-control')
|
||||||
|
.form-group
|
||||||
|
.col-md-4.control-label
|
||||||
|
= f.label :password_confirmation
|
||||||
|
.col-md-8
|
||||||
|
= f.text_field(:password_confirmation, class: 'form-control')
|
||||||
|
|
||||||
%hr
|
%hr
|
||||||
.form-group
|
.form-group
|
||||||
.col-md-4.control-label
|
.col-md-4.control-label
|
||||||
|
|
|
@ -9,7 +9,7 @@
|
||||||
= err
|
= err
|
||||||
%br
|
%br
|
||||||
.row
|
.row
|
||||||
.col-md-6
|
.col-md-8
|
||||||
.panel.panel-default
|
.panel.panel-default
|
||||||
.panel-heading
|
.panel-heading
|
||||||
%h3.panel-title= t(:general)
|
%h3.panel-title= t(:general)
|
||||||
|
@ -18,21 +18,12 @@
|
||||||
%dt= t(:username)
|
%dt= t(:username)
|
||||||
%dd= @admin_user.username
|
%dd= @admin_user.username
|
||||||
|
|
||||||
%dt= t(:password)
|
%dt= t(:email)
|
||||||
%dd= @admin_user.password
|
%dd= @admin_user.email
|
||||||
|
|
||||||
%dt= t(:identity_code)
|
%dt= t(:identity_code)
|
||||||
%dd= @admin_user.identity_code
|
%dd= @admin_user.identity_code
|
||||||
|
|
||||||
.col-md-6
|
|
||||||
.panel.panel-default
|
|
||||||
.panel-heading
|
|
||||||
%h3.panel-title= t(:address)
|
|
||||||
.panel-body
|
|
||||||
%dl.dl-horizontal
|
|
||||||
%dt= t(:email)
|
|
||||||
%dd= @admin_user.email
|
|
||||||
|
|
||||||
%dt= t(:role)
|
%dt= t(:role)
|
||||||
- if @admin_user.roles
|
- if @admin_user.roles
|
||||||
%dd= t(@admin_user.roles.first)
|
%dd= t(@admin_user.roles.first)
|
||||||
|
|
|
@ -1,8 +1,15 @@
|
||||||
%h2.form-signin-heading.text-center Eesti Interneti SA
|
.row
|
||||||
%hr
|
.form-signin.col-md-6.center-block.text-center
|
||||||
.form-signin
|
%h2.form-signin-heading.text-center Eesti Interneti SA
|
||||||
/ TODO: Refactor this when ID card login is done
|
%hr
|
||||||
= button_to 'ID card (user1)', admin_sessions_path,
|
.form-signin
|
||||||
class: 'btn btn-lg btn-primary btn-block', name: 'user1'
|
= form_for(@admin_user, url: admin_sessions_path, method: :create, html: {class: 'form-signin'}) do |f|
|
||||||
= button_to 'ID card (user2)', admin_sessions_path,
|
= render 'admin/shared/errors', object: f.object
|
||||||
class: 'btn btn-lg btn-primary btn-block', name: 'user2'
|
|
||||||
|
- error_class = f.object.errors.any? ? 'has-error' : ''
|
||||||
|
%div{class: error_class}
|
||||||
|
= f.text_field :username, class: 'form-control', placeholder: t(:username), required: true
|
||||||
|
= f.password_field :password, class: 'form-control',
|
||||||
|
autocomplete: 'off', placeholder: t(:password), required: true
|
||||||
|
%button.btn.btn-lg.btn-primary.btn-block{:type => 'submit'}= t(:log_in)
|
||||||
|
|
||||||
|
|
5
app/views/admin/shared/_errors.haml
Normal file
5
app/views/admin/shared/_errors.haml
Normal file
|
@ -0,0 +1,5 @@
|
||||||
|
- if object.errors.any?
|
||||||
|
%p.text-danger
|
||||||
|
- object.errors.each do |attr, err|
|
||||||
|
= err
|
||||||
|
%br
|
|
@ -8,7 +8,8 @@
|
||||||
- error_class = f.object.errors.any? ? 'has-error' : ''
|
- error_class = f.object.errors.any? ? 'has-error' : ''
|
||||||
%div{class: error_class}
|
%div{class: error_class}
|
||||||
= f.text_field :tag, class: 'form-control', placeholder: t(:username), required: true
|
= f.text_field :tag, class: 'form-control', placeholder: t(:username), required: true
|
||||||
= f.password_field :password, class: 'form-control', placeholder: t(:password), required: true
|
= f.password_field :password, class: 'form-control',
|
||||||
|
autocomplete: 'off', placeholder: t(:password), required: true
|
||||||
|
|
||||||
%button.btn.btn-lg.btn-primary.btn-block{:type => 'submit'}= t(:log_in)
|
%button.btn.btn-lg.btn-primary.btn-block{:type => 'submit'}= t(:log_in)
|
||||||
|
|
||||||
|
|
|
@ -14,7 +14,7 @@ Devise.setup do |config|
|
||||||
# Configure the e-mail address which will be shown in Devise::Mailer,
|
# Configure the e-mail address which will be shown in Devise::Mailer,
|
||||||
# note that it will be overwritten if you use your own mailer class
|
# note that it will be overwritten if you use your own mailer class
|
||||||
# with default "from" parameter.
|
# with default "from" parameter.
|
||||||
config.mailer_sender = 'please-change-me-at-config-initializers-devise@example.com'
|
config.mailer_sender = 'noreply@example.com'
|
||||||
|
|
||||||
# Configure the class responsible to send e-mails.
|
# Configure the class responsible to send e-mails.
|
||||||
# config.mailer = 'Devise::Mailer'
|
# config.mailer = 'Devise::Mailer'
|
||||||
|
@ -131,7 +131,7 @@ Devise.setup do |config|
|
||||||
|
|
||||||
# ==> Configuration for :rememberable
|
# ==> Configuration for :rememberable
|
||||||
# The time the user will be remembered without asking for credentials again.
|
# The time the user will be remembered without asking for credentials again.
|
||||||
# config.remember_for = 2.weeks
|
config.remember_for = 2.weeks
|
||||||
|
|
||||||
# Invalidates all the remember me tokens when the user signs out.
|
# Invalidates all the remember me tokens when the user signs out.
|
||||||
config.expire_all_remember_me_on_sign_out = true
|
config.expire_all_remember_me_on_sign_out = true
|
||||||
|
@ -155,7 +155,7 @@ Devise.setup do |config|
|
||||||
# ==> Configuration for :timeoutable
|
# ==> Configuration for :timeoutable
|
||||||
# The time you want to timeout the user session without activity. After this
|
# The time you want to timeout the user session without activity. After this
|
||||||
# time the user will be asked for credentials again. Default is 30 minutes.
|
# time the user will be asked for credentials again. Default is 30 minutes.
|
||||||
# config.timeout_in = 30.minutes
|
config.timeout_in = 8.hours
|
||||||
|
|
||||||
# If true, expires auth token on session timeout.
|
# If true, expires auth token on session timeout.
|
||||||
# config.expire_auth_token_on_timeout = false
|
# config.expire_auth_token_on_timeout = false
|
||||||
|
@ -210,7 +210,7 @@ Devise.setup do |config|
|
||||||
# Turn scoped views on. Before rendering "sessions/new", it will first check for
|
# Turn scoped views on. Before rendering "sessions/new", it will first check for
|
||||||
# "users/sessions/new". It's turned off by default because it's slower if you
|
# "users/sessions/new". It's turned off by default because it's slower if you
|
||||||
# are using only default views.
|
# are using only default views.
|
||||||
# config.scoped_views = false
|
config.scoped_views = true
|
||||||
|
|
||||||
# Configure the default scope given to Warden. By default it's the first
|
# Configure the default scope given to Warden. By default it's the first
|
||||||
# devise role declared in your routes (usually :user).
|
# devise role declared in your routes (usually :user).
|
||||||
|
|
|
@ -219,11 +219,7 @@ Rails.application.routes.draw do
|
||||||
|
|
||||||
devise_scope :user do
|
devise_scope :user do
|
||||||
get 'login' => 'sessions#login'
|
get 'login' => 'sessions#login'
|
||||||
# get 'login/mid' => 'sessions#login_mid'
|
|
||||||
# post 'login/mid' => 'sessions#mid'
|
|
||||||
|
|
||||||
post 'sessions' => 'sessions#create'
|
post 'sessions' => 'sessions#create'
|
||||||
post 'mid' => 'sessions#mid'
|
|
||||||
get 'logout' => '/devise/sessions#destroy'
|
get 'logout' => '/devise/sessions#destroy'
|
||||||
end
|
end
|
||||||
|
|
||||||
|
@ -232,9 +228,5 @@ Rails.application.routes.draw do
|
||||||
|
|
||||||
devise_for :users
|
devise_for :users
|
||||||
|
|
||||||
devise_scope :user do
|
|
||||||
get 'login' => 'admin/sessions#login'
|
|
||||||
end
|
|
||||||
|
|
||||||
root to: redirect('admin/login')
|
root to: redirect('admin/login')
|
||||||
end
|
end
|
||||||
|
|
8
db/migrate/20150519144118_add_devise_attributes.rb
Normal file
8
db/migrate/20150519144118_add_devise_attributes.rb
Normal file
|
@ -0,0 +1,8 @@
|
||||||
|
class AddDeviseAttributes < ActiveRecord::Migration
|
||||||
|
def change
|
||||||
|
add_column :users, :encrypted_password, :string, null: true, default: ""
|
||||||
|
add_column :users, :remember_created_at, :datetime, null: true
|
||||||
|
add_column :users, :failed_attempts, :integer, default: 0, null: false
|
||||||
|
add_column :users, :locked_at, :datetime, null: true
|
||||||
|
end
|
||||||
|
end
|
28
db/schema.rb
28
db/schema.rb
|
@ -11,7 +11,7 @@
|
||||||
#
|
#
|
||||||
# It's strongly recommended that you check this file into your version control system.
|
# It's strongly recommended that you check this file into your version control system.
|
||||||
|
|
||||||
ActiveRecord::Schema.define(version: 20150519140853) do
|
ActiveRecord::Schema.define(version: 20150519144118) do
|
||||||
|
|
||||||
# These are extensions that must be enabled in order to support this database
|
# These are extensions that must be enabled in order to support this database
|
||||||
enable_extension "plpgsql"
|
enable_extension "plpgsql"
|
||||||
|
@ -852,6 +852,24 @@ ActiveRecord::Schema.define(version: 20150519140853) do
|
||||||
|
|
||||||
add_index "nameservers", ["domain_id"], name: "index_nameservers_on_domain_id", using: :btree
|
add_index "nameservers", ["domain_id"], name: "index_nameservers_on_domain_id", using: :btree
|
||||||
|
|
||||||
|
create_table "people", force: :cascade do |t|
|
||||||
|
t.string "email", default: "", null: false
|
||||||
|
t.string "encrypted_password", default: "", null: false
|
||||||
|
t.string "reset_password_token"
|
||||||
|
t.datetime "reset_password_sent_at"
|
||||||
|
t.datetime "remember_created_at"
|
||||||
|
t.integer "sign_in_count", default: 0, null: false
|
||||||
|
t.datetime "current_sign_in_at"
|
||||||
|
t.datetime "last_sign_in_at"
|
||||||
|
t.inet "current_sign_in_ip"
|
||||||
|
t.inet "last_sign_in_ip"
|
||||||
|
t.datetime "created_at"
|
||||||
|
t.datetime "updated_at"
|
||||||
|
end
|
||||||
|
|
||||||
|
add_index "people", ["email"], name: "index_people_on_email", unique: true, using: :btree
|
||||||
|
add_index "people", ["reset_password_token"], name: "index_people_on_reset_password_token", unique: true, using: :btree
|
||||||
|
|
||||||
create_table "registrant_verifications", force: :cascade do |t|
|
create_table "registrant_verifications", force: :cascade do |t|
|
||||||
t.string "domain_name"
|
t.string "domain_name"
|
||||||
t.string "verification_token"
|
t.string "verification_token"
|
||||||
|
@ -919,13 +937,13 @@ ActiveRecord::Schema.define(version: 20150519140853) do
|
||||||
t.datetime "created_at"
|
t.datetime "created_at"
|
||||||
t.datetime "updated_at"
|
t.datetime "updated_at"
|
||||||
t.string "email"
|
t.string "email"
|
||||||
t.integer "sign_in_count", default: 0, null: false
|
t.integer "sign_in_count", default: 0, null: false
|
||||||
t.datetime "current_sign_in_at"
|
t.datetime "current_sign_in_at"
|
||||||
t.datetime "last_sign_in_at"
|
t.datetime "last_sign_in_at"
|
||||||
t.inet "current_sign_in_ip"
|
t.inet "current_sign_in_ip"
|
||||||
t.inet "last_sign_in_ip"
|
t.inet "last_sign_in_ip"
|
||||||
t.string "identity_code"
|
t.string "identity_code"
|
||||||
t.string "roles", array: true
|
t.string "roles", array: true
|
||||||
t.string "creator_str"
|
t.string "creator_str"
|
||||||
t.string "updator_str"
|
t.string "updator_str"
|
||||||
t.string "country_code"
|
t.string "country_code"
|
||||||
|
@ -935,6 +953,10 @@ ActiveRecord::Schema.define(version: 20150519140853) do
|
||||||
t.text "crt"
|
t.text "crt"
|
||||||
t.string "type"
|
t.string "type"
|
||||||
t.string "registrant_ident"
|
t.string "registrant_ident"
|
||||||
|
t.string "encrypted_password", default: ""
|
||||||
|
t.datetime "remember_created_at"
|
||||||
|
t.integer "failed_attempts", default: 0, null: false
|
||||||
|
t.datetime "locked_at"
|
||||||
end
|
end
|
||||||
|
|
||||||
add_index "users", ["identity_code"], name: "index_users_on_identity_code", using: :btree
|
add_index "users", ["identity_code"], name: "index_users_on_identity_code", using: :btree
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue