alchemy-devise 4.4.0 → 4.5.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (24) hide show
  1. checksums.yaml +4 -4
  2. data/app/controllers/alchemy/admin/passwords_controller.rb +33 -0
  3. data/app/controllers/alchemy/admin/user_sessions_controller.rb +60 -0
  4. data/app/mailers/alchemy/notifications.rb +1 -1
  5. data/app/views/alchemy/{passwords → admin/passwords}/edit.html.erb +2 -2
  6. data/app/views/alchemy/{passwords → admin/passwords}/new.html.erb +2 -2
  7. data/app/views/alchemy/{user_sessions → admin/user_sessions}/new.html.erb +1 -1
  8. data/app/views/alchemy/notifications/alchemy_user_created.de.text.erb +1 -1
  9. data/app/views/alchemy/notifications/alchemy_user_created.en.text.erb +1 -1
  10. data/app/views/alchemy/notifications/alchemy_user_created.es.text.erb +1 -1
  11. data/app/views/alchemy/notifications/alchemy_user_created.ru.text.erb +1 -1
  12. data/app/views/alchemy/notifications/member_created.de.text.erb +1 -1
  13. data/app/views/alchemy/notifications/member_created.en.text.erb +1 -1
  14. data/app/views/alchemy/notifications/member_created.es.text.erb +1 -1
  15. data/app/views/alchemy/notifications/member_created.ru.text.erb +1 -1
  16. data/app/views/alchemy/notifications/reset_password_instructions.de.text.erb +1 -1
  17. data/app/views/alchemy/notifications/reset_password_instructions.en.text.erb +1 -1
  18. data/app/views/alchemy/notifications/reset_password_instructions.es.text.erb +1 -1
  19. data/app/views/alchemy/notifications/reset_password_instructions.ru.text.erb +1 -1
  20. data/config/routes.rb +19 -14
  21. data/lib/alchemy/devise/version.rb +1 -1
  22. metadata +7 -7
  23. data/app/controllers/alchemy/passwords_controller.rb +0 -31
  24. 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: 7e352204aef8262b7a4b3cffe5ef3e7a58781194d777a481c3b99300f92499d6
4
- data.tar.gz: 6fa7ec4f94b5333fe8cad0897f821d80fedb297f932f4d904cbd4eeecce5cd2b
3
+ metadata.gz: 4c558baf798de77b122ba7e53c5facb2e57a5a72ae351f2b0d967104fe945c04
4
+ data.tar.gz: e27c4781ec9348d8bdcbc77abeed7584e64fe8facfbd943b133fb5e362bf1701
5
5
  SHA512:
6
- metadata.gz: 2b6ac50b6a59132a6232a481da65290dc7500f7ab44397cfce25df98ef28d2609340e65edc190d9dca48e74409b5a3eb394aa5f015f8e72f134fcb2b0d1f025c
7
- data.tar.gz: bba4952131d61b8f33ec9670ffa9a2178ebe6095e52453f27e2c604b0918d9b528fd09d1f32a3f7d8a2a7896525b1f85004b695c04b0687a4a3066516a761cfe
6
+ metadata.gz: 789bc60a8330c5690a4641ecdb558e4268bec99f6e92cdded7e9a0edd25f478201974ef9091b9571bff777ae3a76cd093dfbf0069ba8e58c1c7e0dd0c9b5c619
7
+ data.tar.gz: a469f6d79fdb3bde9edeff1e2d077006e46a1c998b78d4f3515ead33fe462fdcadc0069de50a6f07e4c70aefc3584dd45d4d2ec89e2b0c7a4691a5521614f631
@@ -0,0 +1,33 @@
1
+ module Alchemy
2
+ module Admin
3
+ class PasswordsController < ::Devise::PasswordsController
4
+ include Alchemy::Admin::Locale
5
+
6
+ before_action { enforce_ssl if ssl_required? && !request.ssl? }
7
+
8
+ helper 'Alchemy::Admin::Base'
9
+
10
+ layout 'alchemy/admin'
11
+
12
+ private
13
+
14
+ # Override for Devise method
15
+ def new_session_path(resource_name)
16
+ alchemy.admin_login_path
17
+ end
18
+
19
+ def admin_edit_password_url(resource, options={})
20
+ alchemy.admin_edit_password_url(options)
21
+ end
22
+
23
+ def after_resetting_password_path_for(resource)
24
+ if can? :index, :alchemy_admin_dashboard
25
+ alchemy.admin_dashboard_path
26
+ else
27
+ alchemy.root_path
28
+ end
29
+ end
30
+
31
+ end
32
+ end
33
+ end
@@ -0,0 +1,60 @@
1
+ module Alchemy
2
+ module Admin
3
+ class UserSessionsController < ::Devise::SessionsController
4
+ include Alchemy::Admin::Locale
5
+
6
+ protect_from_forgery prepend: true
7
+
8
+ before_action except: 'destroy' do
9
+ enforce_ssl if ssl_required? && !request.ssl?
10
+ end
11
+
12
+ before_action :check_user_count, :only => :new
13
+
14
+ helper 'Alchemy::Admin::Base'
15
+
16
+ layout 'alchemy/admin'
17
+
18
+ def create
19
+ authenticate_user!
20
+
21
+ if user_signed_in?
22
+ if session[:redirect_path].blank?
23
+ redirect_path = admin_dashboard_path
24
+ else
25
+ # We have to strip double slashes from beginning of path, because of strange rails/rack bug.
26
+ redirect_path = session[:redirect_path].gsub(/\A\/{2,}/, '/')
27
+ end
28
+ redirect_to redirect_path,
29
+ notice: t(:signed_in, scope: 'devise.sessions')
30
+ else
31
+ super
32
+ end
33
+ end
34
+
35
+ def destroy
36
+ current_alchemy_user.try(:unlock_pages!)
37
+ cookies.clear
38
+ session.clear
39
+ super
40
+ end
41
+
42
+ private
43
+
44
+ def check_user_count
45
+ if User.count == 0
46
+ redirect_to admin_signup_path
47
+ end
48
+ end
49
+
50
+ # Overwriting the default of Devise
51
+ def after_sign_out_path_for(resource_or_scope)
52
+ if request.referer.blank? || request.referer.to_s =~ /admin/
53
+ root_path
54
+ else
55
+ request.referer
56
+ end
57
+ end
58
+ end
59
+ end
60
+ end
@@ -5,7 +5,7 @@ module Alchemy
5
5
 
6
6
  def member_created(user)
7
7
  @user = user
8
- @url = login_url
8
+
9
9
  mail(
10
10
  to: user.email,
11
11
  subject: Alchemy.t("Your user credentials")
@@ -10,13 +10,13 @@
10
10
  <%= devise_error_messages! %>
11
11
  </div>
12
12
  <% end %>
13
- <%= alchemy_form_for resource, as: resource_name, url: update_password_path, method: 'patch' do |f| %>
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.login_path %>
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: reset_password_path, html: {method: 'post'} do |f| %>
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.login_path %>
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'} %>
@@ -5,7 +5,7 @@
5
5
  <%= f.input :password %>
6
6
  <div class="input link">
7
7
  <small>
8
- <%= link_to Alchemy.t('Forgot your password?'), new_password_path %>
8
+ <%= link_to Alchemy.t('Forgot your password?'), admin_new_password_path %>
9
9
  </small>
10
10
  </div>
11
11
  <div class="submit">
@@ -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.new_password_url %>
13
+ <%= alchemy.admin_new_password_url %>
14
14
 
15
15
  Viel Spaß mit Alchemy!
@@ -10,6 +10,6 @@ For security reasons we do not show your password here.
10
10
 
11
11
  If you forgot your password or this is your first login, please goto:
12
12
 
13
- <%= alchemy.new_password_url %>
13
+ <%= alchemy.admin_new_password_url %>
14
14
 
15
15
  Have much fun with Alchemy!
@@ -10,6 +10,6 @@ Por razones de seguridad no mostraremos aquí tu contraseña.
10
10
 
11
11
  Si has olvidado tu contraseña o es tu primer acceso, por favor, accede a:
12
12
 
13
- <%= alchemy.new_password_url %>
13
+ <%= alchemy.admin_new_password_url %>
14
14
 
15
15
  ¡Disfruta de tu web con Alchemy!
@@ -10,6 +10,6 @@
10
10
 
11
11
  Если вы забыли ваш пароль или если это ваш первый визит, пожалуйста, перейдите по ссылке:
12
12
 
13
- <%= alchemy.new_password_url %>
13
+ <%= alchemy.admin_new_password_url %>
14
14
 
15
15
  Наслаждайтесь использованием 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.new_password_url(email: @user.email) %>
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.new_password_url(email: @user.email) %>
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.new_password_url(email: @user.email) %>
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.new_password_url(email: @user.email) %>
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.edit_password_url(@user, reset_password_token: @token) %>
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.edit_password_url(@user, reset_password_token: @token) %>
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.edit_password_url(@user, reset_password_token: @token) %>
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.edit_password_url(@user, reset_password_token: @token) %>
5
+ <%= alchemy.admin_edit_password_url(@user, reset_password_token: @token) %>
6
6
 
7
7
  Если вы не делали запрос, просто проигнорируйте это письмо.
8
8
  Ваш пароль не изменится до тех пор, пока вы не перейдете по ссылке и сами не измените его.
@@ -1,22 +1,29 @@
1
1
  Alchemy::Engine.routes.draw do
2
- devise_for :user,
3
- class_name: 'Alchemy::User',
4
- controllers: {
5
- sessions: 'alchemy/user_sessions'
6
- },
7
- skip: [:sessions, :passwords]
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' => 'admin/dashboard#index',
18
+ get '/dashboard' => 'dashboard#index',
12
19
  :as => :user_root
13
- get '/signup' => 'admin/users#signup',
14
- :as => :admin_signup
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
- delete '/logout' => 'user_sessions#destroy',
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
@@ -1,5 +1,5 @@
1
1
  module Alchemy
2
2
  module Devise
3
- VERSION = "4.4.0"
3
+ VERSION = "4.5.0"
4
4
  end
5
5
  end
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.4.0
4
+ version: 4.5.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Thomas von Deyen
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2020-01-09 00:00:00.000000000 Z
11
+ date: 2020-04-04 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: alchemy_cms
@@ -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
@@ -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