eac_users_support 0.5.1 → 0.6.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/app/models/eac_users_support/user.rb +3 -1
- data/config/locales/devise_invitable.en.yml +31 -0
- data/config/locales/devise_invitable.pt-BR.yml +21 -0
- data/config/routes.rb +1 -2
- data/db/migrate/20200322051231_add_devise_invitable_to_eac_users_support_users.rb +26 -0
- data/db/migrate/20200322053003_add_devise_confirmable_to_eac_users_support_users.rb +21 -0
- data/db/migrate/20200324203335_add_recoverable_to_eac_users_support_users.rb +10 -0
- data/lib/eac_users_support/tasks/password_reset.rb +13 -3
- data/lib/eac_users_support/version.rb +1 -1
- metadata +41 -2
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: be3c7bed883e66a0929a6cc7fdac8163b76e470f44ab6c8756a892cf6b865c52
|
|
4
|
+
data.tar.gz: 3527bca66295da3faee06376f37ce77505ec5b0d20055216dda18f90fb2202db
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: d924a885086b8345184d36ebcec58f642d8066c21f254b7ba289efcecc00b9b483d2d323a06a03c4e55acf47dae982fc70e05f509eaf25255db67335f6ac170e
|
|
7
|
+
data.tar.gz: cc6ef6c896967799d1741a8722737c084b2c73f9f854a3b28961ba080aedeb91a8c61eed1acd8c25a2995676fb148f540814d15d6d51e80ebd37cfe76a63c50d
|
|
@@ -1,10 +1,12 @@
|
|
|
1
1
|
# frozen_string_literal: true
|
|
2
2
|
|
|
3
|
+
require 'devise_invitable'
|
|
3
4
|
require_dependency 'eac_users_support'
|
|
4
5
|
|
|
5
6
|
module EacUsersSupport
|
|
6
7
|
class User < ActiveRecord::Base
|
|
7
|
-
devise :database_authenticatable, :
|
|
8
|
+
devise :confirmable, :database_authenticatable, :invitable, :recoverable, :registerable,
|
|
9
|
+
:rememberable
|
|
8
10
|
|
|
9
11
|
validates :email, presence: true, uniqueness: true
|
|
10
12
|
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
en:
|
|
2
|
+
devise:
|
|
3
|
+
failure:
|
|
4
|
+
invited: "You have a pending invitation, accept it to finish creating your account."
|
|
5
|
+
invitations:
|
|
6
|
+
send_instructions: "An invitation email has been sent to %{email}."
|
|
7
|
+
invitation_token_invalid: "The invitation token provided is not valid!"
|
|
8
|
+
updated: "Your password was set successfully. You are now signed in."
|
|
9
|
+
updated_not_active: "Your password was set successfully."
|
|
10
|
+
no_invitations_remaining: "No invitations remaining"
|
|
11
|
+
invitation_removed: "Your invitation was removed."
|
|
12
|
+
new:
|
|
13
|
+
header: "Send invitation"
|
|
14
|
+
submit_button: "Send an invitation"
|
|
15
|
+
edit:
|
|
16
|
+
header: "Set your password"
|
|
17
|
+
submit_button: "Set my password"
|
|
18
|
+
mailer:
|
|
19
|
+
invitation_instructions:
|
|
20
|
+
subject: "Invitation instructions"
|
|
21
|
+
hello: "Hello %{email}"
|
|
22
|
+
someone_invited_you: "Someone has invited you to %{url}, you can accept it through the link below."
|
|
23
|
+
accept: "Accept invitation"
|
|
24
|
+
accept_until: "This invitation will be due in %{due_date}."
|
|
25
|
+
ignore: "If you don't want to accept the invitation, please ignore this email. Your account won't be created until you access the link above and set your password."
|
|
26
|
+
time:
|
|
27
|
+
formats:
|
|
28
|
+
devise:
|
|
29
|
+
mailer:
|
|
30
|
+
invitation_instructions:
|
|
31
|
+
accept_until_format: "%B %d, %Y %I:%M %p"
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
pt-BR:
|
|
2
|
+
devise:
|
|
3
|
+
invitations:
|
|
4
|
+
send_instructions: 'Um convite foi enviado para %{email}.'
|
|
5
|
+
invitation_token_invalid: 'O token fornecido não é válido!'
|
|
6
|
+
updated: 'Sua senha foi definida com sucesso. Agora você está conectado.'
|
|
7
|
+
no_invitations_remaining: "Sem conites restantes"
|
|
8
|
+
invitation_removed: 'Seu convite foi removido.'
|
|
9
|
+
new:
|
|
10
|
+
header: "Enviar convite"
|
|
11
|
+
submit_button: "Enviar convite"
|
|
12
|
+
edit:
|
|
13
|
+
header: "Defina a sua senha"
|
|
14
|
+
submit_button: "Definir a minha senha"
|
|
15
|
+
mailer:
|
|
16
|
+
invitation_instructions:
|
|
17
|
+
subject: 'Instruções Convite'
|
|
18
|
+
hello: 'Olá %{email}'
|
|
19
|
+
someone_invited_you: 'Alguém convidou você para %{url}, você pode aceitar este convite através do link abaixo.'
|
|
20
|
+
accept: 'Aceite o convite'
|
|
21
|
+
ignore: "Se você não quiser aceitar o convite, por favor ignore este e-mail.<br />A sua conta não será criado até que você acesse o link acima e defina a sua senha."
|
data/config/routes.rb
CHANGED
|
@@ -10,11 +10,10 @@ EacUsersSupport::Engine.routes.draw do
|
|
|
10
10
|
end
|
|
11
11
|
end
|
|
12
12
|
end
|
|
13
|
-
devise_for :users, class_name: 'EacUsersSupport::User', module: :devise
|
|
13
|
+
devise_for :users, class_name: 'EacUsersSupport::User', module: :devise
|
|
14
14
|
resource :user, only: [:edit] do
|
|
15
15
|
collection do
|
|
16
16
|
patch 'update_password'
|
|
17
17
|
end
|
|
18
18
|
end
|
|
19
|
-
get '/users/sign_up(.:format)', to: 'devise/sessions#new', as: 'new_user_registration'
|
|
20
19
|
end
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
class AddDeviseInvitableToEacUsersSupportUsers < ActiveRecord::Migration
|
|
4
|
+
def up
|
|
5
|
+
change_table :eac_users_support_users do |t|
|
|
6
|
+
t.string :invitation_token
|
|
7
|
+
t.datetime :invitation_created_at
|
|
8
|
+
t.datetime :invitation_sent_at
|
|
9
|
+
t.datetime :invitation_accepted_at
|
|
10
|
+
t.integer :invitation_limit
|
|
11
|
+
t.references :invited_by, polymorphic: true
|
|
12
|
+
t.integer :invitations_count, default: 0
|
|
13
|
+
t.index :invitations_count
|
|
14
|
+
t.index :invitation_token, unique: true # for invitable
|
|
15
|
+
t.index :invited_by_id
|
|
16
|
+
end
|
|
17
|
+
end
|
|
18
|
+
|
|
19
|
+
def down
|
|
20
|
+
change_table :eac_users_support_users do |t|
|
|
21
|
+
t.remove_references :invited_by, polymorphic: true
|
|
22
|
+
t.remove :invitations_count, :invitation_limit, :invitation_sent_at, :invitation_accepted_at,
|
|
23
|
+
:invitation_token, :invitation_created_at
|
|
24
|
+
end
|
|
25
|
+
end
|
|
26
|
+
end
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
class AddDeviseConfirmableToEacUsersSupportUsers < ActiveRecord::Migration
|
|
4
|
+
class Model < ::ActiveRecord::Base
|
|
5
|
+
self.table_name = :eac_users_support_users
|
|
6
|
+
end
|
|
7
|
+
|
|
8
|
+
def change
|
|
9
|
+
add_column :eac_users_support_users, :confirmation_token, :string
|
|
10
|
+
add_column :eac_users_support_users, :confirmed_at, :datetime
|
|
11
|
+
add_column :eac_users_support_users, :confirmation_sent_at, :datetime
|
|
12
|
+
# add_column :eac_users_support_users, :unconfirmed_email, :string # Only if using reconfirmable
|
|
13
|
+
add_index :eac_users_support_users, :confirmation_token, unique: true
|
|
14
|
+
# User.reset_column_information # Need for some types of updates, but not for update_all.
|
|
15
|
+
# To avoid a short time window between running the migration and updating all existing
|
|
16
|
+
# users as confirmed, do the following
|
|
17
|
+
reversible do |dir|
|
|
18
|
+
dir.up { Model.update_all confirmed_at: DateTime.now }
|
|
19
|
+
end
|
|
20
|
+
end
|
|
21
|
+
end
|
|
@@ -1,18 +1,21 @@
|
|
|
1
1
|
# frozen_string_literal: true
|
|
2
2
|
|
|
3
|
+
require 'eac_ruby_utils/simple_cache'
|
|
4
|
+
|
|
3
5
|
module EacUsersSupport
|
|
4
6
|
module Tasks
|
|
5
7
|
class PasswordReset
|
|
8
|
+
include ::EacRubyUtils::SimpleCache
|
|
9
|
+
|
|
6
10
|
def initialize(email, administrator)
|
|
7
11
|
@email = email
|
|
8
12
|
@administrator = administrator
|
|
9
13
|
end
|
|
10
14
|
|
|
11
15
|
def run
|
|
12
|
-
|
|
13
|
-
if u
|
|
16
|
+
if found_user
|
|
14
17
|
Rails.logger.info "Usuário encontrado com o email \"#{@email}\""
|
|
15
|
-
|
|
18
|
+
found_user.update!(attributes_to_update)
|
|
16
19
|
else
|
|
17
20
|
Rails.logger.info "Usuário não encontrado com o email \"#{@email}\". Criando..."
|
|
18
21
|
User.create!({ email: @email }.merge(attributes_to_update))
|
|
@@ -24,9 +27,16 @@ module EacUsersSupport
|
|
|
24
27
|
|
|
25
28
|
def attributes_to_update
|
|
26
29
|
r = { password: @email, password_confirmation: @email }
|
|
30
|
+
if found_user.present? && found_user.confirmed_at.blank?
|
|
31
|
+
r.merge(confirmed_at: ::DateTime.now)
|
|
32
|
+
end
|
|
27
33
|
r[:administrator] = true if @administrator
|
|
28
34
|
r
|
|
29
35
|
end
|
|
36
|
+
|
|
37
|
+
def found_user_uncached
|
|
38
|
+
::EacUsersSupport::User.find_by(email: @email)
|
|
39
|
+
end
|
|
30
40
|
end
|
|
31
41
|
end
|
|
32
42
|
end
|
metadata
CHANGED
|
@@ -1,14 +1,14 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: eac_users_support
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version: 0.
|
|
4
|
+
version: 0.6.0
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- Esquilo Azul Company
|
|
8
8
|
autorequire:
|
|
9
9
|
bindir: bin
|
|
10
10
|
cert_chain: []
|
|
11
|
-
date: 2020-03-
|
|
11
|
+
date: 2020-03-26 00:00:00.000000000 Z
|
|
12
12
|
dependencies:
|
|
13
13
|
- !ruby/object:Gem::Dependency
|
|
14
14
|
name: active_scaffold
|
|
@@ -44,6 +44,40 @@ dependencies:
|
|
|
44
44
|
- - ">="
|
|
45
45
|
- !ruby/object:Gem::Version
|
|
46
46
|
version: 4.6.1
|
|
47
|
+
- !ruby/object:Gem::Dependency
|
|
48
|
+
name: devise_invitable
|
|
49
|
+
requirement: !ruby/object:Gem::Requirement
|
|
50
|
+
requirements:
|
|
51
|
+
- - "~>"
|
|
52
|
+
- !ruby/object:Gem::Version
|
|
53
|
+
version: '1.7'
|
|
54
|
+
- - ">="
|
|
55
|
+
- !ruby/object:Gem::Version
|
|
56
|
+
version: 1.7.5
|
|
57
|
+
type: :runtime
|
|
58
|
+
prerelease: false
|
|
59
|
+
version_requirements: !ruby/object:Gem::Requirement
|
|
60
|
+
requirements:
|
|
61
|
+
- - "~>"
|
|
62
|
+
- !ruby/object:Gem::Version
|
|
63
|
+
version: '1.7'
|
|
64
|
+
- - ">="
|
|
65
|
+
- !ruby/object:Gem::Version
|
|
66
|
+
version: 1.7.5
|
|
67
|
+
- !ruby/object:Gem::Dependency
|
|
68
|
+
name: eac_ruby_utils
|
|
69
|
+
requirement: !ruby/object:Gem::Requirement
|
|
70
|
+
requirements:
|
|
71
|
+
- - "~>"
|
|
72
|
+
- !ruby/object:Gem::Version
|
|
73
|
+
version: '0.22'
|
|
74
|
+
type: :runtime
|
|
75
|
+
prerelease: false
|
|
76
|
+
version_requirements: !ruby/object:Gem::Requirement
|
|
77
|
+
requirements:
|
|
78
|
+
- - "~>"
|
|
79
|
+
- !ruby/object:Gem::Version
|
|
80
|
+
version: '0.22'
|
|
47
81
|
- !ruby/object:Gem::Dependency
|
|
48
82
|
name: rails
|
|
49
83
|
requirement: !ruby/object:Gem::Requirement
|
|
@@ -133,12 +167,17 @@ files:
|
|
|
133
167
|
- config/initializers/devise.rb
|
|
134
168
|
- config/locales/devise.en.yml
|
|
135
169
|
- config/locales/devise.pt-BR.yml
|
|
170
|
+
- config/locales/devise_invitable.en.yml
|
|
171
|
+
- config/locales/devise_invitable.pt-BR.yml
|
|
136
172
|
- config/locales/pt-BR.yml
|
|
137
173
|
- config/routes.rb
|
|
138
174
|
- db/migrate/20160605013848_create_eac_users_support_users.rb
|
|
139
175
|
- db/migrate/20160605035833_add_devise_authenticable_to_eac_users_support_users.rb
|
|
140
176
|
- db/migrate/20180222202443_add_devise_rememberable_to_eac_users_support_users.rb
|
|
141
177
|
- db/migrate/20180318181324_add_administrator_to_eac_users_support_users.rb
|
|
178
|
+
- db/migrate/20200322051231_add_devise_invitable_to_eac_users_support_users.rb
|
|
179
|
+
- db/migrate/20200322053003_add_devise_confirmable_to_eac_users_support_users.rb
|
|
180
|
+
- db/migrate/20200324203335_add_recoverable_to_eac_users_support_users.rb
|
|
142
181
|
- lib/eac_users_support.rb
|
|
143
182
|
- lib/eac_users_support/engine.rb
|
|
144
183
|
- lib/eac_users_support/patches/action_controller_test_case.rb
|