mirror of
https://github.com/internetee/registry.git
synced 2025-08-11 12:09:34 +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'
|
||||
|
||||
def create
|
||||
super
|
||||
end
|
||||
|
||||
def login
|
||||
@admin_user = AdminUser.new
|
||||
end
|
||||
|
||||
def find_user_by_idc(idc)
|
||||
AdminUser.find_by(identity_code: idc)
|
||||
def create
|
||||
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
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
class Registrant::SessionsController < ::SessionsController
|
||||
class Registrant::SessionsController < Devise::SessionsController
|
||||
layout 'registrant/application'
|
||||
helper_method :depp_controller?
|
||||
def depp_controller?
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
class Registrar::SessionsController < ::SessionsController
|
||||
class Registrar::SessionsController < Devise::SessionsController
|
||||
layout 'registrar/application'
|
||||
helper_method :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, User
|
||||
can :manage, ApiUser
|
||||
can :manage, AdminUser
|
||||
can :manage, Certificate
|
||||
can :manage, Keyrelay
|
||||
can :manage, LegalDocument
|
||||
|
|
|
@ -8,6 +8,8 @@ class AdminUser < User
|
|||
|
||||
ROLES = %w(user customer_service admin)
|
||||
|
||||
devise :database_authenticatable, :rememberable, :trackable, :validatable, :lockable
|
||||
|
||||
def to_s
|
||||
username
|
||||
end
|
||||
|
|
|
@ -8,11 +8,18 @@
|
|||
= f.label :username
|
||||
.col-md-8
|
||||
= f.text_field(:username, class: 'form-control')
|
||||
- if @admin_user.new_record? || can?(:update, AdminUser)
|
||||
.form-group
|
||||
.col-md-4.control-label
|
||||
= f.label :password
|
||||
.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
|
||||
.form-group
|
||||
.col-md-4.control-label
|
||||
|
|
|
@ -9,7 +9,7 @@
|
|||
= err
|
||||
%br
|
||||
.row
|
||||
.col-md-6
|
||||
.col-md-8
|
||||
.panel.panel-default
|
||||
.panel-heading
|
||||
%h3.panel-title= t(:general)
|
||||
|
@ -18,21 +18,12 @@
|
|||
%dt= t(:username)
|
||||
%dd= @admin_user.username
|
||||
|
||||
%dt= t(:password)
|
||||
%dd= @admin_user.password
|
||||
%dt= t(:email)
|
||||
%dd= @admin_user.email
|
||||
|
||||
%dt= t(: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)
|
||||
- if @admin_user.roles
|
||||
%dd= t(@admin_user.roles.first)
|
||||
|
|
|
@ -1,8 +1,15 @@
|
|||
%h2.form-signin-heading.text-center Eesti Interneti SA
|
||||
%hr
|
||||
.form-signin
|
||||
/ TODO: Refactor this when ID card login is done
|
||||
= button_to 'ID card (user1)', admin_sessions_path,
|
||||
class: 'btn btn-lg btn-primary btn-block', name: 'user1'
|
||||
= button_to 'ID card (user2)', admin_sessions_path,
|
||||
class: 'btn btn-lg btn-primary btn-block', name: 'user2'
|
||||
.row
|
||||
.form-signin.col-md-6.center-block.text-center
|
||||
%h2.form-signin-heading.text-center Eesti Interneti SA
|
||||
%hr
|
||||
.form-signin
|
||||
= form_for(@admin_user, url: admin_sessions_path, method: :create, html: {class: 'form-signin'}) do |f|
|
||||
= render 'admin/shared/errors', object: f.object
|
||||
|
||||
- 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' : ''
|
||||
%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
|
||||
= 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)
|
||||
|
||||
|
|
|
@ -14,7 +14,7 @@ Devise.setup do |config|
|
|||
# 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
|
||||
# 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.
|
||||
# config.mailer = 'Devise::Mailer'
|
||||
|
@ -131,7 +131,7 @@ Devise.setup do |config|
|
|||
|
||||
# ==> Configuration for :rememberable
|
||||
# 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.
|
||||
config.expire_all_remember_me_on_sign_out = true
|
||||
|
@ -155,7 +155,7 @@ Devise.setup do |config|
|
|||
# ==> Configuration for :timeoutable
|
||||
# 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.
|
||||
# config.timeout_in = 30.minutes
|
||||
config.timeout_in = 8.hours
|
||||
|
||||
# If true, expires auth token on session timeout.
|
||||
# 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
|
||||
# "users/sessions/new". It's turned off by default because it's slower if you
|
||||
# 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
|
||||
# devise role declared in your routes (usually :user).
|
||||
|
|
|
@ -219,11 +219,7 @@ Rails.application.routes.draw do
|
|||
|
||||
devise_scope :user do
|
||||
get 'login' => 'sessions#login'
|
||||
# get 'login/mid' => 'sessions#login_mid'
|
||||
# post 'login/mid' => 'sessions#mid'
|
||||
|
||||
post 'sessions' => 'sessions#create'
|
||||
post 'mid' => 'sessions#mid'
|
||||
get 'logout' => '/devise/sessions#destroy'
|
||||
end
|
||||
|
||||
|
@ -232,9 +228,5 @@ Rails.application.routes.draw do
|
|||
|
||||
devise_for :users
|
||||
|
||||
devise_scope :user do
|
||||
get 'login' => 'admin/sessions#login'
|
||||
end
|
||||
|
||||
root to: redirect('admin/login')
|
||||
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
|
24
db/schema.rb
24
db/schema.rb
|
@ -11,7 +11,7 @@
|
|||
#
|
||||
# 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
|
||||
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
|
||||
|
||||
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|
|
||||
t.string "domain_name"
|
||||
t.string "verification_token"
|
||||
|
@ -935,6 +953,10 @@ ActiveRecord::Schema.define(version: 20150519140853) do
|
|||
t.text "crt"
|
||||
t.string "type"
|
||||
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
|
||||
|
||||
add_index "users", ["identity_code"], name: "index_users_on_identity_code", using: :btree
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue