alchemy-devise 6.1.0 → 6.2.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: f58d46b9126aecea12b501b449de4effd33b1c5eccf18f82937a5662c35469a4
4
- data.tar.gz: 46bf5120a6e8d2dcb536ba407d6bfcf1572164833b789752d9f58e8c84713914
3
+ metadata.gz: 037e618a3f66b84599f6e3dd9c9ee7ac2b5eccafad82df24e7a2deac4e277cfc
4
+ data.tar.gz: 8bc2d3e03a28e5a570aace97412aae02055f6ba2fdfa3730598749081bcac8d8
5
5
  SHA512:
6
- metadata.gz: 101acd9fa3dde21bf274bf493e6b9f9e801d47d7e988e01f3cef86fd813951cb291268f9690e06c89a9c1d881a625e9306fd0fc8d1f3b5e485479dcbbe12852f
7
- data.tar.gz: 033a6f2df8c32e7281c0b5dd55309947cf0400cfd87ba1703a43c5ab25b098c82ef65edd739750c9fabbf499765d487d7663068fd69a95fbc4fc6a2430f49580
6
+ metadata.gz: c577818f7db36c4a5bd4147f878ef8a63d511fdd42573e97b54212742e6aaafe960ad039b8cfb7ce90683f240c385508b881d070240c70e1bb1704b7ad754725
7
+ data.tar.gz: db8f25a255b6b700b414d7ca0b154f3fd35de04941e5e286cfee2069c2630670532aab28e56d6a925427fe3ce8f0d55ba5faa265d7815e5a00b989e98e933fd6
data/CHANGELOG.md CHANGED
@@ -1,5 +1,10 @@
1
1
  # Changelog
2
2
 
3
+ ## 6.2.0 (2023-04-01)
4
+
5
+ - Add Alchemy 7 support [#164](https://github.com/AlchemyCMS/alchemy-devise/pull/164) ([tvdeyen](https://github.com/tvdeyen))
6
+ - Upgrade rspec-rails to version 6.0.1 [#153](https://github.com/AlchemyCMS/alchemy-devise/pull/153) ([depfu](https://github.com/apps/depfu))
7
+
3
8
  ## 6.1.0 (2023-01-20)
4
9
 
5
10
  - Remove Alchemy 5.3 support [#158](https://github.com/AlchemyCMS/alchemy-devise/pull/158) ([tvdeyen](https://github.com/tvdeyen))
@@ -7,10 +7,6 @@ module Alchemy
7
7
  class PasswordsController < ::Devise::PasswordsController
8
8
  include Alchemy::Admin::Locale
9
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
10
  helper "Alchemy::Admin::Base"
15
11
 
16
12
  layout "alchemy/admin"
@@ -9,11 +9,6 @@ module Alchemy
9
9
 
10
10
  protect_from_forgery prepend: true
11
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
12
  before_action :check_user_count, :only => :new
18
13
 
19
14
  helper "Alchemy::Admin::Base"
@@ -1,5 +1,7 @@
1
- require 'devise/orm/active_record'
2
- require 'userstamp'
1
+ # frozen_string_literal: true
2
+
3
+ require "devise/orm/active_record"
4
+ require "userstamp"
3
5
 
4
6
  module Alchemy
5
7
  class User < ActiveRecord::Base
@@ -12,7 +14,7 @@ module Alchemy
12
14
  :password,
13
15
  :password_confirmation,
14
16
  :send_credentials,
15
- :tag_list
17
+ :tag_list,
16
18
  ]
17
19
 
18
20
  devise *Alchemy.devise_modules
@@ -29,13 +31,31 @@ module Alchemy
29
31
  # Unlock all locked pages before destroy.
30
32
  before_destroy :unlock_pages!
31
33
 
32
- scope :admins, -> { where(arel_table[:alchemy_roles].matches('%admin%')) }
33
- scope :logged_in, -> { where('last_request_at > ?', logged_in_timeout.seconds.ago) }
34
- scope :logged_out, -> { where('last_request_at is NULL or last_request_at <= ?', logged_in_timeout.seconds.ago) }
34
+ scope :admins, -> { where(arel_table[:alchemy_roles].matches("%admin%")) }
35
+ scope :logged_in, -> { where("last_request_at > ?", logged_in_timeout.seconds.ago) }
36
+ scope :logged_out, -> { where("last_request_at is NULL or last_request_at <= ?", logged_in_timeout.seconds.ago) }
35
37
 
36
38
  ROLES = Config.get(:user_roles)
37
39
 
38
40
  class << self
41
+ def ransackable_attributes(_auth_object = nil)
42
+ %w[
43
+ email
44
+ firstname
45
+ lastname
46
+ login
47
+ ]
48
+ end
49
+
50
+ alias_method :searchable_alchemy_resource_attributes, :ransackable_attributes
51
+
52
+ def ransackable_associations(_auth_object = nil)
53
+ %w[
54
+ taggings
55
+ tags
56
+ ]
57
+ end
58
+
39
59
  def human_rolename(role)
40
60
  Alchemy.t("user_roles.#{role}")
41
61
  end
@@ -43,19 +63,6 @@ module Alchemy
43
63
  def logged_in_timeout
44
64
  Config.get(:auto_logout_time).minutes.to_i
45
65
  end
46
-
47
- # Search users that match query
48
- #
49
- # Attributes searched are: login, email, firstname, lastname
50
- #
51
- def search(query)
52
- query = "%#{query.downcase}%"
53
-
54
- where arel_table[:login].lower.matches(query)
55
- .or arel_table[:email].lower.matches(query)
56
- .or arel_table[:firstname].lower.matches(query)
57
- .or arel_table[:lastname].lower.matches(query)
58
- end
59
66
  end
60
67
 
61
68
  def role_symbols
@@ -67,12 +74,12 @@ module Alchemy
67
74
  end
68
75
 
69
76
  def alchemy_roles
70
- read_attribute(:alchemy_roles).split(' ')
77
+ read_attribute(:alchemy_roles).split(" ")
71
78
  end
72
79
 
73
80
  def alchemy_roles=(roles_string)
74
81
  if roles_string.is_a? Array
75
- write_attribute(:alchemy_roles, roles_string.join(' '))
82
+ write_attribute(:alchemy_roles, roles_string.join(" "))
76
83
  elsif roles_string.is_a? String
77
84
  write_attribute(:alchemy_roles, roles_string)
78
85
  end
@@ -84,8 +91,9 @@ module Alchemy
84
91
 
85
92
  # Returns true if the user ahs admin role
86
93
  def is_admin?
87
- has_role? 'admin'
94
+ has_role? "admin"
88
95
  end
96
+
89
97
  alias_method :admin?, :is_admin?
90
98
 
91
99
  # Returns true if the user has the given role.
@@ -105,6 +113,7 @@ module Alchemy
105
113
  def pages_locked_by_me
106
114
  Page.locked_by(self).order(:updated_at)
107
115
  end
116
+
108
117
  alias_method :locked_pages, :pages_locked_by_me
109
118
 
110
119
  # Returns the firstname and lastname as a string
@@ -118,11 +127,12 @@ module Alchemy
118
127
  if lastname.blank? && firstname.blank?
119
128
  login
120
129
  else
121
- options = {:flipped => false}.merge(options)
130
+ options = { flipped: false }.merge(options)
122
131
  fullname = options[:flipped] ? "#{lastname}, #{firstname}" : "#{firstname} #{lastname}"
123
132
  fullname.squeeze(" ").strip
124
133
  end
125
134
  end
135
+
126
136
  alias_method :name, :fullname
127
137
  alias_method :alchemy_display_name, :fullname
128
138
 
@@ -150,7 +160,7 @@ module Alchemy
150
160
  # Delivers a welcome mail depending from user's role.
151
161
  #
152
162
  def deliver_welcome_mail
153
- if has_role?('author') || has_role?('editor') || has_role?('admin')
163
+ if has_role?("author") || has_role?("editor") || has_role?("admin")
154
164
  Notifications.alchemy_user_created(self).deliver_later
155
165
  else
156
166
  Notifications.member_created(self).deliver_later
@@ -1,5 +1,5 @@
1
1
  module Alchemy
2
2
  module Devise
3
- VERSION = "6.1.0"
3
+ VERSION = "6.2.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: 6.1.0
4
+ version: 6.2.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-01-20 00:00:00.000000000 Z
11
+ date: 2023-04-01 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: alchemy_cms
@@ -19,7 +19,7 @@ dependencies:
19
19
  version: 6.0.0
20
20
  - - "<"
21
21
  - !ruby/object:Gem::Version
22
- version: '7'
22
+ version: '8'
23
23
  type: :runtime
24
24
  prerelease: false
25
25
  version_requirements: !ruby/object:Gem::Requirement
@@ -29,7 +29,7 @@ dependencies:
29
29
  version: 6.0.0
30
30
  - - "<"
31
31
  - !ruby/object:Gem::Version
32
- version: '7'
32
+ version: '8'
33
33
  - !ruby/object:Gem::Dependency
34
34
  name: devise
35
35
  requirement: !ruby/object:Gem::Requirement
@@ -112,14 +112,14 @@ dependencies:
112
112
  requirements:
113
113
  - - "~>"
114
114
  - !ruby/object:Gem::Version
115
- version: 5.1.2
115
+ version: 6.0.1
116
116
  type: :development
117
117
  prerelease: false
118
118
  version_requirements: !ruby/object:Gem::Requirement
119
119
  requirements:
120
120
  - - "~>"
121
121
  - !ruby/object:Gem::Version
122
- version: 5.1.2
122
+ version: 6.0.1
123
123
  - !ruby/object:Gem::Dependency
124
124
  name: simplecov
125
125
  requirement: !ruby/object:Gem::Requirement
@@ -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.3.26
213
+ rubygems_version: 3.4.10
214
214
  signing_key:
215
215
  specification_version: 4
216
216
  summary: Devise based user authentication for AlchemyCMS.