eac_users_support 0.5.0 → 0.7.1

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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: '048055a37126d09e6dcfb77e16cf0db39b1685636ecbff4d96dceb073cff059d'
4
- data.tar.gz: 5233973a8170ae86c88685b0e600c448da87b1036da55c62c588b631ac12e148
3
+ metadata.gz: 937494fd57af908f914d09345291428a837723b4f0b9e35803b8a56080a45447
4
+ data.tar.gz: edd39bf7eb87d8ebd534cce0da997d42f99fc8d2dec64d380f9d3e88b3bada93
5
5
  SHA512:
6
- metadata.gz: f3ec70c14efaf7e3e55f699ae5fa5bbcecb789e47b20fb3af3ff7f308af2f258e80fa87551ae6afa11f4afdea060603fcc84e1c9f9f6af9e2220ac0822747d63
7
- data.tar.gz: b9d66d81ea7c1a8564d25febb41df7c40e861db4781a66d2a4ce2e9d3b43e9162426e4e7afec69ade9c21d049add0ea9340104722913386210d0cb454d816a3c
6
+ metadata.gz: a86e8fc5e3c8c5f855df6732430f7503c7c849677283ad6a5ed1110c915b64ce6351da26d24536e598f70948843e30969c2231c7584132b3de21764e34b47aee
7
+ data.tar.gz: 2784e95ef6f5cd5c542660bfbacafa781a457e5c841f91c1f8039b272a1295e18d97de9d5faaec338e099253424349cef33e2df3e967ce89787fa965871c892a
@@ -9,4 +9,4 @@ alt="Build Status" />}[https://travis-ci.org/eduardobogoni/eac_users_support]
9
9
  {<img src="https://api.codeclimate.com/v1/badges/b1d55205806a6d7a907a/test_coverage"
10
10
  />}[https://codeclimate.com/github/eduardobogoni/eac_users_support/test_coverage]
11
11
 
12
- This project rocks and uses MIT-LICENSE.
12
+ This project rocks and uses MIT-LICENSE.
data/Rakefile CHANGED
@@ -23,13 +23,8 @@ load 'rails/tasks/statistics.rake'
23
23
 
24
24
  Bundler::GemHelper.install_tasks
25
25
 
26
-
27
- begin
28
- require 'rspec/core/rake_task'
29
- RSpec::Core::RakeTask.new(:spec)
30
- task :test => :spec
31
- rescue LoadError
32
- # no rspec available
33
- end
26
+ require 'rspec/core/rake_task'
27
+ RSpec::Core::RakeTask.new(:spec)
28
+ task test: :spec
34
29
 
35
30
  task default: :test
@@ -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, :registerable, :rememberable
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,3 @@
1
+ <h2>Log in</h2>
2
+ <%= render partial: 'login_form' %>
3
+ <%= render "devise/shared/links" %>
@@ -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."
@@ -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, skip: [:registrations]
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
@@ -0,0 +1,10 @@
1
+ # frozen_string_literal: true
2
+
3
+ class AddRecoverableToEacUsersSupportUsers < ActiveRecord::Migration
4
+ def change
5
+ change_table :eac_users_support_users do |t|
6
+ t.string :reset_password_token
7
+ t.datetime :reset_password_sent_at
8
+ end
9
+ end
10
+ end
@@ -1,6 +1,7 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  require 'devise'
4
+ require 'devise_invitable'
4
5
 
5
6
  module EacUsersSupport
6
7
  class Engine < ::Rails::Engine
@@ -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
- u = User.find_by(email: @email)
13
- if u
16
+ if found_user
14
17
  Rails.logger.info "Usuário encontrado com o email \"#{@email}\""
15
- u.update!(attributes_to_update)
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
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module EacUsersSupport
4
- VERSION = '0.5.0'
4
+ VERSION = '0.7.1'
5
5
  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.5.0
4
+ version: 0.7.1
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-02-11 00:00:00.000000000 Z
11
+ date: 2020-06-14 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
@@ -72,6 +106,26 @@ dependencies:
72
106
  - - "~>"
73
107
  - !ruby/object:Gem::Version
74
108
  version: '3.10'
109
+ - !ruby/object:Gem::Dependency
110
+ name: eac_ruby_gem_support
111
+ requirement: !ruby/object:Gem::Requirement
112
+ requirements:
113
+ - - "~>"
114
+ - !ruby/object:Gem::Version
115
+ version: '0.1'
116
+ - - ">="
117
+ - !ruby/object:Gem::Version
118
+ version: 0.1.2
119
+ type: :development
120
+ prerelease: false
121
+ version_requirements: !ruby/object:Gem::Requirement
122
+ requirements:
123
+ - - "~>"
124
+ - !ruby/object:Gem::Version
125
+ version: '0.1'
126
+ - - ">="
127
+ - !ruby/object:Gem::Version
128
+ version: 0.1.2
75
129
  - !ruby/object:Gem::Dependency
76
130
  name: rspec-rails
77
131
  requirement: !ruby/object:Gem::Requirement
@@ -115,16 +169,23 @@ files:
115
169
  - app/controllers/eac_users_support/application_controller.rb
116
170
  - app/controllers/eac_users_support/users_controller.rb
117
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
118
174
  - app/views/eac_users_support/users/edit.html.erb
119
175
  - config/initializers/devise.rb
120
176
  - config/locales/devise.en.yml
121
177
  - config/locales/devise.pt-BR.yml
178
+ - config/locales/devise_invitable.en.yml
179
+ - config/locales/devise_invitable.pt-BR.yml
122
180
  - config/locales/pt-BR.yml
123
181
  - config/routes.rb
124
182
  - db/migrate/20160605013848_create_eac_users_support_users.rb
125
183
  - db/migrate/20160605035833_add_devise_authenticable_to_eac_users_support_users.rb
126
184
  - db/migrate/20180222202443_add_devise_rememberable_to_eac_users_support_users.rb
127
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
128
189
  - lib/eac_users_support.rb
129
190
  - lib/eac_users_support/engine.rb
130
191
  - lib/eac_users_support/patches/action_controller_test_case.rb