eac_users_support 0.5.1 → 0.8.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/app/models/eac_users_support/user.rb +3 -1
- data/app/views/devise/sessions/_login_form.html.erb +19 -0
- data/app/views/devise/sessions/new.html.erb +3 -0
- 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/db/migrate/20200620215624_add_unconfirmed_email_to_eac_users_support_users.rb +7 -0
- data/lib/eac_users_support/engine.rb +1 -0
- data/lib/eac_users_support/tasks/password_reset.rb +13 -3
- data/lib/eac_users_support/version.rb +1 -1
- metadata +50 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: a6f71837cbc32ec116960a738b6587a260cbc5666b350e457b4bb7b972bb5fae
|
4
|
+
data.tar.gz: 7431f987013795c944690be25139c262f514663b641af90454b5066fa41d5675
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 71dfb7cfcc2d9cd99c409a9b8a23d340604010ca84a3997f2a9910d996f625076e2fcc55259dbaef9c7b09aa2ab0af75a3ff7098995dcd5b5be6787310a7995e
|
7
|
+
data.tar.gz: '0227709c518159a57f3954beeafd3f92f60744f349fabb741af4dbc0bc690e8c497eca2aca4c0e963bda703573e1008012c142bc7696a55a2f783d1a96269baa'
|
@@ -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,19 @@
|
|
1
|
+
<%= form_for(resource, as: resource_name, url: session_path(resource_name)) do |f| %>
|
2
|
+
<div class="field">
|
3
|
+
<%= f.label :email %><br />
|
4
|
+
<%= f.email_field :email, autofocus: true, autocomplete: "email" %>
|
5
|
+
</div>
|
6
|
+
<div class="field">
|
7
|
+
<%= f.label :password %><br />
|
8
|
+
<%= f.password_field :password, autocomplete: "current-password" %>
|
9
|
+
</div>
|
10
|
+
<% if devise_mapping.rememberable? %>
|
11
|
+
<div class="field">
|
12
|
+
<%= f.check_box :remember_me %>
|
13
|
+
<%= f.label :remember_me %>
|
14
|
+
</div>
|
15
|
+
<% end %>
|
16
|
+
<div class="actions">
|
17
|
+
<%= f.submit "Log in" %>
|
18
|
+
</div>
|
19
|
+
<% end %>
|
@@ -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.8.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-
|
11
|
+
date: 2020-06-23 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
|
@@ -79,6 +113,9 @@ dependencies:
|
|
79
113
|
- - "~>"
|
80
114
|
- !ruby/object:Gem::Version
|
81
115
|
version: '0.1'
|
116
|
+
- - ">="
|
117
|
+
- !ruby/object:Gem::Version
|
118
|
+
version: 0.1.2
|
82
119
|
type: :development
|
83
120
|
prerelease: false
|
84
121
|
version_requirements: !ruby/object:Gem::Requirement
|
@@ -86,6 +123,9 @@ dependencies:
|
|
86
123
|
- - "~>"
|
87
124
|
- !ruby/object:Gem::Version
|
88
125
|
version: '0.1'
|
126
|
+
- - ">="
|
127
|
+
- !ruby/object:Gem::Version
|
128
|
+
version: 0.1.2
|
89
129
|
- !ruby/object:Gem::Dependency
|
90
130
|
name: rspec-rails
|
91
131
|
requirement: !ruby/object:Gem::Requirement
|
@@ -129,16 +169,24 @@ files:
|
|
129
169
|
- app/controllers/eac_users_support/application_controller.rb
|
130
170
|
- app/controllers/eac_users_support/users_controller.rb
|
131
171
|
- app/models/eac_users_support/user.rb
|
172
|
+
- app/views/devise/sessions/_login_form.html.erb
|
173
|
+
- app/views/devise/sessions/new.html.erb
|
132
174
|
- app/views/eac_users_support/users/edit.html.erb
|
133
175
|
- config/initializers/devise.rb
|
134
176
|
- config/locales/devise.en.yml
|
135
177
|
- config/locales/devise.pt-BR.yml
|
178
|
+
- config/locales/devise_invitable.en.yml
|
179
|
+
- config/locales/devise_invitable.pt-BR.yml
|
136
180
|
- config/locales/pt-BR.yml
|
137
181
|
- config/routes.rb
|
138
182
|
- db/migrate/20160605013848_create_eac_users_support_users.rb
|
139
183
|
- db/migrate/20160605035833_add_devise_authenticable_to_eac_users_support_users.rb
|
140
184
|
- db/migrate/20180222202443_add_devise_rememberable_to_eac_users_support_users.rb
|
141
185
|
- db/migrate/20180318181324_add_administrator_to_eac_users_support_users.rb
|
186
|
+
- db/migrate/20200322051231_add_devise_invitable_to_eac_users_support_users.rb
|
187
|
+
- db/migrate/20200322053003_add_devise_confirmable_to_eac_users_support_users.rb
|
188
|
+
- db/migrate/20200324203335_add_recoverable_to_eac_users_support_users.rb
|
189
|
+
- db/migrate/20200620215624_add_unconfirmed_email_to_eac_users_support_users.rb
|
142
190
|
- lib/eac_users_support.rb
|
143
191
|
- lib/eac_users_support/engine.rb
|
144
192
|
- lib/eac_users_support/patches/action_controller_test_case.rb
|