eac_rails_base0 0.36.1 → 0.39.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/controllers/eac_rails_base0/application_controller.rb +6 -0
- data/app/helpers/eac_rails_base0/app_version_helper.rb +20 -0
- data/app/helpers/eac_rails_base0/panel_default_helper.rb +29 -0
- data/app/views/devise/confirmations/new.html.erb +11 -0
- data/app/views/devise/mailer/confirmation_instructions.html.erb +5 -0
- data/app/views/devise/mailer/reset_password_instructions.html.erb +9 -0
- data/app/views/devise/passwords/edit.html.erb +10 -0
- data/app/views/devise/passwords/new.html.erb +7 -0
- data/app/views/devise/registrations/edit.html.erb +9 -0
- data/app/views/devise/registrations/new.html.erb +9 -0
- data/app/views/devise/sessions/new.html.erb +9 -0
- data/app/views/devise/shared/_links.html.erb +37 -0
- data/config/locales/pt-BR.yml +17 -6
- data/lib/eac_rails_base0/app_base/ability.rb +23 -1
- data/lib/eac_rails_base0/app_base/ability_mapping.rb +2 -0
- data/lib/eac_rails_base0/spec_helper/eac_users_support.rb +8 -6
- data/lib/eac_rails_base0/version.rb +1 -1
- metadata +14 -4
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: d40e6c771be2a3a4717fe568fd34aea08c56bfbb10d4aa876eddf30f13e3bef5
|
4
|
+
data.tar.gz: b9f149565fea2e3d880b76a4aee6317a59870ed21d4e4e5148b01c60288b97ba
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 609b35c3187d0cb4e490860209775683d80be4d5674c6d45320f74bd851450237622c06714994da6f466b8f6465d2fca27faee294affb38f11939a8a984773f1
|
7
|
+
data.tar.gz: 9823469ddefde147b6759ddd12ef06cb130401ac8273a17fb7dc21b1a5fc7d692257345f3b5c0ebf137ab8cf01b815fc70c24d985a71dc5f5a6e6bc023baae47
|
@@ -5,6 +5,7 @@ module EacRailsBase0
|
|
5
5
|
include ::CanCanDry::ControllerAuthorization
|
6
6
|
|
7
7
|
layout 'eac_rails_base0/application'
|
8
|
+
helper ::EacRailsBase0::AppVersionHelper
|
8
9
|
helper ::EacRailsBase0::LayoutHelper
|
9
10
|
helper ::EacRailsUtils::FormatterHelper
|
10
11
|
helper ::EacRailsUtils::LinksHelper
|
@@ -22,6 +23,7 @@ module EacRailsBase0
|
|
22
23
|
redirect_to main_app.root_url
|
23
24
|
else
|
24
25
|
flash[:danger] = 'Por favor faça o login.'
|
26
|
+
store_location_for(::EacUsersSupport::User, request.fullpath)
|
25
27
|
redirect_to eac_users_support.new_user_session_path
|
26
28
|
end
|
27
29
|
end
|
@@ -33,5 +35,9 @@ module EacRailsBase0
|
|
33
35
|
super
|
34
36
|
end
|
35
37
|
end
|
38
|
+
|
39
|
+
def after_sign_in_path_for(resource)
|
40
|
+
stored_location_for(resource) || root_path
|
41
|
+
end
|
36
42
|
end
|
37
43
|
end
|
@@ -0,0 +1,20 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module EacRailsBase0
|
4
|
+
module AppVersionHelper
|
5
|
+
def base0_app_version
|
6
|
+
base0_app_version_by_environment_variable ||
|
7
|
+
base0_app_version_by_version_file ||
|
8
|
+
::I18n.t('eac_rails_base0.app_version.unsetted')
|
9
|
+
end
|
10
|
+
|
11
|
+
def base0_app_version_by_environment_variable
|
12
|
+
ENV['APP_VERSION'].to_s.strip.presence
|
13
|
+
end
|
14
|
+
|
15
|
+
def base0_app_version_by_version_file
|
16
|
+
::Rails.root.children.find { |file| file.basename.to_path.downcase == 'version' }
|
17
|
+
.if_present { |file| file.read.presence }
|
18
|
+
end
|
19
|
+
end
|
20
|
+
end
|
@@ -0,0 +1,29 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module EacRailsBase0
|
4
|
+
module PanelDefaultHelper
|
5
|
+
def panel_default(title, &block)
|
6
|
+
content_tag(:div, class: 'container') do
|
7
|
+
content_tag(:div, class: 'panel panel-default') do
|
8
|
+
panel_heading(title) << panel_body(block)
|
9
|
+
end
|
10
|
+
end
|
11
|
+
end
|
12
|
+
|
13
|
+
private
|
14
|
+
|
15
|
+
def panel_heading(title)
|
16
|
+
content_tag(:div, class: 'panel-heading') do
|
17
|
+
content_tag(:h2, class: 'panel-title') do
|
18
|
+
title
|
19
|
+
end
|
20
|
+
end
|
21
|
+
end
|
22
|
+
|
23
|
+
def panel_body(block)
|
24
|
+
content_tag(:div, class: 'panel-body') do
|
25
|
+
block ? block.call : ''
|
26
|
+
end
|
27
|
+
end
|
28
|
+
end
|
29
|
+
end
|
@@ -0,0 +1,11 @@
|
|
1
|
+
<!--
|
2
|
+
f.email_field :email, autofocus: true, autocomplete: "email",
|
3
|
+
value: (resource.pending_reconfirmation? ? resource.unconfirmed_email : resource.email)
|
4
|
+
-->
|
5
|
+
<%= panel_default t('devise.confirmation_resend') do %>
|
6
|
+
<%= common_form(resource, as: resource_name, url: confirmation_path(resource_name),
|
7
|
+
html: { method: :post }, :submit_label => t('devise.confirmation_resend_submit')) do |f| %>
|
8
|
+
<%= f.email_field :email, required: true %>
|
9
|
+
<% end %>
|
10
|
+
<%= render "devise/shared/links" %>
|
11
|
+
<% end %>
|
@@ -0,0 +1,9 @@
|
|
1
|
+
<p>Olá <%= @resource.email %>!</p>
|
2
|
+
<p>Alguém solicitou a recuperação de sua senha. Você pode fazer isso
|
3
|
+
através do link abaixo.</p>
|
4
|
+
<p><%= link_to 'Alterar minha senha',
|
5
|
+
edit_password_url(@resource, reset_password_token: @token) %></p>
|
6
|
+
<p>Se você não efetuou esta solicitação, por favor, ignore este
|
7
|
+
e-mail.</p>
|
8
|
+
<p>Sua senha não será alterada até que você acesse o link acima e
|
9
|
+
recadastre-a.</p>
|
@@ -0,0 +1,10 @@
|
|
1
|
+
<%= panel_default t('devise.update_password') do %>
|
2
|
+
<%= common_form(resource, as: resource_name,
|
3
|
+
url: password_path(resource_name), submit_label: t('devise.update_password_submit'),
|
4
|
+
html: { method: :put }
|
5
|
+
) do |f| %>
|
6
|
+
<%= f.hidden_field :reset_password_token %>
|
7
|
+
<%= f.password_field :password, label: t('devise.new_password'), required: true %>
|
8
|
+
<%= f.password_field :password_confirmation, required: true %>
|
9
|
+
<% end %>
|
10
|
+
<% end %>
|
@@ -0,0 +1,7 @@
|
|
1
|
+
<%= panel_default t('devise.forgot_password') do %>
|
2
|
+
<%= common_form(resource, as: resource_name, url: password_path(resource_name),
|
3
|
+
submit_label: t('devise.forgot_password_submit'),
|
4
|
+
html: { method: :post }) do |f| %>
|
5
|
+
<%= f.email_field :email, class: 'form-control' %>
|
6
|
+
<% end %>
|
7
|
+
<% end %>
|
@@ -0,0 +1,9 @@
|
|
1
|
+
<%= panel_default t('devise.update_password') do %>
|
2
|
+
<%= common_form(resource, as: resource_name, url: registration_path(resource_name),
|
3
|
+
submit_label: t('devise.update_password_submit'), html: { method: :put, role: "form" }) do |f| %>
|
4
|
+
<p>Preencha os campos abaixo se deseja alterar sua senha.</p>
|
5
|
+
<%= f.password_field :current_password, label: 'Senha atual', required: true %>
|
6
|
+
<%= f.password_field :password, label: 'Nova senha', required: false %>
|
7
|
+
<%= f.password_field :password_confirmation, label: 'Confirmação de senha' %>
|
8
|
+
<% end %>
|
9
|
+
<% end %>
|
@@ -0,0 +1,9 @@
|
|
1
|
+
<%= panel_default t('devise.sign_up') do %>
|
2
|
+
<%= common_form(resource, as: resource_name, url: registration_path(resource_name),
|
3
|
+
submit_label: t('devise.sign_up_submit'), html: { role: "form" }) do |f| %>
|
4
|
+
<%= f.email_field :email %>
|
5
|
+
<%= f.password_field :password, required: true %>
|
6
|
+
<%= f.password_field :password_confirmation, required: true %>
|
7
|
+
<% end %>
|
8
|
+
<%= render "devise/shared/links" %>
|
9
|
+
<% end %>
|
@@ -0,0 +1,9 @@
|
|
1
|
+
<%= panel_default t('devise.log_in') do %>
|
2
|
+
<%= common_form(resource, as: resource_name, url: session_path(resource_name),
|
3
|
+
:submit_label => t('devise.log_in')) do |f| %>
|
4
|
+
<%= f.email_field :email, required: true %>
|
5
|
+
<%= f.password_field :password, required: true %>
|
6
|
+
<%= f.check_box_field :remember_me %>
|
7
|
+
<% end %>
|
8
|
+
<%= render "devise/shared/links" %>
|
9
|
+
<% end %>
|
@@ -0,0 +1,37 @@
|
|
1
|
+
<%
|
2
|
+
links = [{
|
3
|
+
condition: controller_name != 'sessions',
|
4
|
+
label: t('devise.log_in'),
|
5
|
+
url: -> { new_session_path(resource_name) }
|
6
|
+
},{
|
7
|
+
condition: devise_mapping.registerable? && controller_name != 'registrations',
|
8
|
+
label: t('devise.sign_up'),
|
9
|
+
url: -> {new_registration_path(resource_name) }
|
10
|
+
},{
|
11
|
+
condition: devise_mapping.recoverable? && controller_name != 'passwords' && controller_name != 'registrations',
|
12
|
+
label: t('devise.forgot_password'),
|
13
|
+
url: -> {new_password_path(resource_name) }
|
14
|
+
},{
|
15
|
+
condition: devise_mapping.confirmable? && controller_name != 'confirmations',
|
16
|
+
label: t('devise.unreceived_confirmation'),
|
17
|
+
url: -> {new_confirmation_path(resource_name) }
|
18
|
+
},{
|
19
|
+
condition: devise_mapping.lockable? && resource_class.unlock_strategy_enabled?(:email) && controller_name != 'unlocks',
|
20
|
+
label: t('devise.unreceived_unlock'),
|
21
|
+
url: -> { new_unlock_path(resource_name) }
|
22
|
+
}]
|
23
|
+
if devise_mapping.omniauthable?
|
24
|
+
links += resource_class.omniauth_providers.map do |provider|
|
25
|
+
{
|
26
|
+
condition: true,
|
27
|
+
label: t("devise.log_in_with", provider: ::OmniAuth::Utils.camelize(provider)),
|
28
|
+
url: -> { omniauth_authorize_path(resource_name, provider) }
|
29
|
+
}
|
30
|
+
end
|
31
|
+
end
|
32
|
+
%>
|
33
|
+
<% links.each do |link| %>
|
34
|
+
<% if link.fetch(:condition) %>
|
35
|
+
<%= link_to link.fetch(:label), link.fetch(:url).call %><br/>
|
36
|
+
<% end %>
|
37
|
+
<% end %>
|
data/config/locales/pt-BR.yml
CHANGED
@@ -4,18 +4,29 @@ pt-BR:
|
|
4
4
|
default: '%d/%m/%Y'
|
5
5
|
picker: '%d/%m/%Y'
|
6
6
|
short: '%d/%m/%y'
|
7
|
+
devise:
|
8
|
+
confirmation_resend: Reenvio de instruções de confirmação
|
9
|
+
confirmation_resend_submit: Reenviar
|
10
|
+
forgot_password: Esqueceu sua senha?
|
11
|
+
forgot_password_submit: Envie-me as instruções de recuperação de senha
|
12
|
+
log_in: Entrar
|
13
|
+
log_in_with: Entrar com %{provider}
|
14
|
+
log_out: Sair
|
15
|
+
new_password: Nova senha
|
16
|
+
sign_up: Cadastrar-se
|
17
|
+
sign_up_submit: Cadastrar
|
18
|
+
unreceived_confirmation: Não recebeu as instruções de confirmação?
|
19
|
+
unreceived_unlock: Não recebeu as instruções de desbloqueio de conta?
|
20
|
+
update_password: Alteração de senha
|
21
|
+
update_password_submit: Alterar minha senha
|
7
22
|
time:
|
8
23
|
formats:
|
9
24
|
default: "%d/%m/%Y %H:%M"
|
10
25
|
picker: '%d/%m/%Y %H:%M'
|
11
26
|
short: '%d/%m/%y %H:%M'
|
12
27
|
eac_rails_base0:
|
13
|
-
|
14
|
-
|
15
|
-
delete_object: Remover "%{label}".
|
16
|
-
edit_object: Editar "%{label}".
|
17
|
-
goto_url: Ir para %{url}.
|
18
|
-
show_object: Mostrar "%{label}".
|
28
|
+
app_version:
|
29
|
+
unsetted: Não especificada
|
19
30
|
main_menu:
|
20
31
|
admin:
|
21
32
|
aranha: Aranha
|
@@ -14,19 +14,41 @@ module EacRailsBase0
|
|
14
14
|
administrator_rules(user)
|
15
15
|
end
|
16
16
|
|
17
|
+
def devise_confirmation_rules(user)
|
18
|
+
return unless user.new_record?
|
19
|
+
|
20
|
+
can :create, 'Devise::Confirmation'
|
21
|
+
can :read, 'Devise::Confirmation'
|
22
|
+
end
|
23
|
+
|
24
|
+
def devise_invitable_rules(user)
|
25
|
+
can :create, 'Devise::Invitation' if user.administrator?
|
26
|
+
can :update, 'Devise::Invitation'
|
27
|
+
if user.new_record?
|
28
|
+
can :create, 'DeviseInvitable::Registration'
|
29
|
+
else
|
30
|
+
can :update, 'DeviseInvitable::Registration'
|
31
|
+
end
|
32
|
+
end
|
33
|
+
|
17
34
|
def devise_password_rules(user)
|
18
35
|
return unless user.new_record?
|
19
36
|
|
20
37
|
can :manage, 'Devise::Password'
|
21
38
|
end
|
22
39
|
|
40
|
+
def devise_registration_rules(user)
|
41
|
+
can :create, 'Devise::Registration' if user.new_record?
|
42
|
+
can :update, 'Devise::Registration' unless user.new_record?
|
43
|
+
end
|
44
|
+
|
23
45
|
def devise_session_rules(user)
|
24
46
|
can :destroy, 'Devise::Session' unless user.new_record?
|
25
47
|
can :create, 'Devise::Session'
|
26
48
|
end
|
27
49
|
|
28
50
|
def devise_rules(user)
|
29
|
-
%w[password session].each do |devise_module|
|
51
|
+
%w[confirmation invitable password registration session].each do |devise_module|
|
30
52
|
send("devise_#{devise_module}_rules", user)
|
31
53
|
end
|
32
54
|
end
|
@@ -6,9 +6,11 @@ module EacRailsBase0
|
|
6
6
|
include CanCanDry::AbilityMapping
|
7
7
|
include CanCanDry::AbilityMappingSets::ActiveScaffold
|
8
8
|
include CanCanDry::AbilityMappingSets::Devise
|
9
|
+
include CanCanDry::AbilityMappingSets::DeviseInvitable
|
9
10
|
|
10
11
|
def initialize
|
11
12
|
map_devise
|
13
|
+
map_devise_invitable
|
12
14
|
map_controller 'EacUsersSupport::Admin::Users', :manage, ::EacUsersSupport::User
|
13
15
|
map_controller 'Aranha::Addresses', :manage, ::Aranha::Address
|
14
16
|
map_controller 'BrRailties::FederalUnits', :manage, ::BrRailties::FederalUnit
|
@@ -23,9 +23,11 @@ RSpec.shared_context 'when user is admin', shared_context: :metadata do
|
|
23
23
|
|
24
24
|
before do
|
25
25
|
visit '/users/sign_in'
|
26
|
-
fill_in '
|
27
|
-
|
28
|
-
|
26
|
+
fill_in ::I18n.translate!('activerecord.attributes.eac_users_support/user.email'),
|
27
|
+
with: user.email
|
28
|
+
fill_in ::I18n.translate!('activerecord.attributes.eac_users_support/user.password'),
|
29
|
+
with: user.password
|
30
|
+
click_button ::I18n.translate!('devise.log_in')
|
29
31
|
end
|
30
32
|
|
31
33
|
it 'user should be logged' do
|
@@ -37,9 +39,9 @@ end
|
|
37
39
|
RSpec.shared_context 'when user is anonymous', shared_context: :metadata do
|
38
40
|
before do
|
39
41
|
visit '/'
|
40
|
-
if link_exist?('
|
41
|
-
click_link('
|
42
|
-
elsif !link_exist?('
|
42
|
+
if link_exist?(::I18n.translate!('devise.log_out'))
|
43
|
+
click_link(::I18n.translate!('devise.log_out'))
|
44
|
+
elsif !link_exist?(::I18n.translate!('devise.log_in'))
|
43
45
|
raise 'login nor logout link found'
|
44
46
|
end
|
45
47
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: eac_rails_base0
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.39.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Esquilo Azul Company
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2020-
|
11
|
+
date: 2020-08-11 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: aranha
|
@@ -515,8 +515,19 @@ files:
|
|
515
515
|
- app/assets/stylesheets/eac_rails_base0/components.scss
|
516
516
|
- app/assets/stylesheets/eac_rails_base0/default_configuration.scss
|
517
517
|
- app/controllers/eac_rails_base0/application_controller.rb
|
518
|
+
- app/helpers/eac_rails_base0/app_version_helper.rb
|
518
519
|
- app/helpers/eac_rails_base0/layout_helper.rb
|
520
|
+
- app/helpers/eac_rails_base0/panel_default_helper.rb
|
519
521
|
- app/uploaders/eac_rails_base0/default_file_uploader.rb
|
522
|
+
- app/views/devise/confirmations/new.html.erb
|
523
|
+
- app/views/devise/mailer/confirmation_instructions.html.erb
|
524
|
+
- app/views/devise/mailer/reset_password_instructions.html.erb
|
525
|
+
- app/views/devise/passwords/edit.html.erb
|
526
|
+
- app/views/devise/passwords/new.html.erb
|
527
|
+
- app/views/devise/registrations/edit.html.erb
|
528
|
+
- app/views/devise/registrations/new.html.erb
|
529
|
+
- app/views/devise/sessions/new.html.erb
|
530
|
+
- app/views/devise/shared/_links.html.erb
|
520
531
|
- app/views/layouts/eac_rails_base0/_flash.html.erb
|
521
532
|
- app/views/layouts/eac_rails_base0/_main_menu.html.erb
|
522
533
|
- app/views/layouts/eac_rails_base0/_navbar_user.html.erb
|
@@ -610,8 +621,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
610
621
|
- !ruby/object:Gem::Version
|
611
622
|
version: '0'
|
612
623
|
requirements: []
|
613
|
-
|
614
|
-
rubygems_version: 2.7.7
|
624
|
+
rubygems_version: 3.0.8
|
615
625
|
signing_key:
|
616
626
|
specification_version: 4
|
617
627
|
summary: A Rails base for multiple Rails projects developed by Esquilo Azul Company.
|