alchemy-devise 4.3.1 → 5.0.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +2 -2
- data/Rakefile +4 -2
- data/app/controllers/alchemy/admin/passwords_controller.rb +38 -0
- data/app/controllers/alchemy/admin/user_sessions_controller.rb +65 -0
- data/app/controllers/alchemy/admin/users_controller.rb +2 -3
- data/app/mailers/alchemy/notifications.rb +1 -1
- data/app/models/alchemy/user.rb +0 -8
- data/app/views/alchemy/{passwords → admin/passwords}/edit.html.erb +2 -2
- data/app/views/alchemy/{passwords → admin/passwords}/new.html.erb +2 -2
- data/app/views/alchemy/{user_sessions → admin/user_sessions}/new.html.erb +1 -1
- data/app/views/alchemy/admin/users/_fields.html.erb +0 -4
- data/app/views/alchemy/notifications/alchemy_user_created.de.text.erb +1 -1
- data/app/views/alchemy/notifications/alchemy_user_created.en.text.erb +1 -1
- data/app/views/alchemy/notifications/alchemy_user_created.es.text.erb +1 -1
- data/app/views/alchemy/notifications/alchemy_user_created.ru.text.erb +1 -1
- data/app/views/alchemy/notifications/member_created.de.text.erb +1 -1
- data/app/views/alchemy/notifications/member_created.en.text.erb +1 -1
- data/app/views/alchemy/notifications/member_created.es.text.erb +1 -1
- data/app/views/alchemy/notifications/member_created.ru.text.erb +1 -1
- data/app/views/alchemy/notifications/reset_password_instructions.de.text.erb +1 -1
- data/app/views/alchemy/notifications/reset_password_instructions.en.text.erb +1 -1
- data/app/views/alchemy/notifications/reset_password_instructions.es.text.erb +1 -1
- data/app/views/alchemy/notifications/reset_password_instructions.ru.text.erb +1 -1
- data/config/initializers/alchemy.rb +6 -0
- data/config/routes.rb +19 -14
- data/db/migrate/20131015124700_create_alchemy_users.rb +0 -1
- data/lib/alchemy/devise/version.rb +1 -1
- metadata +17 -16
- data/app/controllers/alchemy/passwords_controller.rb +0 -31
- data/app/controllers/alchemy/user_sessions_controller.rb +0 -62
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: d7cf8952620a0f56d95f9f809b61d1711b617a213d43ac6ed55e8b180aa194ef
|
4
|
+
data.tar.gz: 85ea1e249415b2d8aa14a4edcf2dc429bc18a813f26f740ee3aca43240bbd907
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: cf1515c619d2231aea6032dce59d2d64a75c8588810b7438466b5ab38275c67e4207e05e2ebf7ecb3e373a6bbe0472b4a7572b709ac959933ca624676b257bce
|
7
|
+
data.tar.gz: d275895d02b2b8646dfb7a92a8724a9fc1ba258ba116e6dc0c359933fd9e4f06dbd4390bab5706aafc8f09822d953af12d40c4311e1822a07f7509c751bb0683
|
data/README.md
CHANGED
@@ -1,4 +1,4 @@
|
|
1
|
-
## Devise based authentication for AlchemyCMS
|
1
|
+
## Devise based authentication for AlchemyCMS
|
2
2
|
|
3
3
|
[![Build Status](https://secure.travis-ci.org/AlchemyCMS/alchemy-devise.svg?branch=master)](http://travis-ci.org/AlchemyCMS/alchemy-devise)
|
4
4
|
|
@@ -12,7 +12,7 @@ Just put the gem into your projects `Gemfile`.
|
|
12
12
|
|
13
13
|
```ruby
|
14
14
|
# Gemfile
|
15
|
-
gem 'alchemy-devise'
|
15
|
+
gem 'alchemy-devise'
|
16
16
|
```
|
17
17
|
|
18
18
|
and run `bundle install`.
|
data/Rakefile
CHANGED
@@ -33,7 +33,9 @@ namespace :alchemy do
|
|
33
33
|
system <<-BASH
|
34
34
|
cd spec/dummy
|
35
35
|
export RAILS_ENV=test
|
36
|
-
bin/rake
|
36
|
+
bin/rake railties:install:migrations
|
37
|
+
bin/rake db:drop db:create db:migrate
|
38
|
+
bin/rails g alchemy:install --force --auto-accept
|
37
39
|
bin/rails g alchemy:devise:install --force
|
38
40
|
cd -
|
39
41
|
BASH
|
@@ -46,7 +48,7 @@ BASH
|
|
46
48
|
original_file = './CHANGELOG.md'
|
47
49
|
new_file = original_file + '.new'
|
48
50
|
backup = original_file + '.old'
|
49
|
-
changes = `git rev-list #{ENV['PREVIOUS_VERSION']}...
|
51
|
+
changes = `git rev-list v#{ENV['PREVIOUS_VERSION']}...main | bundle exec github_fast_changelog AlchemyCMS/alchemy-devise`
|
50
52
|
File.open(new_file, 'w') do |fo|
|
51
53
|
fo.puts changes
|
52
54
|
File.foreach(original_file) do |li|
|
@@ -0,0 +1,38 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require "alchemy/version"
|
4
|
+
|
5
|
+
module Alchemy
|
6
|
+
module Admin
|
7
|
+
class PasswordsController < ::Devise::PasswordsController
|
8
|
+
include Alchemy::Admin::Locale
|
9
|
+
|
10
|
+
if Alchemy.gem_version <= Gem::Version.new("4.9")
|
11
|
+
before_action { enforce_ssl if ssl_required? && !request.ssl? }
|
12
|
+
end
|
13
|
+
|
14
|
+
helper "Alchemy::Admin::Base"
|
15
|
+
|
16
|
+
layout "alchemy/admin"
|
17
|
+
|
18
|
+
private
|
19
|
+
|
20
|
+
# Override for Devise method
|
21
|
+
def new_session_path(resource_name)
|
22
|
+
alchemy.admin_login_path
|
23
|
+
end
|
24
|
+
|
25
|
+
def admin_edit_password_url(_resource, options = {})
|
26
|
+
alchemy.admin_edit_password_url(options)
|
27
|
+
end
|
28
|
+
|
29
|
+
def after_resetting_password_path_for(resource)
|
30
|
+
if can? :index, :alchemy_admin_dashboard
|
31
|
+
alchemy.admin_dashboard_path
|
32
|
+
else
|
33
|
+
alchemy.root_path
|
34
|
+
end
|
35
|
+
end
|
36
|
+
end
|
37
|
+
end
|
38
|
+
end
|
@@ -0,0 +1,65 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require "alchemy/version"
|
4
|
+
|
5
|
+
module Alchemy
|
6
|
+
module Admin
|
7
|
+
class UserSessionsController < ::Devise::SessionsController
|
8
|
+
include Alchemy::Admin::Locale
|
9
|
+
|
10
|
+
protect_from_forgery prepend: true
|
11
|
+
|
12
|
+
if Alchemy.gem_version <= Gem::Version.new("4.9")
|
13
|
+
before_action except: "destroy" do
|
14
|
+
enforce_ssl if ssl_required? && !request.ssl?
|
15
|
+
end
|
16
|
+
end
|
17
|
+
before_action :check_user_count, :only => :new
|
18
|
+
|
19
|
+
helper "Alchemy::Admin::Base"
|
20
|
+
|
21
|
+
layout "alchemy/admin"
|
22
|
+
|
23
|
+
def create
|
24
|
+
authenticate_user!
|
25
|
+
|
26
|
+
if user_signed_in?
|
27
|
+
if session[:redirect_path].blank?
|
28
|
+
redirect_path = admin_dashboard_path
|
29
|
+
else
|
30
|
+
# We have to strip double slashes from beginning of path, because of strange rails/rack bug.
|
31
|
+
redirect_path = session[:redirect_path].gsub(/\A\/{2,}/, "/")
|
32
|
+
end
|
33
|
+
redirect_to redirect_path,
|
34
|
+
notice: t(:signed_in, scope: "devise.sessions")
|
35
|
+
else
|
36
|
+
super
|
37
|
+
end
|
38
|
+
end
|
39
|
+
|
40
|
+
def destroy
|
41
|
+
current_alchemy_user.try(:unlock_pages!)
|
42
|
+
cookies.clear
|
43
|
+
session.clear
|
44
|
+
super
|
45
|
+
end
|
46
|
+
|
47
|
+
private
|
48
|
+
|
49
|
+
def check_user_count
|
50
|
+
if User.count == 0
|
51
|
+
redirect_to admin_signup_path
|
52
|
+
end
|
53
|
+
end
|
54
|
+
|
55
|
+
# Overwriting the default of Devise
|
56
|
+
def after_sign_out_path_for(resource_or_scope)
|
57
|
+
if request.referer.blank? || request.referer.to_s =~ /admin/
|
58
|
+
root_path
|
59
|
+
else
|
60
|
+
request.referer
|
61
|
+
end
|
62
|
+
end
|
63
|
+
end
|
64
|
+
end
|
65
|
+
end
|
@@ -2,7 +2,7 @@ module Alchemy
|
|
2
2
|
module Admin
|
3
3
|
class UsersController < ResourcesController
|
4
4
|
|
5
|
-
before_action :
|
5
|
+
before_action :set_roles, except: [:index, :destroy]
|
6
6
|
|
7
7
|
load_and_authorize_resource class: Alchemy::User,
|
8
8
|
only: [:edit, :update, :destroy]
|
@@ -67,13 +67,12 @@ module Alchemy
|
|
67
67
|
|
68
68
|
private
|
69
69
|
|
70
|
-
def
|
70
|
+
def set_roles
|
71
71
|
if can_update_role?
|
72
72
|
@user_roles = User::ROLES.map do |role|
|
73
73
|
[User.human_rolename(role), role]
|
74
74
|
end
|
75
75
|
end
|
76
|
-
@user_genders = User.genders_for_select
|
77
76
|
end
|
78
77
|
|
79
78
|
def user_params
|
data/app/models/alchemy/user.rb
CHANGED
@@ -8,7 +8,6 @@ module Alchemy
|
|
8
8
|
:lastname,
|
9
9
|
:login,
|
10
10
|
:email,
|
11
|
-
:gender,
|
12
11
|
:language,
|
13
12
|
:password,
|
14
13
|
:password_confirmation,
|
@@ -41,13 +40,6 @@ module Alchemy
|
|
41
40
|
Alchemy.t("user_roles.#{role}")
|
42
41
|
end
|
43
42
|
|
44
|
-
def genders_for_select
|
45
|
-
[
|
46
|
-
[Alchemy.t('male'), 'male'],
|
47
|
-
[Alchemy.t('female'), 'female']
|
48
|
-
]
|
49
|
-
end
|
50
|
-
|
51
43
|
def logged_in_timeout
|
52
44
|
Config.get(:auto_logout_time).minutes.to_i
|
53
45
|
end
|
@@ -10,13 +10,13 @@
|
|
10
10
|
<%= devise_error_messages! %>
|
11
11
|
</div>
|
12
12
|
<% end %>
|
13
|
-
<%= alchemy_form_for resource, as: resource_name, url:
|
13
|
+
<%= alchemy_form_for resource, as: resource_name, url: admin_update_password_path, method: 'patch' do |f| %>
|
14
14
|
<%= f.hidden_field :reset_password_token %>
|
15
15
|
<%= f.input :password, autofocus: true, label: Alchemy.t("New password") %>
|
16
16
|
<%= f.input :password_confirmation, label: Alchemy.t("Confirm new password") %>
|
17
17
|
<div class="input link">
|
18
18
|
<small>
|
19
|
-
<%= link_to Alchemy.t(:back), alchemy.
|
19
|
+
<%= link_to Alchemy.t(:back), alchemy.admin_login_path %>
|
20
20
|
</small>
|
21
21
|
</div>
|
22
22
|
<%= f.submit Alchemy.t("Change password") %>
|
@@ -10,13 +10,13 @@
|
|
10
10
|
<%= devise_error_messages! %>
|
11
11
|
</div>
|
12
12
|
<% end %>
|
13
|
-
<%= alchemy_form_for :user, url:
|
13
|
+
<%= alchemy_form_for :user, url: admin_reset_password_path, html: {method: 'post'} do |f| %>
|
14
14
|
<%= f.input :email,
|
15
15
|
autofocus: true,
|
16
16
|
input_html: {value: params[:email]} %>
|
17
17
|
<div class="input link">
|
18
18
|
<small>
|
19
|
-
<%= link_to Alchemy.t(:back), alchemy.
|
19
|
+
<%= link_to Alchemy.t(:back), alchemy.admin_login_path %>
|
20
20
|
</small>
|
21
21
|
</div>
|
22
22
|
<%= f.submit Alchemy.t("Send reset instructions"), input_html: {class: 'secondary'} %>
|
@@ -10,6 +10,6 @@ Aus Sicherheitsgründen stellen wir Ihr Passwort hier nicht dar.
|
|
10
10
|
|
11
11
|
Wenn Sie Ihr Passwort vergessen haben oder dies Ihr erster Login ist, gehen Sie bitte auf:
|
12
12
|
|
13
|
-
<%= alchemy.
|
13
|
+
<%= alchemy.admin_new_password_url %>
|
14
14
|
|
15
15
|
Viel Spaß mit Alchemy!
|
@@ -8,6 +8,6 @@ Es wurde ein Zufallspasswort generiert. Aus Sicherheitsgründen wird dieses hier
|
|
8
8
|
|
9
9
|
Klicken Sie bitte daher auf den folgenden Link (*), um sich ein neues Passwort zu vergeben:
|
10
10
|
|
11
|
-
<%= alchemy.
|
11
|
+
<%= alchemy.admin_new_password_url(email: @user.email) %>
|
12
12
|
|
13
13
|
*) Sollte dies nicht funktionieren, so kopieren Sie Sich bitte diesen Link und tragen Sie ihn in die Adresszeile Ihres Webbrowsers ein.
|
@@ -8,6 +8,6 @@ The password was randomly created. For security reasons it is not displayed here
|
|
8
8
|
|
9
9
|
Please follow this link (*) to reset your password:
|
10
10
|
|
11
|
-
<%= alchemy.
|
11
|
+
<%= alchemy.admin_new_password_url(email: @user.email) %>
|
12
12
|
|
13
13
|
*) If this does not work, please copy the url and paste it into the address bar of your web browser.
|
@@ -8,6 +8,6 @@ La contraseña se ha generado aleatoriamente. Por razones de seguridad no se mos
|
|
8
8
|
|
9
9
|
Por favor, accede este enlace (*) para reiniciar tu contraseña:
|
10
10
|
|
11
|
-
<%= alchemy.
|
11
|
+
<%= alchemy.admin_new_password_url(email: @user.email) %>
|
12
12
|
|
13
13
|
*) Si esto no funciona, por favor, copia el enlace y pegalo en el campo de direcciones de tu navegador web.
|
@@ -8,6 +8,6 @@
|
|
8
8
|
|
9
9
|
Пожалуйста, пройдите по ссылке (*), чтобы назначить собственный пароль:
|
10
10
|
|
11
|
-
<%= alchemy.
|
11
|
+
<%= alchemy.admin_new_password_url(email: @user.email) %>
|
12
12
|
|
13
13
|
*) Если ссылка не работает, пожалуйста, скопируйте ее в адресную строку вашего браузера.
|
@@ -2,7 +2,7 @@ Hallo <%= @user.fullname %>.
|
|
2
2
|
|
3
3
|
Sie haben angefordert Ihr Passwort zurückzusetzen. Dies kann durch anklicken des nachfolgenden Links bestätigt werden.
|
4
4
|
|
5
|
-
<%= alchemy.
|
5
|
+
<%= alchemy.admin_edit_password_url(@user, reset_password_token: @token) %>
|
6
6
|
|
7
7
|
Wenn Sie diese Zurücksetzung nicht angefragt haben, dann können Sie diese E-Mail einfach ignorieren.
|
8
8
|
Ihr Passwort wird erst dann zurückgesetzt, wenn Sie den Link anklicken.
|
@@ -2,7 +2,7 @@ Hello <%= @user.name %>.
|
|
2
2
|
|
3
3
|
You have requested to change your password. Please confirm this by clicking the link below.
|
4
4
|
|
5
|
-
<%= alchemy.
|
5
|
+
<%= alchemy.admin_edit_password_url(@user, reset_password_token: @token) %>
|
6
6
|
|
7
7
|
If you didn't request this, please ignore this email.
|
8
8
|
Your password won't change until you access the link above and create a new one.
|
@@ -2,7 +2,7 @@ Hola <%= @user.name %>.
|
|
2
2
|
|
3
3
|
Has solicitado modificar tu contraseña. Por favor, confírmalo pulsando en el siguiente enlace.
|
4
4
|
|
5
|
-
<%= alchemy.
|
5
|
+
<%= alchemy.admin_edit_password_url(@user, reset_password_token: @token) %>
|
6
6
|
|
7
7
|
Si no has sido tu el que ha hecho la solicitud, ignora este correo.
|
8
8
|
Tu contraseña no cambiará hasta que no accedas al enlace de arriba y generes una nueva.
|
@@ -2,7 +2,7 @@
|
|
2
2
|
|
3
3
|
Вы сделали запрос на смену пароля. Пожалуйста подтвердите это, нажав на ссылку ниже.
|
4
4
|
|
5
|
-
<%= alchemy.
|
5
|
+
<%= alchemy.admin_edit_password_url(@user, reset_password_token: @token) %>
|
6
6
|
|
7
7
|
Если вы не делали запрос, просто проигнорируйте это письмо.
|
8
8
|
Ваш пароль не изменится до тех пор, пока вы не перейдете по ссылке и сами не измените его.
|
@@ -18,3 +18,9 @@ Alchemy.user_class_name = 'Alchemy::User'
|
|
18
18
|
Alchemy.signup_path = '/admin/signup'
|
19
19
|
Alchemy.login_path = '/admin/login'
|
20
20
|
Alchemy.logout_path = '/admin/logout'
|
21
|
+
|
22
|
+
if Alchemy.respond_to?(:logout_method)
|
23
|
+
Rails.application.config.after_initialize do
|
24
|
+
Alchemy.logout_method = Devise.sign_out_via
|
25
|
+
end
|
26
|
+
end
|
data/config/routes.rb
CHANGED
@@ -1,22 +1,29 @@
|
|
1
1
|
Alchemy::Engine.routes.draw do
|
2
|
-
|
3
|
-
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
|
2
|
+
namespace :admin, {
|
3
|
+
path: Alchemy.admin_path,
|
4
|
+
constraints: Alchemy.admin_constraints
|
5
|
+
} do
|
6
|
+
|
7
|
+
devise_for :user,
|
8
|
+
class_name: 'Alchemy::User',
|
9
|
+
singular: :user,
|
10
|
+
skip: :all,
|
11
|
+
controllers: {
|
12
|
+
sessions: 'alchemy/admin/user_sessions',
|
13
|
+
passwords: 'alchemy/admin/passwords'
|
14
|
+
},
|
15
|
+
router_name: :alchemy
|
8
16
|
|
9
|
-
scope Alchemy.admin_path, {constraints: Alchemy.admin_constraints} do
|
10
17
|
devise_scope :user do
|
11
|
-
get '/dashboard' => '
|
18
|
+
get '/dashboard' => 'dashboard#index',
|
12
19
|
:as => :user_root
|
13
|
-
get '/signup' => '
|
14
|
-
:as => :
|
20
|
+
get '/signup' => 'users#signup',
|
21
|
+
:as => :signup
|
15
22
|
get '/login' => 'user_sessions#new',
|
16
23
|
:as => :login
|
17
24
|
post '/login' => 'user_sessions#create'
|
18
|
-
|
19
|
-
:as => :logout
|
25
|
+
match '/logout' => 'user_sessions#destroy',
|
26
|
+
:as => :logout, via: Devise.sign_out_via
|
20
27
|
|
21
28
|
get '/passwords' => 'passwords#new',
|
22
29
|
:as => :new_password
|
@@ -27,9 +34,7 @@ Alchemy::Engine.routes.draw do
|
|
27
34
|
patch '/passwords' => 'passwords#update',
|
28
35
|
:as => :update_password
|
29
36
|
end
|
30
|
-
end
|
31
37
|
|
32
|
-
namespace :admin, {path: Alchemy.admin_path, constraints: Alchemy.admin_constraints} do
|
33
38
|
resources :users
|
34
39
|
end
|
35
40
|
end
|
@@ -6,7 +6,6 @@ class CreateAlchemyUsers < ActiveRecord::Migration[4.2]
|
|
6
6
|
t.string "lastname"
|
7
7
|
t.string "login"
|
8
8
|
t.string "email"
|
9
|
-
t.string "gender"
|
10
9
|
t.string "language"
|
11
10
|
t.string "encrypted_password", limit: 128, default: "", null: false
|
12
11
|
t.string "password_salt", limit: 128, default: "", null: false
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: alchemy-devise
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version:
|
4
|
+
version: 5.0.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Thomas von Deyen
|
8
|
-
autorequire:
|
8
|
+
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2020-11-22 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: alchemy_cms
|
@@ -16,20 +16,20 @@ dependencies:
|
|
16
16
|
requirements:
|
17
17
|
- - ">="
|
18
18
|
- !ruby/object:Gem::Version
|
19
|
-
version: 4.1.0
|
19
|
+
version: 4.1.0
|
20
20
|
- - "<"
|
21
21
|
- !ruby/object:Gem::Version
|
22
|
-
version: '
|
22
|
+
version: '5.1'
|
23
23
|
type: :runtime
|
24
24
|
prerelease: false
|
25
25
|
version_requirements: !ruby/object:Gem::Requirement
|
26
26
|
requirements:
|
27
27
|
- - ">="
|
28
28
|
- !ruby/object:Gem::Version
|
29
|
-
version: 4.1.0
|
29
|
+
version: 4.1.0
|
30
30
|
- - "<"
|
31
31
|
- !ruby/object:Gem::Version
|
32
|
-
version: '
|
32
|
+
version: '5.1'
|
33
33
|
- !ruby/object:Gem::Dependency
|
34
34
|
name: devise
|
35
35
|
requirement: !ruby/object:Gem::Requirement
|
@@ -39,7 +39,7 @@ dependencies:
|
|
39
39
|
version: 4.7.1
|
40
40
|
- - "<"
|
41
41
|
- !ruby/object:Gem::Version
|
42
|
-
version: '
|
42
|
+
version: '5'
|
43
43
|
type: :runtime
|
44
44
|
prerelease: false
|
45
45
|
version_requirements: !ruby/object:Gem::Requirement
|
@@ -49,7 +49,7 @@ dependencies:
|
|
49
49
|
version: 4.7.1
|
50
50
|
- - "<"
|
51
51
|
- !ruby/object:Gem::Version
|
52
|
-
version: '
|
52
|
+
version: '5'
|
53
53
|
- !ruby/object:Gem::Dependency
|
54
54
|
name: capybara
|
55
55
|
requirement: !ruby/object:Gem::Requirement
|
@@ -148,12 +148,15 @@ files:
|
|
148
148
|
- app/assets/stylesheets/alchemy-devise/login.scss
|
149
149
|
- app/assets/stylesheets/alchemy-devise/users.scss
|
150
150
|
- app/assets/stylesheets/alchemy/admin/alchemy-devise.css
|
151
|
+
- app/controllers/alchemy/admin/passwords_controller.rb
|
152
|
+
- app/controllers/alchemy/admin/user_sessions_controller.rb
|
151
153
|
- app/controllers/alchemy/admin/users_controller.rb
|
152
154
|
- app/controllers/alchemy/base_controller_extension.rb
|
153
|
-
- app/controllers/alchemy/passwords_controller.rb
|
154
|
-
- app/controllers/alchemy/user_sessions_controller.rb
|
155
155
|
- app/mailers/alchemy/notifications.rb
|
156
156
|
- app/models/alchemy/user.rb
|
157
|
+
- app/views/alchemy/admin/passwords/edit.html.erb
|
158
|
+
- app/views/alchemy/admin/passwords/new.html.erb
|
159
|
+
- app/views/alchemy/admin/user_sessions/new.html.erb
|
157
160
|
- app/views/alchemy/admin/users/_fields.html.erb
|
158
161
|
- app/views/alchemy/admin/users/_user.html.erb
|
159
162
|
- app/views/alchemy/admin/users/edit.html.erb
|
@@ -172,9 +175,6 @@ files:
|
|
172
175
|
- app/views/alchemy/notifications/reset_password_instructions.en.text.erb
|
173
176
|
- app/views/alchemy/notifications/reset_password_instructions.es.text.erb
|
174
177
|
- app/views/alchemy/notifications/reset_password_instructions.ru.text.erb
|
175
|
-
- app/views/alchemy/passwords/edit.html.erb
|
176
|
-
- app/views/alchemy/passwords/new.html.erb
|
177
|
-
- app/views/alchemy/user_sessions/new.html.erb
|
178
178
|
- config/initializers/alchemy.rb
|
179
179
|
- config/routes.rb
|
180
180
|
- config/spring.rb
|
@@ -210,8 +210,9 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
210
210
|
- !ruby/object:Gem::Version
|
211
211
|
version: '0'
|
212
212
|
requirements: []
|
213
|
-
rubygems_version: 3.
|
214
|
-
signing_key:
|
213
|
+
rubygems_version: 3.1.4
|
214
|
+
signing_key:
|
215
215
|
specification_version: 4
|
216
216
|
summary: Devise based user authentication for AlchemyCMS.
|
217
217
|
test_files: []
|
218
|
+
...
|
@@ -1,31 +0,0 @@
|
|
1
|
-
module Alchemy
|
2
|
-
class PasswordsController < ::Devise::PasswordsController
|
3
|
-
include Alchemy::Admin::Locale
|
4
|
-
|
5
|
-
before_action { enforce_ssl if ssl_required? && !request.ssl? }
|
6
|
-
|
7
|
-
helper 'Alchemy::Admin::Base'
|
8
|
-
|
9
|
-
layout 'alchemy/admin'
|
10
|
-
|
11
|
-
private
|
12
|
-
|
13
|
-
# Override for Devise method
|
14
|
-
def new_session_path(resource_name)
|
15
|
-
alchemy.login_path
|
16
|
-
end
|
17
|
-
|
18
|
-
def edit_password_url(resource, options={})
|
19
|
-
alchemy.edit_password_url(options)
|
20
|
-
end
|
21
|
-
|
22
|
-
def after_resetting_password_path_for(resource)
|
23
|
-
if can? :index, :alchemy_admin_dashboard
|
24
|
-
alchemy.admin_dashboard_path
|
25
|
-
else
|
26
|
-
alchemy.root_path
|
27
|
-
end
|
28
|
-
end
|
29
|
-
|
30
|
-
end
|
31
|
-
end
|
@@ -1,62 +0,0 @@
|
|
1
|
-
module Alchemy
|
2
|
-
class UserSessionsController < ::Devise::SessionsController
|
3
|
-
include Alchemy::Admin::Locale
|
4
|
-
|
5
|
-
protect_from_forgery prepend: true
|
6
|
-
|
7
|
-
before_action except: 'destroy' do
|
8
|
-
enforce_ssl if ssl_required? && !request.ssl?
|
9
|
-
end
|
10
|
-
|
11
|
-
before_action :check_user_count, :only => :new
|
12
|
-
|
13
|
-
helper 'Alchemy::Admin::Base'
|
14
|
-
|
15
|
-
layout 'alchemy/admin'
|
16
|
-
|
17
|
-
def new
|
18
|
-
super
|
19
|
-
end
|
20
|
-
|
21
|
-
def create
|
22
|
-
authenticate_user!
|
23
|
-
|
24
|
-
if user_signed_in?
|
25
|
-
if session[:redirect_path].blank?
|
26
|
-
redirect_path = admin_dashboard_path
|
27
|
-
else
|
28
|
-
# We have to strip double slashes from beginning of path, because of strange rails/rack bug.
|
29
|
-
redirect_path = session[:redirect_path].gsub(/\A\/{2,}/, '/')
|
30
|
-
end
|
31
|
-
redirect_to redirect_path,
|
32
|
-
notice: t(:signed_in, scope: 'devise.sessions')
|
33
|
-
else
|
34
|
-
super
|
35
|
-
end
|
36
|
-
end
|
37
|
-
|
38
|
-
def destroy
|
39
|
-
current_alchemy_user.try(:unlock_pages!)
|
40
|
-
cookies.clear
|
41
|
-
session.clear
|
42
|
-
super
|
43
|
-
end
|
44
|
-
|
45
|
-
private
|
46
|
-
|
47
|
-
def check_user_count
|
48
|
-
if User.count == 0
|
49
|
-
redirect_to admin_signup_path
|
50
|
-
end
|
51
|
-
end
|
52
|
-
|
53
|
-
# Overwriting the default of Devise
|
54
|
-
def after_sign_out_path_for(resource_or_scope)
|
55
|
-
if request.referer.blank? || request.referer.to_s =~ /admin/
|
56
|
-
root_path
|
57
|
-
else
|
58
|
-
request.referer
|
59
|
-
end
|
60
|
-
end
|
61
|
-
end
|
62
|
-
end
|