alchemy-devise 6.2.0 → 7.0.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG.md +10 -0
- data/README.md +2 -1
- data/app/controllers/alchemy/admin/user_sessions_controller.rb +4 -4
- data/app/controllers/alchemy/admin/users_controller.rb +5 -6
- data/app/mailers/alchemy/notifications.rb +2 -3
- data/app/models/alchemy/user.rb +4 -4
- data/config/initializers/alchemy.rb +2 -2
- data/config/routes.rb +13 -14
- data/config/spring.rb +1 -1
- data/db/migrate/20131015124700_create_alchemy_users.rb +17 -17
- data/lib/alchemy/devise/engine.rb +6 -6
- data/lib/alchemy/devise/test_support/factories.rb +8 -8
- data/lib/alchemy/devise/version.rb +1 -1
- data/lib/alchemy/devise.rb +2 -2
- data/lib/generators/alchemy/devise/install/install_generator.rb +4 -4
- metadata +5 -5
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: bd6b7560905c561c9ac5c33a5d06b52fe9d39387037c7c9c6a0c783bf6d7d84f
|
4
|
+
data.tar.gz: f7ab01665f1d69d4fa948c2b949a1463d728777fd0d803565756c440f125e65a
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 8264ef086327c7949c32c647d218d4de031db097ede9ebe394e355015510e39f20bb98848474580082bccc8b932780595006e2bde3f1648a0e13424986ee5b4c
|
7
|
+
data.tar.gz: 270a29faebfd1fc2f3edfc3eab41e8d436a362ab2c6fd7e1607161146b1c8b4cb0480853b906ba35fb38dbd9ec2e25b614c69a8b27daaf58008fb959a6884b9d
|
data/CHANGELOG.md
CHANGED
@@ -1,5 +1,15 @@
|
|
1
1
|
# Changelog
|
2
2
|
|
3
|
+
## 7.0.0 (2023-07-05)
|
4
|
+
|
5
|
+
- Update to Alchemy 7.0 [#173](https://github.com/AlchemyCMS/alchemy-devise/pull/173) ([tvdeyen](https://github.com/tvdeyen))
|
6
|
+
|
7
|
+
## 6.3.0 (2023-07-05)
|
8
|
+
|
9
|
+
- Remove Alchemy 7.0 and 6.0 support [#174](https://github.com/AlchemyCMS/alchemy-devise/pull/174) ([tvdeyen](https://github.com/tvdeyen))
|
10
|
+
- Use standard.rb to lint code [#166](https://github.com/AlchemyCMS/alchemy-devise/pull/166) ([tvdeyen](https://github.com/tvdeyen))
|
11
|
+
- Update brakeman scan action [#165](https://github.com/AlchemyCMS/alchemy-devise/pull/165) ([tvdeyen](https://github.com/tvdeyen))
|
12
|
+
|
3
13
|
## 6.2.0 (2023-04-01)
|
4
14
|
|
5
15
|
- Add Alchemy 7 support [#164](https://github.com/AlchemyCMS/alchemy-devise/pull/164) ([tvdeyen](https://github.com/tvdeyen))
|
data/README.md
CHANGED
@@ -1,8 +1,9 @@
|
|
1
1
|
## Devise based authentication for AlchemyCMS
|
2
2
|
|
3
3
|
[![Build Status](https://github.com/AlchemyCMS/alchemy-devise/workflows/CI/badge.svg?branch=main)](https://github.com/AlchemyCMS/alchemy-devise/actions)
|
4
|
+
[![Brakeman Scan](https://github.com/AlchemyCMS/alchemy-devise/actions/workflows/brakeman-analysis.yml/badge.svg)](https://github.com/AlchemyCMS/alchemy-devise/actions/workflows/brakeman-analysis.yml)
|
4
5
|
|
5
|
-
[![Gem Version](https://badge.fury.io/rb/alchemy-devise.svg)](http://badge.fury.io/rb/alchemy-devise) [![Test Coverage](https://codeclimate.com/github/AlchemyCMS/alchemy-devise/badges/coverage.svg)](https://codeclimate.com/github/AlchemyCMS/alchemy-devise/coverage) [![Code Climate](https://codeclimate.com/github/AlchemyCMS/alchemy-devise/badges/gpa.svg)](https://codeclimate.com/github/AlchemyCMS/alchemy-devise)
|
6
|
+
[![Gem Version](https://badge.fury.io/rb/alchemy-devise.svg)](http://badge.fury.io/rb/alchemy-devise) [![Test Coverage](https://codeclimate.com/github/AlchemyCMS/alchemy-devise/badges/coverage.svg)](https://codeclimate.com/github/AlchemyCMS/alchemy-devise/coverage) [![Code Climate](https://codeclimate.com/github/AlchemyCMS/alchemy-devise/badges/gpa.svg)](https://codeclimate.com/github/AlchemyCMS/alchemy-devise)
|
6
7
|
|
7
8
|
AlchemyCMS has no authentication in its core. So it is possible to bring your own authentication and use it to authorize users in AlchemyCMS. If you don't have your own authentication, you can use this gem.
|
8
9
|
|
@@ -9,7 +9,7 @@ module Alchemy
|
|
9
9
|
|
10
10
|
protect_from_forgery prepend: true
|
11
11
|
|
12
|
-
before_action :check_user_count, :
|
12
|
+
before_action :check_user_count, only: :new
|
13
13
|
|
14
14
|
helper "Alchemy::Admin::Base"
|
15
15
|
|
@@ -19,11 +19,11 @@ module Alchemy
|
|
19
19
|
authenticate_user!
|
20
20
|
|
21
21
|
if user_signed_in?
|
22
|
-
if session[:redirect_path].blank?
|
23
|
-
|
22
|
+
redirect_path = if session[:redirect_path].blank?
|
23
|
+
admin_dashboard_path
|
24
24
|
else
|
25
25
|
# We have to strip double slashes from beginning of path, because of strange rails/rack bug.
|
26
|
-
|
26
|
+
session[:redirect_path].gsub(/\A\/{2,}/, "/")
|
27
27
|
end
|
28
28
|
redirect_to redirect_path,
|
29
29
|
notice: t(:signed_in, scope: "devise.sessions")
|
@@ -1,7 +1,6 @@
|
|
1
1
|
module Alchemy
|
2
2
|
module Admin
|
3
3
|
class UsersController < ResourcesController
|
4
|
-
|
5
4
|
before_action :set_roles, except: [:index, :destroy]
|
6
5
|
|
7
6
|
load_and_authorize_resource class: Alchemy::User,
|
@@ -14,7 +13,7 @@ module Alchemy
|
|
14
13
|
|
15
14
|
def index
|
16
15
|
@query = User.ransack(params[:q])
|
17
|
-
@query.sorts =
|
16
|
+
@query.sorts = "login asc" if @query.sorts.empty?
|
18
17
|
@users = @query.result
|
19
18
|
.page(params[:page] || 1)
|
20
19
|
.per(items_per_page)
|
@@ -53,7 +52,7 @@ module Alchemy
|
|
53
52
|
deliver_welcome_mail
|
54
53
|
render_errors_or_redirect @user,
|
55
54
|
admin_users_path,
|
56
|
-
Alchemy.t("User updated", :
|
55
|
+
Alchemy.t("User updated", name: @user.name)
|
57
56
|
end
|
58
57
|
|
59
58
|
def destroy
|
@@ -92,9 +91,9 @@ module Alchemy
|
|
92
91
|
end
|
93
92
|
|
94
93
|
def signup_admin_or_redirect
|
95
|
-
@user.alchemy_roles = %w
|
94
|
+
@user.alchemy_roles = %w[admin]
|
96
95
|
if @user.save
|
97
|
-
flash[:notice] = Alchemy.t(
|
96
|
+
flash[:notice] = Alchemy.t("Successfully signup admin user")
|
98
97
|
sign_in :user, @user
|
99
98
|
deliver_welcome_mail
|
100
99
|
redirect_to admin_pages_path
|
@@ -116,7 +115,7 @@ module Alchemy
|
|
116
115
|
end
|
117
116
|
|
118
117
|
def deliver_welcome_mail
|
119
|
-
if @user.valid? && @user.send_credentials ==
|
118
|
+
if @user.valid? && @user.send_credentials == "1"
|
120
119
|
@user.deliver_welcome_mail
|
121
120
|
end
|
122
121
|
end
|
@@ -1,7 +1,6 @@
|
|
1
1
|
module Alchemy
|
2
2
|
class Notifications < ActionMailer::Base
|
3
|
-
|
4
|
-
default(from: Config.get(:mailer)['mail_from'])
|
3
|
+
default(from: Config.get(:mailer)["mail_from"])
|
5
4
|
|
6
5
|
def member_created(user)
|
7
6
|
@user = user
|
@@ -21,7 +20,7 @@ module Alchemy
|
|
21
20
|
)
|
22
21
|
end
|
23
22
|
|
24
|
-
def reset_password_instructions(user, token, opts={})
|
23
|
+
def reset_password_instructions(user, token, opts = {})
|
25
24
|
@user = user
|
26
25
|
@token = token
|
27
26
|
mail(
|
data/app/models/alchemy/user.rb
CHANGED
@@ -14,10 +14,10 @@ module Alchemy
|
|
14
14
|
:password,
|
15
15
|
:password_confirmation,
|
16
16
|
:send_credentials,
|
17
|
-
:tag_list
|
17
|
+
:tag_list
|
18
18
|
]
|
19
19
|
|
20
|
-
devise
|
20
|
+
devise(*Alchemy.devise_modules)
|
21
21
|
|
22
22
|
include Alchemy::Taggable
|
23
23
|
|
@@ -86,7 +86,7 @@ module Alchemy
|
|
86
86
|
end
|
87
87
|
|
88
88
|
def add_role(role)
|
89
|
-
self.alchemy_roles =
|
89
|
+
self.alchemy_roles = alchemy_roles.push(role.to_s).uniq
|
90
90
|
end
|
91
91
|
|
92
92
|
# Returns true if the user ahs admin role
|
@@ -127,7 +127,7 @@ module Alchemy
|
|
127
127
|
if lastname.blank? && firstname.blank?
|
128
128
|
login
|
129
129
|
else
|
130
|
-
options = {
|
130
|
+
options = {flipped: false}.merge(options)
|
131
131
|
fullname = options[:flipped] ? "#{lastname}, #{firstname}" : "#{firstname} #{lastname}"
|
132
132
|
fullname.squeeze(" ").strip
|
133
133
|
end
|
data/config/routes.rb
CHANGED
@@ -3,35 +3,34 @@ Alchemy::Engine.routes.draw do
|
|
3
3
|
path: Alchemy.admin_path,
|
4
4
|
constraints: Alchemy.admin_constraints
|
5
5
|
} do
|
6
|
-
|
7
6
|
devise_for :user,
|
8
|
-
class_name:
|
7
|
+
class_name: "Alchemy::User",
|
9
8
|
singular: :user,
|
10
9
|
skip: :all,
|
11
10
|
controllers: {
|
12
|
-
sessions:
|
13
|
-
passwords:
|
11
|
+
sessions: "alchemy/admin/user_sessions",
|
12
|
+
passwords: "alchemy/admin/passwords"
|
14
13
|
},
|
15
14
|
router_name: :alchemy
|
16
15
|
|
17
16
|
devise_scope :user do
|
18
|
-
get
|
17
|
+
get "/dashboard" => "dashboard#index",
|
19
18
|
:as => :user_root
|
20
|
-
get
|
19
|
+
get "/signup" => "users#signup",
|
21
20
|
:as => :signup
|
22
|
-
get
|
21
|
+
get "/login" => "user_sessions#new",
|
23
22
|
:as => :login
|
24
|
-
post
|
25
|
-
match
|
26
|
-
:as => :logout, via
|
23
|
+
post "/login" => "user_sessions#create"
|
24
|
+
match "/logout" => "user_sessions#destroy",
|
25
|
+
:as => :logout, :via => Devise.sign_out_via
|
27
26
|
|
28
|
-
get
|
27
|
+
get "/passwords" => "passwords#new",
|
29
28
|
:as => :new_password
|
30
|
-
get
|
29
|
+
get "/passwords/:id/edit/:reset_password_token" => "passwords#edit",
|
31
30
|
:as => :edit_password
|
32
|
-
post
|
31
|
+
post "/passwords" => "passwords#create",
|
33
32
|
:as => :reset_password
|
34
|
-
patch
|
33
|
+
patch "/passwords" => "passwords#update",
|
35
34
|
:as => :update_password
|
36
35
|
end
|
37
36
|
|
data/config/spring.rb
CHANGED
@@ -1 +1 @@
|
|
1
|
-
Spring.application_root =
|
1
|
+
Spring.application_root = "spec/dummy"
|
@@ -2,26 +2,26 @@ class CreateAlchemyUsers < ActiveRecord::Migration[4.2]
|
|
2
2
|
def up
|
3
3
|
return if table_exists?(:alchemy_users)
|
4
4
|
create_table "alchemy_users" do |t|
|
5
|
-
t.string
|
6
|
-
t.string
|
7
|
-
t.string
|
8
|
-
t.string
|
9
|
-
t.string
|
10
|
-
t.string
|
11
|
-
t.string
|
12
|
-
t.integer
|
13
|
-
t.integer
|
5
|
+
t.string "firstname"
|
6
|
+
t.string "lastname"
|
7
|
+
t.string "login"
|
8
|
+
t.string "email"
|
9
|
+
t.string "language"
|
10
|
+
t.string "encrypted_password", limit: 128, default: "", null: false
|
11
|
+
t.string "password_salt", limit: 128, default: "", null: false
|
12
|
+
t.integer "sign_in_count", default: 0, null: false
|
13
|
+
t.integer "failed_attempts", default: 0, null: false
|
14
14
|
t.datetime "last_request_at"
|
15
15
|
t.datetime "current_sign_in_at"
|
16
16
|
t.datetime "last_sign_in_at"
|
17
|
-
t.string
|
18
|
-
t.string
|
19
|
-
t.datetime "created_at",
|
20
|
-
t.datetime "updated_at",
|
21
|
-
t.integer
|
22
|
-
t.integer
|
23
|
-
t.text
|
24
|
-
t.string
|
17
|
+
t.string "current_sign_in_ip"
|
18
|
+
t.string "last_sign_in_ip"
|
19
|
+
t.datetime "created_at", null: false
|
20
|
+
t.datetime "updated_at", null: false
|
21
|
+
t.integer "creator_id"
|
22
|
+
t.integer "updater_id"
|
23
|
+
t.text "cached_tag_list"
|
24
|
+
t.string "reset_password_token"
|
25
25
|
t.datetime "reset_password_sent_at"
|
26
26
|
end
|
27
27
|
|
@@ -1,24 +1,24 @@
|
|
1
|
-
require
|
2
|
-
require
|
1
|
+
require "alchemy_cms"
|
2
|
+
require "devise"
|
3
3
|
|
4
4
|
module Alchemy
|
5
5
|
module Devise
|
6
6
|
class Engine < ::Rails::Engine
|
7
7
|
isolate_namespace Alchemy
|
8
|
-
engine_name
|
8
|
+
engine_name "alchemy_devise"
|
9
9
|
|
10
10
|
initializer "alchemy_devise.user_class", before: "alchemy.userstamp" do
|
11
11
|
Alchemy.user_class_name = "Alchemy::User"
|
12
12
|
end
|
13
13
|
|
14
|
-
initializer
|
14
|
+
initializer "alchemy_devise.assets" do |app|
|
15
15
|
app.config.assets.precompile += [
|
16
|
-
|
16
|
+
"alchemy-devise.css"
|
17
17
|
]
|
18
18
|
end
|
19
19
|
|
20
20
|
config.to_prepare do
|
21
|
-
require_relative
|
21
|
+
require_relative "../../../app/controllers/alchemy/base_controller_extension"
|
22
22
|
end
|
23
23
|
end
|
24
24
|
end
|
@@ -4,25 +4,25 @@ FactoryBot.define do
|
|
4
4
|
factory :alchemy_user, class: Alchemy::User do
|
5
5
|
sequence(:login) { |n| "john_#{n}.doe" }
|
6
6
|
sequence(:email) { |n| "john_#{n}@doe.com" }
|
7
|
-
firstname {
|
8
|
-
lastname {
|
9
|
-
password {
|
10
|
-
password_confirmation {
|
7
|
+
firstname { "John" }
|
8
|
+
lastname { "Doe" }
|
9
|
+
password { "s3cr3t" }
|
10
|
+
password_confirmation { "s3cr3t" }
|
11
11
|
|
12
12
|
factory :alchemy_admin_user do
|
13
|
-
alchemy_roles {
|
13
|
+
alchemy_roles { "admin" }
|
14
14
|
end
|
15
15
|
|
16
16
|
factory :alchemy_member_user do
|
17
|
-
alchemy_roles {
|
17
|
+
alchemy_roles { "member" }
|
18
18
|
end
|
19
19
|
|
20
20
|
factory :alchemy_author_user do
|
21
|
-
alchemy_roles {
|
21
|
+
alchemy_roles { "author" }
|
22
22
|
end
|
23
23
|
|
24
24
|
factory :alchemy_editor_user do
|
25
|
-
alchemy_roles {
|
25
|
+
alchemy_roles { "editor" }
|
26
26
|
end
|
27
27
|
end
|
28
28
|
end
|
data/lib/alchemy/devise.rb
CHANGED
@@ -6,12 +6,12 @@ module Alchemy
|
|
6
6
|
# === Default modules
|
7
7
|
#
|
8
8
|
# [
|
9
|
-
|
9
|
+
# . :database_authenticatable,
|
10
10
|
# :trackable,
|
11
11
|
# :validatable,
|
12
12
|
# :timeoutable,
|
13
13
|
# :recoverable
|
14
|
-
|
14
|
+
# . ]
|
15
15
|
#
|
16
16
|
# If you want to add additional modules into the Alchemy user class append
|
17
17
|
# them to this collection in an initializer in your app.
|
@@ -3,18 +3,18 @@ module Alchemy
|
|
3
3
|
module Generators
|
4
4
|
class InstallGenerator < Rails::Generators::Base
|
5
5
|
desc "Installs Alchemy Devise based authentication into your app."
|
6
|
-
source_root File.expand_path(
|
6
|
+
source_root File.expand_path("templates", File.dirname(__FILE__))
|
7
7
|
|
8
8
|
def copy_devise_config
|
9
|
-
template
|
9
|
+
template "devise.rb.tt", "config/initializers/devise.rb"
|
10
10
|
end
|
11
11
|
|
12
12
|
def add_migrations
|
13
|
-
run
|
13
|
+
run "bundle exec rake alchemy_devise:install:migrations"
|
14
14
|
end
|
15
15
|
|
16
16
|
def run_migrations
|
17
|
-
run
|
17
|
+
run "bundle exec rake db:migrate"
|
18
18
|
end
|
19
19
|
|
20
20
|
def append_assets
|
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: 7.0.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: 2023-
|
11
|
+
date: 2023-07-05 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: alchemy_cms
|
@@ -16,7 +16,7 @@ dependencies:
|
|
16
16
|
requirements:
|
17
17
|
- - ">="
|
18
18
|
- !ruby/object:Gem::Version
|
19
|
-
version:
|
19
|
+
version: 7.0.0.pre.rc1
|
20
20
|
- - "<"
|
21
21
|
- !ruby/object:Gem::Version
|
22
22
|
version: '8'
|
@@ -26,7 +26,7 @@ dependencies:
|
|
26
26
|
requirements:
|
27
27
|
- - ">="
|
28
28
|
- !ruby/object:Gem::Version
|
29
|
-
version:
|
29
|
+
version: 7.0.0.pre.rc1
|
30
30
|
- - "<"
|
31
31
|
- !ruby/object:Gem::Version
|
32
32
|
version: '8'
|
@@ -210,7 +210,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
210
210
|
- !ruby/object:Gem::Version
|
211
211
|
version: '0'
|
212
212
|
requirements: []
|
213
|
-
rubygems_version: 3.4.
|
213
|
+
rubygems_version: 3.4.15
|
214
214
|
signing_key:
|
215
215
|
specification_version: 4
|
216
216
|
summary: Devise based user authentication for AlchemyCMS.
|