symphonia 4.0.0 → 4.1.2
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/.rubocop.yml +6 -0
- data/CHANGELOG.md +15 -0
- data/app/assets/stylesheets/symphonia/_font_awesome.scss +29 -0
- data/app/assets/stylesheets/symphonia/_layout.scss +40 -0
- data/app/assets/stylesheets/symphonia/basic.scss +3 -38
- data/app/assets/stylesheets/symphonia/symphonia_bootstrap.scss +1 -46
- data/app/controllers/symphonia/accounts_controller.rb +6 -12
- data/app/helpers/symphonia/application_helper.rb +2 -2
- data/app/views/layouts/symphonia/application.html.erb +2 -2
- data/app/views/symphonia/accounts/_form.html.erb +0 -4
- data/app/views/symphonia/accounts/register.html.erb +4 -14
- data/app/views/symphonia/login/_form.html.erb +3 -3
- data/config/locales/cs.yml +0 -5
- data/lib/generators/symphonia/setup/setup_generator.rb +2 -2
- data/lib/generators/symphonia/setup/templates/Gemfile +1 -2
- data/lib/generators/symphonia/setup/templates/app/config/initializers/settings.rb.tt +0 -5
- data/lib/generators/symphonia/setup/templates/config/initializers/symphonia.rb.tt +48 -0
- data/lib/generators/symphonia/setup/templates/public/404.html.tt +2 -2
- data/lib/generators/symphonia/setup/templates/public/500.html.tt +0 -11
- data/lib/symphonia/action_cable/connection.rb +5 -7
- data/lib/symphonia/admin_constraint.rb +3 -1
- data/lib/symphonia/controller_extensions.rb +39 -65
- data/lib/symphonia/user_management.rb +0 -1
- data/lib/symphonia/version.rb +1 -1
- data/spec/controllers/account_controller_spec.rb +17 -17
- metadata +5 -16
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 7033f315c16e49ebc00088855303534bd7220068416b08e48056ce9d43e2531d
|
4
|
+
data.tar.gz: 1868fc1ee61994c9859cdb38bcaf069a52a3b3a1cf5242f8ae71a03f282f3909
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: fb542f3bc5305a51d23b4ecc24988a2aaf4acb2abe1b3880264b622f0094c943142f83f3e168f538d6c3d158ae54076bb8aea601762d03b331dfc89faa6e7815
|
7
|
+
data.tar.gz: 4df5f61aeb4d8ee5cd66ec25771602372a30cabad3d0f8320247955965fffe15575a6aa6ff7d81ccd5415a98fed99b943601aec19dc1fefd32512bb955f27e4d
|
data/.rubocop.yml
CHANGED
@@ -1,3 +1,7 @@
|
|
1
|
+
require:
|
2
|
+
- rubocop-rails
|
3
|
+
- rubocop-rspec
|
4
|
+
|
1
5
|
AllCops:
|
2
6
|
TargetRubyVersion: 2.5
|
3
7
|
NewCops: enable
|
@@ -15,6 +19,8 @@ Metrics/BlockLength:
|
|
15
19
|
Enabled: false
|
16
20
|
Metrics/MethodLength:
|
17
21
|
Enabled: false
|
22
|
+
Naming/VariableNumber:
|
23
|
+
Enabled: false
|
18
24
|
|
19
25
|
Style/Documentation:
|
20
26
|
Enabled: false
|
data/CHANGELOG.md
CHANGED
@@ -5,6 +5,21 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
|
|
5
5
|
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
|
6
6
|
|
7
7
|
## [Unreleased]
|
8
|
+
## [4.1.1] - 2021-12-26
|
9
|
+
### Fixed
|
10
|
+
- user activation
|
11
|
+
## [4.1.0] - 2021-10-23
|
12
|
+
### Fixed
|
13
|
+
- missing default settings template in generator:setup
|
14
|
+
### Added
|
15
|
+
- rubocop-rails
|
16
|
+
- rubocop-rspec
|
17
|
+
### Removed
|
18
|
+
- mini_racer
|
19
|
+
### Changed
|
20
|
+
- split SASS files
|
21
|
+
|
22
|
+
## [4.0.0] - 2021-05-18
|
8
23
|
### Removed
|
9
24
|
- development dependency in gemspec replaced by `symphonia_spec` gem
|
10
25
|
- GenericColumn in Query
|
@@ -0,0 +1,29 @@
|
|
1
|
+
@import 'font-awesome';
|
2
|
+
/* Font awesome aliases */
|
3
|
+
.fa-add {
|
4
|
+
@extend .fa-plus-circle !optional;
|
5
|
+
}
|
6
|
+
.fa-delete, .fa-del {
|
7
|
+
@extend .fa-trash-o !optional;
|
8
|
+
}
|
9
|
+
.fa-back {
|
10
|
+
@extend .fa-chevron-left !optional;
|
11
|
+
}
|
12
|
+
.fa-true {
|
13
|
+
@extend .fa-check !optional;
|
14
|
+
}
|
15
|
+
.fa-false {
|
16
|
+
@extend .fa-times !optional;
|
17
|
+
}
|
18
|
+
.fa-notice {
|
19
|
+
@extend .fa-check-circle !optional;
|
20
|
+
}
|
21
|
+
.fa-error {
|
22
|
+
@extend .fa-times-circle !optional;
|
23
|
+
}
|
24
|
+
.alert .fa-info {
|
25
|
+
@extend .fa-info-circle !optional;
|
26
|
+
}
|
27
|
+
[class^="fa-"]:before:hover, a[class*=" fa-"]:before:hover {
|
28
|
+
text-decoration: none
|
29
|
+
}
|
@@ -0,0 +1,40 @@
|
|
1
|
+
@import "bootstrap";
|
2
|
+
|
3
|
+
// fixed navbar
|
4
|
+
body > .container {
|
5
|
+
padding-top: 80px;
|
6
|
+
}
|
7
|
+
|
8
|
+
@media print {
|
9
|
+
body > .container {
|
10
|
+
padding-top: 0 !important;
|
11
|
+
}
|
12
|
+
}
|
13
|
+
|
14
|
+
footer.footer {
|
15
|
+
height: 40px;
|
16
|
+
line-height: 40px;
|
17
|
+
bottom: 0;
|
18
|
+
width: 100%;
|
19
|
+
}
|
20
|
+
|
21
|
+
@keyframes highlight {
|
22
|
+
from {
|
23
|
+
background-color: map-get($theme-colors, warning);
|
24
|
+
}
|
25
|
+
to {
|
26
|
+
background-color: inherit;
|
27
|
+
}
|
28
|
+
}
|
29
|
+
|
30
|
+
@media print {
|
31
|
+
.contextual {
|
32
|
+
@extend .d-print-none;
|
33
|
+
}
|
34
|
+
a[href]:after {
|
35
|
+
content: none
|
36
|
+
}
|
37
|
+
.btn {
|
38
|
+
@extend .d-print-none;
|
39
|
+
}
|
40
|
+
}
|
@@ -1,37 +1,5 @@
|
|
1
|
-
@import
|
2
|
-
/* Font awesome aliases */
|
3
|
-
.fa-add {
|
4
|
-
//@extend .fa-plus-circle:before;
|
5
|
-
@extend .fa-plus-circle !optional;
|
6
|
-
}
|
7
|
-
.fa-delete, .fa-del {
|
8
|
-
@extend .fa-trash-o !optional;
|
9
|
-
}
|
10
|
-
.fa-back {
|
11
|
-
@extend .fa-chevron-left !optional;
|
12
|
-
}
|
13
|
-
.fa-true {
|
14
|
-
@extend .fa-check !optional;
|
15
|
-
}
|
16
|
-
.fa-false {
|
17
|
-
@extend .fa-times !optional;
|
18
|
-
}
|
1
|
+
@import "_font_awesome";
|
19
2
|
|
20
|
-
.fa-notice {
|
21
|
-
@extend .fa-check-circle !optional;
|
22
|
-
}
|
23
|
-
.fa-error {
|
24
|
-
@extend .fa-times-circle !optional;
|
25
|
-
}
|
26
|
-
.alert .fa-info {
|
27
|
-
@extend .fa-info-circle !optional;
|
28
|
-
}
|
29
|
-
[class^="fa-"]:before, [class*=" fa-"]:before {
|
30
|
-
//padding-right: 5px;
|
31
|
-
}
|
32
|
-
[class^="fa-"]:before:hover, a[class*=" fa-"]:before:hover {
|
33
|
-
text-decoration: none
|
34
|
-
}
|
35
3
|
.page-header.title, .page-header.title h1 {
|
36
4
|
margin-top: 0;
|
37
5
|
}
|
@@ -40,7 +8,6 @@
|
|
40
8
|
}
|
41
9
|
.reorder, .reorder label {
|
42
10
|
cursor: move;
|
43
|
-
cursor: -webkit-grabbing;
|
44
11
|
}
|
45
12
|
|
46
13
|
.flash {
|
@@ -76,9 +43,7 @@
|
|
76
43
|
content: "\f05d"
|
77
44
|
}
|
78
45
|
}
|
79
|
-
|
80
|
-
display: none;
|
81
|
-
}
|
46
|
+
|
82
47
|
.nodata, .no-data {
|
83
48
|
@extend .flash;
|
84
49
|
@extend .info;
|
@@ -217,4 +182,4 @@ table.table {
|
|
217
182
|
.sortable-ghost {
|
218
183
|
//border: 2px solid black;
|
219
184
|
box-shadow: inset 0 0 5px #000000;
|
220
|
-
}
|
185
|
+
}
|
@@ -1,47 +1,2 @@
|
|
1
|
-
|
2
|
-
// *= require rails_bootstrap_forms
|
3
|
-
// *= require bootstrap-datepicker3
|
4
|
-
//@import "bootstrap-sprockets";
|
5
|
-
|
6
|
-
@import "bootstrap";
|
1
|
+
@import "layout";
|
7
2
|
@import "bootstrap-datepicker3";
|
8
|
-
|
9
|
-
|
10
|
-
// fixed navbar
|
11
|
-
body > .container {
|
12
|
-
padding-top: 80px;
|
13
|
-
}
|
14
|
-
|
15
|
-
@media print {
|
16
|
-
body > .container {
|
17
|
-
padding-top: 0 !important;
|
18
|
-
}
|
19
|
-
}
|
20
|
-
|
21
|
-
footer.footer {
|
22
|
-
height: 40px;
|
23
|
-
line-height: 40px;
|
24
|
-
bottom: 0;
|
25
|
-
width: 100%;
|
26
|
-
}
|
27
|
-
|
28
|
-
@keyframes highlight {
|
29
|
-
from {
|
30
|
-
background-color: map-get($theme-colors, warning);
|
31
|
-
}
|
32
|
-
to {
|
33
|
-
background-color: inherit;
|
34
|
-
}
|
35
|
-
}
|
36
|
-
|
37
|
-
@media print {
|
38
|
-
.contextual {
|
39
|
-
@extend .d-print-none;
|
40
|
-
}
|
41
|
-
a[href]:after {
|
42
|
-
content: none
|
43
|
-
}
|
44
|
-
.btn {
|
45
|
-
@extend .d-print-none;
|
46
|
-
}
|
47
|
-
}
|
@@ -5,8 +5,6 @@ module Symphonia
|
|
5
5
|
before_action -> { menu_item(:my_account) }, only: [:show, :edit, :update]
|
6
6
|
before_action :prepare_user, only: [:register, :create]
|
7
7
|
|
8
|
-
helper Recaptcha::ClientHelper if defined? Recaptcha
|
9
|
-
|
10
8
|
def show
|
11
9
|
@user = current_account
|
12
10
|
|
@@ -32,7 +30,7 @@ module Symphonia
|
|
32
30
|
if @user.valid? && verify_registration && @user.save(validate: false)
|
33
31
|
Notifier.activation_user(@user).deliver_later
|
34
32
|
Notifier.user_registered(@user).deliver_later
|
35
|
-
format.html { redirect_to
|
33
|
+
format.html { redirect_to login_path, notice: t(:text_user_registered) }
|
36
34
|
format.json { render status: :created }
|
37
35
|
else
|
38
36
|
format.html { render action: 'register' }
|
@@ -71,14 +69,14 @@ module Symphonia
|
|
71
69
|
@user = find_account_by_mail(params.require(:email))
|
72
70
|
if @user
|
73
71
|
if @user.active?
|
74
|
-
redirect_to
|
72
|
+
redirect_to login_path, flash: { error: t(:text_user_alerady_active) }
|
75
73
|
else
|
76
74
|
@user.reset_perishable_token!
|
77
75
|
Notifier.activation_user(@user).deliver_later
|
78
|
-
redirect_to
|
76
|
+
redirect_to login_path, notice: t(:text_activation_resend)
|
79
77
|
end
|
80
78
|
else
|
81
|
-
redirect_to
|
79
|
+
redirect_to login_path, flash: { error: t(:text_user_not_found) }
|
82
80
|
end
|
83
81
|
end
|
84
82
|
|
@@ -88,7 +86,7 @@ module Symphonia
|
|
88
86
|
@user.activate!
|
89
87
|
redirect_to login_path, notice: t(:text_activation_success)
|
90
88
|
else
|
91
|
-
redirect_to
|
89
|
+
redirect_to login_path, flash: { error: t(:text_user_not_found_or_token_invalid) }
|
92
90
|
end
|
93
91
|
end
|
94
92
|
|
@@ -159,11 +157,7 @@ module Symphonia
|
|
159
157
|
|
160
158
|
# @return [Boolean]
|
161
159
|
def verify_registration
|
162
|
-
|
163
|
-
verify_recaptcha(model: @user)
|
164
|
-
else
|
165
|
-
true
|
166
|
-
end
|
160
|
+
true
|
167
161
|
end
|
168
162
|
|
169
163
|
end
|
@@ -28,7 +28,7 @@ module Symphonia
|
|
28
28
|
end
|
29
29
|
end
|
30
30
|
|
31
|
-
|
31
|
+
s.html_safe
|
32
32
|
end
|
33
33
|
|
34
34
|
def render_menu(menu, options = {})
|
@@ -38,7 +38,7 @@ module Symphonia
|
|
38
38
|
end
|
39
39
|
options[:container_class] ||= 'mr-auto'
|
40
40
|
|
41
|
-
|
41
|
+
content_tag(:ul, s.html_safe, itemscope: '', itemtype: 'http://schema.org/BreadcrumbList', class: "navbar-nav #{options[:container_class]}", id: menu.to_s)
|
42
42
|
end
|
43
43
|
|
44
44
|
def render_menu_node(menu, item, options = {})
|
@@ -5,9 +5,9 @@
|
|
5
5
|
<title><%= html_title %></title>
|
6
6
|
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
7
7
|
<%= yield :meta_tags %>
|
8
|
-
<%= stylesheet_link_tag 'application', :
|
8
|
+
<%= stylesheet_link_tag 'application', media: 'all', 'data-turbolinks-track': true %>
|
9
9
|
<%= yield :stylesheet_tags %>
|
10
|
-
<%= javascript_include_tag 'application', 'data-turbolinks-track'
|
10
|
+
<%= javascript_include_tag 'application', 'data-turbolinks-track': true %>
|
11
11
|
<script type="text/javascript">
|
12
12
|
Symphonia.routes.reorderImagesPath = '<%= symphonia.reorder_attachment_path %>';
|
13
13
|
</script>
|
@@ -9,11 +9,9 @@
|
|
9
9
|
</div>
|
10
10
|
<div class="col-lg-8">
|
11
11
|
<%= f.text_field :first_name, required: true %>
|
12
|
-
|
13
12
|
</div>
|
14
13
|
<div class="col-lg-8">
|
15
14
|
<%= f.text_field :last_name, required: true %>
|
16
|
-
|
17
15
|
</div>
|
18
16
|
<div class="col-lg-8">
|
19
17
|
<% if f.object.external_id.blank? %>
|
@@ -21,5 +19,3 @@
|
|
21
19
|
<% end %>
|
22
20
|
</div>
|
23
21
|
</div>
|
24
|
-
|
25
|
-
|
@@ -8,20 +8,10 @@
|
|
8
8
|
<%= symphonia_form_for(@user, url: account_register_path) do |f| %>
|
9
9
|
<div style="width:1px;height: 1px;visibility: hidden"><%= check_box_tag :terms, true %></div>
|
10
10
|
<%= f.error_messages %>
|
11
|
-
<%= f.
|
12
|
-
<%= f.
|
13
|
-
<%= f.password_field :password, required: true, prepend: icon('key') %>
|
14
|
-
|
15
|
-
<fieldset>
|
16
|
-
<%= content_tag(:legend, t(:text_explanation_recaptcha)) %>
|
17
|
-
<div class="form-group">
|
18
|
-
<div class="col-sm-offset-4 col-sm-5">
|
19
|
-
<%#= invisible_recaptcha_tags %>
|
20
|
-
<%= recaptcha_tags(:display => { :theme => 'white' }) %>
|
21
|
-
</div>
|
22
|
-
</div>
|
23
|
-
</fieldset>
|
24
|
-
<% end %>
|
11
|
+
<%= f.text_field :name, required: true, autocomplete: "off", prepend: icon("user") %>
|
12
|
+
<%= f.email_field :mail, required: true, autocomplete: "username", prepend: "@" %>
|
13
|
+
<%= f.password_field :password, autocomplete: "new-password", required: true, prepend: icon('key') %>
|
14
|
+
|
25
15
|
<%= f.primary t(:button_register), class: 'btn btn-primary btn-block' %>
|
26
16
|
<% end %>
|
27
17
|
</div>
|
@@ -1,8 +1,8 @@
|
|
1
1
|
<%= f.error_messages %>
|
2
|
-
<%= hidden_field_tag(:back_url,
|
3
|
-
<%= f.text_field :login, required: true, autofocus: true %>
|
2
|
+
<%= hidden_field_tag(:back_url, back_url || session[:back_url]) %>
|
3
|
+
<%= f.text_field :login, required: true, autofocus: true, autocomplete: "username" %>
|
4
4
|
|
5
|
-
<%= f.password_field :password, required: true %>
|
5
|
+
<%= f.password_field :password, required: true, autocomplete: "current-password" %>
|
6
6
|
|
7
7
|
<%= f.form_group :remember_me do %>
|
8
8
|
<%= f.check_box :remember_me %>
|
data/config/locales/cs.yml
CHANGED
@@ -79,10 +79,6 @@ cs:
|
|
79
79
|
role_id: 'Role'
|
80
80
|
ssl: Používat SSL?
|
81
81
|
|
82
|
-
recaptcha:
|
83
|
-
errors:
|
84
|
-
verification_failed: 'Nesprávný text z obrázku'
|
85
|
-
|
86
82
|
helpers:
|
87
83
|
submit:
|
88
84
|
create: Vytvořit
|
@@ -144,7 +140,6 @@ cs:
|
|
144
140
|
text_user_not_found: Účet nenalezen
|
145
141
|
text_activation_resend: Aktivační odkaz odeslán
|
146
142
|
text_reset_password_resend: Informace o změně hesla odeslány
|
147
|
-
text_explanation_recaptcha: 'Opište prosím tato dvě slova:'
|
148
143
|
text_or: nebo
|
149
144
|
text_confirm_send_unlock_mail: Po aktivaci účtu bude uživateli zaslán email.
|
150
145
|
text_error_no_data_file_input: Nebyl vybrán žádný soubor
|
@@ -6,7 +6,7 @@ module Symphonia
|
|
6
6
|
source_root File.expand_path('templates', __dir__)
|
7
7
|
|
8
8
|
def create_settings
|
9
|
-
template 'config/initializers/
|
9
|
+
template 'config/initializers/symphonia.rb'
|
10
10
|
end
|
11
11
|
|
12
12
|
def copy_static
|
@@ -47,7 +47,7 @@ module Symphonia
|
|
47
47
|
|
48
48
|
def setup_gemfile
|
49
49
|
append_to_file 'Gemfile' do
|
50
|
-
"gem '
|
50
|
+
"gem 'symphonia_spec', source: 'https://gems.luk4s.cz', group: %w[development test]"
|
51
51
|
end
|
52
52
|
|
53
53
|
end
|
@@ -1,10 +1,5 @@
|
|
1
1
|
# encoding: utf-8
|
2
2
|
|
3
|
-
# Recaptcha.configure do |config|
|
4
|
-
# config.site_key = '6LejxOESAAAAALC3ohQCddKilokhYnTNXfYVItZe'
|
5
|
-
# config.secret_key = '6LejxOESAAAAANf-9T4nyHCDGW6Ok78Zo7GaG2GK'
|
6
|
-
# end
|
7
|
-
|
8
3
|
WillPaginate.per_page = 20
|
9
4
|
# Rails.application.config.i18n.available_locales = %i[en cs ru pl]
|
10
5
|
|
@@ -0,0 +1,48 @@
|
|
1
|
+
Symphonia.configure do |config|
|
2
|
+
config.after_login_path = ->(h) { h.symphonia.user_current_path }
|
3
|
+
config.allow_registrations = false
|
4
|
+
config.default_locale = :cs
|
5
|
+
end
|
6
|
+
|
7
|
+
# Symphonia::MenuManager.map :top_menu do |m|
|
8
|
+
# m[:home] = {
|
9
|
+
# label: :label_home,
|
10
|
+
# icon: 'fa fa-home',
|
11
|
+
# url: '/'
|
12
|
+
# }
|
13
|
+
# m[:users] = {
|
14
|
+
# label: :label_users,
|
15
|
+
# icon: 'fa fa-user',
|
16
|
+
# url: ->(h) { h.symphonia.users_path },
|
17
|
+
# if: proc { Symphonia::User.current.admin? }
|
18
|
+
# }
|
19
|
+
# m[:roles] = {
|
20
|
+
# label: :label_roles,
|
21
|
+
# icon: 'fa fa-key',
|
22
|
+
# url: ->(h) { h.symphonia.roles_path },
|
23
|
+
# if: proc { Symphonia::User.current.admin? }
|
24
|
+
# }
|
25
|
+
#
|
26
|
+
# end
|
27
|
+
# Symphonia::MenuManager.map :top_menu_account do |m|
|
28
|
+
# # -----
|
29
|
+
# m[:my_account] = {
|
30
|
+
# label: :label_my_account,
|
31
|
+
# icon: 'fa fa-wrench',
|
32
|
+
# url: ->(h) { h.symphonia.account_path },
|
33
|
+
# if: proc { Symphonia::User.current.logged_in? }
|
34
|
+
# }
|
35
|
+
# m[:logout] = {
|
36
|
+
# label: :button_logout,
|
37
|
+
# icon: 'fa fa-sign-out',
|
38
|
+
# url: ->(h) { h.symphonia.logout_path },
|
39
|
+
# method: 'delete',
|
40
|
+
# if: proc { Symphonia::User.current.logged_in? }
|
41
|
+
# }
|
42
|
+
# m[:login] = {
|
43
|
+
# label: :button_login,
|
44
|
+
# icon: 'fa fa-signin',
|
45
|
+
# url: ->(h) { h.symphonia.login_path },
|
46
|
+
# if: proc { !Symphonia::User.current.logged_in? }
|
47
|
+
# }
|
48
|
+
# end
|
@@ -3,13 +3,13 @@
|
|
3
3
|
<head>
|
4
4
|
<meta charset="UTF-8">
|
5
5
|
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
6
|
-
<title>404
|
6
|
+
<title>404 Stránka nenalezena</title>
|
7
7
|
<link rel="stylesheet" href="//stackpath.bootstrapcdn.com/font-awesome/4.7.0/css/font-awesome.min.css" />
|
8
8
|
<link rel="stylesheet" href="//stackpath.bootstrapcdn.com/bootstrap/4.4.1/css/bootstrap.min.css" integrity="sha384-Vkoo8x4CGsO3+Hhxv8T/Q5PaXtkKtu6ug5TOeNV6gBiFeWPGFN9MuhOf23Q9Ifjh" crossorigin="anonymous">
|
9
9
|
</head>
|
10
10
|
|
11
11
|
<body>
|
12
|
-
<!-- This file lives in public/
|
12
|
+
<!-- This file lives in public/404.html -->
|
13
13
|
<br />
|
14
14
|
<div class="rows">
|
15
15
|
<p class="col-sm-6 col-md-3">
|
@@ -21,17 +21,6 @@
|
|
21
21
|
<p>
|
22
22
|
Při zpracování požadavku došlo k vnitřní chybě serveru. Kontaktujte prosím administrátora.
|
23
23
|
</p>
|
24
|
-
<ul class="fa-ul">
|
25
|
-
<li>
|
26
|
-
<h3>Lukáš Pokorný</h3>
|
27
|
-
</li>
|
28
|
-
<li>
|
29
|
-
<i class="fa fa-li fa-envelope"></i>e-mail: <a href="mailto:admin@lagrace.cz">admin@luk4s.cz</a>
|
30
|
-
</li>
|
31
|
-
<li>
|
32
|
-
<i class="fa fa-li fa-mobile-phone"></i>tel: 604484983
|
33
|
-
</li>
|
34
|
-
</ul>
|
35
24
|
</div>
|
36
25
|
</div>
|
37
26
|
</div>
|
@@ -9,17 +9,15 @@ module Symphonia
|
|
9
9
|
|
10
10
|
def connect
|
11
11
|
self.current_user = find_verified_user_or_guest
|
12
|
-
logger.add_tags 'ActionCable',
|
12
|
+
logger.add_tags 'ActionCable', current_user.login unless current_user.nil?
|
13
13
|
end
|
14
14
|
|
15
15
|
protected
|
16
16
|
|
17
17
|
def find_verified_user_or_guest
|
18
|
-
if (credentials = request.session["symphonia/user_credentials"]).
|
19
|
-
|
20
|
-
|
21
|
-
nil
|
22
|
-
end
|
18
|
+
return if (credentials = request.session["symphonia/user_credentials"]).blank?
|
19
|
+
|
20
|
+
::Symphonia::User.find_by(persistence_token: credentials.split(':')[0])
|
23
21
|
end
|
24
22
|
end
|
25
23
|
|
@@ -28,4 +26,4 @@ module Symphonia
|
|
28
26
|
|
29
27
|
end
|
30
28
|
end
|
31
|
-
end
|
29
|
+
end
|
@@ -1,10 +1,12 @@
|
|
1
1
|
module Symphonia
|
2
2
|
class AdminConstraint
|
3
|
+
|
3
4
|
def matches?(request)
|
4
5
|
return false if (credentials = request.session["symphonia/user_credentials"]).blank?
|
5
6
|
|
6
7
|
user = User.find_by_persistence_token(credentials.split(':')[0])
|
7
8
|
user&.admin?
|
8
9
|
end
|
10
|
+
|
9
11
|
end
|
10
|
-
end
|
12
|
+
end
|
@@ -3,69 +3,39 @@ module Symphonia
|
|
3
3
|
|
4
4
|
extend ActiveSupport::Concern
|
5
5
|
|
6
|
+
class Unauthorized < RuntimeError
|
7
|
+
end
|
6
8
|
|
7
9
|
included do
|
8
|
-
class Unauthorized < Exception;
|
9
|
-
end
|
10
10
|
|
11
11
|
before_action :current_user, :menu_item
|
12
12
|
before_action :set_default_locale
|
13
13
|
|
14
|
-
# force_ssl if: -> {Rails.env.production? && User.current.ssl?}
|
15
|
-
|
16
14
|
add_flash_types :notice
|
17
15
|
add_flash_types :info
|
18
16
|
add_flash_types :warning
|
19
17
|
add_flash_types :error
|
20
18
|
|
21
|
-
rescue_from ::ActiveRecord::RecordNotFound
|
22
|
-
|
23
|
-
end
|
24
|
-
|
25
|
-
rescue_from Unauthorized do
|
26
|
-
render_403
|
27
|
-
end
|
28
|
-
|
29
|
-
helper_method :current_user
|
19
|
+
rescue_from ::ActiveRecord::RecordNotFound, with: :render_404
|
20
|
+
rescue_from Unauthorized, with: :render_403
|
30
21
|
|
22
|
+
helper_method :current_user, :back_url
|
31
23
|
end
|
32
24
|
|
33
25
|
def back_url
|
34
|
-
url = params[:back_url]
|
35
|
-
if url.nil? && (referer = request.env['HTTP_REFERER'])
|
26
|
+
url = params[:back_url].presence
|
27
|
+
if url.nil? && (referer = request.env['HTTP_REFERER'].presence)
|
36
28
|
url = CGI.unescape(referer.to_s)
|
37
29
|
end
|
38
30
|
url
|
39
31
|
end
|
40
32
|
|
41
|
-
# def redirect_back_or_default(default, options={})
|
42
|
-
# back_url = params[:back_url].to_s
|
43
|
-
# if back_url.present?
|
44
|
-
# begin
|
45
|
-
# uri = URI.parse(back_url)
|
46
|
-
# # do not redirect user to another host or to the login or register page
|
47
|
-
# if (uri.relative? || (uri.host == request.host)) && !uri.path.match(%r{/(login|account/register)})
|
48
|
-
# redirect_to(back_url)
|
49
|
-
# return
|
50
|
-
# end
|
51
|
-
# rescue URI::InvalidURIError
|
52
|
-
# logger.warn("Could not redirect to invalid URL #{back_url}")
|
53
|
-
# # redirect to default
|
54
|
-
# end
|
55
|
-
# elsif options[:referer]
|
56
|
-
# redirect_to_referer_or default
|
57
|
-
# return
|
58
|
-
# end
|
59
|
-
# redirect_to default, options
|
60
|
-
# false
|
61
|
-
# end
|
62
|
-
|
63
33
|
# Redirects to the request referer if present, redirects to args or call block otherwise.
|
64
34
|
def redirect_to_referer_or(*args, &block)
|
65
35
|
redirect_to :back
|
66
36
|
rescue ::ActionController::RedirectBackError
|
67
37
|
if args.any?
|
68
|
-
redirect_to
|
38
|
+
redirect_to(*args)
|
69
39
|
elsif block_given?
|
70
40
|
block.call
|
71
41
|
else
|
@@ -76,7 +46,10 @@ module Symphonia
|
|
76
46
|
# private
|
77
47
|
|
78
48
|
def set_locale
|
79
|
-
|
49
|
+
params_locale = params.fetch(:locale, nil).presence
|
50
|
+
params_locale ||= session[:locale].presence
|
51
|
+
params_locale ||= request.env['HTTP_ACCEPT_LANGUAGE'].to_s.split(',').collect { |l| l.scan(/^[a-z]{2}/) }.flatten
|
52
|
+
client_lang = Array(params_locale).compact
|
80
53
|
client_lang.unshift current_user.language if current_user.language
|
81
54
|
@client_lang = client_lang.detect { |l| I18n.available_locales.include?(l.to_sym) }
|
82
55
|
|
@@ -87,53 +60,57 @@ module Symphonia
|
|
87
60
|
end
|
88
61
|
|
89
62
|
def set_default_locale
|
90
|
-
|
91
|
-
|
92
|
-
|
63
|
+
return unless (enforce_default = Symphonia.config.default_locale)
|
64
|
+
|
65
|
+
I18n.locale = enforce_default
|
93
66
|
end
|
94
67
|
|
95
68
|
# protected
|
96
69
|
|
97
|
-
def login_require(
|
70
|
+
def login_require(_format = nil)
|
98
71
|
if current_user.nil? || !current_user.logged_in?
|
99
72
|
respond_to do |format|
|
100
73
|
format.html do
|
101
74
|
store_location
|
102
75
|
redirect_to symphonia.login_path, flash: { error: t(:text_login_require) }
|
103
76
|
end
|
104
|
-
format.json
|
105
|
-
|
77
|
+
format.json do
|
78
|
+
render json: { errors: 'You must be logged in to access this endpoint' }, status: :unauthorized
|
79
|
+
end
|
80
|
+
format.any { head :unauthorized }
|
106
81
|
end
|
107
82
|
return false
|
108
83
|
end
|
109
84
|
true
|
110
85
|
end
|
111
86
|
|
112
|
-
|
113
|
-
|
87
|
+
alias require_login login_require
|
88
|
+
alias require_user login_require
|
114
89
|
|
115
90
|
def admin_require
|
116
91
|
return unless login_require
|
117
92
|
|
118
93
|
unless current_user.admin?
|
119
94
|
render_403
|
120
|
-
|
95
|
+
false
|
121
96
|
end
|
122
97
|
end
|
123
98
|
|
124
|
-
|
99
|
+
alias require_admin admin_require
|
125
100
|
|
126
101
|
def render_403
|
127
102
|
respond_to do |format|
|
128
|
-
format.html { render template: 'common/403', message: :notice_not_authorized, status:
|
129
|
-
format.js
|
103
|
+
format.html { render template: 'common/403', message: :notice_not_authorized, status: :forbidden }
|
104
|
+
format.js do
|
105
|
+
render plain: "alert('#{t :text_access_deny}')", message: :notice_not_authorized, status: :forbidden
|
106
|
+
end
|
130
107
|
format.any { head 403, message: :notice_not_authorized }
|
131
108
|
end
|
132
109
|
end
|
133
110
|
|
134
111
|
def render_404
|
135
112
|
respond_to do |format|
|
136
|
-
format.html { render template: 'common/404', message: :notice_page_not_found, status:
|
113
|
+
format.html { render template: 'common/404', message: :notice_page_not_found, status: :not_found }
|
137
114
|
format.any { head 404, message: :not_found }
|
138
115
|
end
|
139
116
|
end
|
@@ -161,35 +138,32 @@ module Symphonia
|
|
161
138
|
def current_user
|
162
139
|
return (Symphonia::User.current ||= @current_user) if defined?(@current_user)
|
163
140
|
|
164
|
-
@current_user = current_user_session
|
141
|
+
@current_user = current_user_session&.user
|
165
142
|
Symphonia::User.current = @current_user || Symphonia::User::Anonymous.new
|
166
143
|
end
|
167
144
|
|
168
145
|
def authorize
|
169
146
|
if Symphonia::User.current.authorize?(controller_name, action_name)
|
170
147
|
return true
|
148
|
+
elsif Symphonia::User.current.logged_in?
|
149
|
+
raise Unauthorized
|
171
150
|
else
|
172
|
-
|
173
|
-
|
174
|
-
|
175
|
-
respond_to do |format|
|
176
|
-
format.html do
|
177
|
-
return redirect_to(symphonia.login_path(back_url: request.path), error: t(:text_error_login_required))
|
178
|
-
end
|
179
|
-
format.any { return head 401 }
|
151
|
+
respond_to do |format|
|
152
|
+
format.html do
|
153
|
+
return redirect_to(symphonia.login_path(back_url: request.path), error: t(:text_error_login_required))
|
180
154
|
end
|
155
|
+
format.any { return head 401 }
|
181
156
|
end
|
182
157
|
end
|
158
|
+
|
183
159
|
raise Unauthorized
|
184
160
|
end
|
185
161
|
|
186
162
|
def handle_unverified_request
|
187
163
|
# raise an exception
|
188
|
-
|
164
|
+
raise ActionController::InvalidAuthenticityToken
|
189
165
|
# or destroy session, redirect
|
190
|
-
|
191
|
-
current_user_session.destroy
|
192
|
-
end
|
166
|
+
current_user_session&.destroy
|
193
167
|
redirect_to main_app.root_url
|
194
168
|
end
|
195
169
|
|
@@ -11,7 +11,6 @@ module Symphonia
|
|
11
11
|
|
12
12
|
validates :email, presence: true, uniqueness: { case_sensitive: false }
|
13
13
|
validates :login, presence: true, uniqueness: { case_sensitive: false }
|
14
|
-
validates :first_name, presence: true
|
15
14
|
|
16
15
|
before_validation :set_uuid, only: -> { uuid.blank? }
|
17
16
|
before_validation :set_login, only: -> { login.blank? }
|
data/lib/symphonia/version.rb
CHANGED
@@ -6,8 +6,8 @@ RSpec.describe Symphonia::AccountsController do
|
|
6
6
|
|
7
7
|
let(:regular_user) { FactoryBot.create(:user) }
|
8
8
|
|
9
|
-
context 'logged', logged: true do
|
10
|
-
|
9
|
+
context 'with logged', logged: true do
|
10
|
+
describe '#update' do
|
11
11
|
|
12
12
|
it 'valid' do
|
13
13
|
put :update, params: { user: { login: Faker::Internet.user_name } }
|
@@ -22,53 +22,52 @@ RSpec.describe Symphonia::AccountsController do
|
|
22
22
|
end
|
23
23
|
end
|
24
24
|
|
25
|
-
|
25
|
+
describe '#resend_activation' do
|
26
26
|
|
27
27
|
let(:email) { Faker::Internet.email }
|
28
28
|
subject { get :resend_activation, params: { email: email } }
|
29
29
|
|
30
30
|
it 'non exist user' do
|
31
|
-
is_expected.to redirect_to :
|
31
|
+
is_expected.to redirect_to :login
|
32
32
|
expect(flash[:error]).not_to be :blank
|
33
33
|
end
|
34
34
|
|
35
35
|
it 'active user' do
|
36
36
|
_user = FactoryBot.create(:user, email: email, status: 'active')
|
37
|
-
is_expected.to redirect_to :
|
37
|
+
is_expected.to redirect_to :login
|
38
38
|
expect(flash[:error]).not_to be :blank
|
39
39
|
end
|
40
40
|
|
41
|
+
let(:pending_user) { FactoryBot.create(:user, email: email, status: 'pending') }
|
41
42
|
it 'pending user' do
|
42
|
-
|
43
|
-
token = user.perishable_token.dup
|
43
|
+
token = pending_user.perishable_token.dup
|
44
44
|
|
45
45
|
expect { get :resend_activation, params: { email: email } }.to have_enqueued_job.on_queue('mailers')
|
46
|
-
expect(response).to have_http_status :redirect
|
47
46
|
|
48
|
-
expect
|
47
|
+
expect { pending_user.reload }.to change(pending_user, :perishable_token)
|
49
48
|
expect(flash[:error]).to be_nil
|
50
49
|
expect(flash[:notice]).not_to be :blank
|
51
50
|
end
|
52
51
|
end
|
53
52
|
|
54
|
-
|
55
|
-
let(:token) { SecureRandom.hex(3) }
|
53
|
+
describe '#activation' do
|
56
54
|
subject { get :activation, params: { activation_code: token } }
|
55
|
+
let(:token) { SecureRandom.hex(3) }
|
56
|
+
let(:pending_user) { FactoryBot.create(:user, status: 'pending') }
|
57
57
|
|
58
58
|
it 'valid token' do
|
59
|
-
|
60
|
-
user.update_columns(perishable_token: token)
|
59
|
+
pending_user.update_columns(perishable_token: token)
|
61
60
|
is_expected.to redirect_to :login
|
62
|
-
expect
|
61
|
+
expect { pending_user.reload }.to change(pending_user, :status).to "active"
|
63
62
|
end
|
64
63
|
|
65
64
|
it 'invalid token' do
|
66
|
-
is_expected.to redirect_to :
|
65
|
+
is_expected.to redirect_to :login
|
67
66
|
expect(flash[:error]).not_to be :blank
|
68
67
|
end
|
69
68
|
end
|
70
69
|
|
71
|
-
|
70
|
+
describe '#lost_password' do
|
72
71
|
|
73
72
|
it 'with mail' do
|
74
73
|
user = FactoryBot.create(:user, status: 'active')
|
@@ -84,8 +83,9 @@ RSpec.describe Symphonia::AccountsController do
|
|
84
83
|
end
|
85
84
|
end
|
86
85
|
|
87
|
-
|
86
|
+
describe "#reset_password" do
|
88
87
|
subject { FactoryBot.create :user }
|
88
|
+
|
89
89
|
it "reset" do
|
90
90
|
put :reset_password, params: { id: subject.perishable_token, password: "secret-pass-1" }
|
91
91
|
expect(response).to redirect_to /login/
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: symphonia
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 4.
|
4
|
+
version: 4.1.2
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Lukas Pokorny
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2022-01-20 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: api-pagination
|
@@ -290,20 +290,6 @@ dependencies:
|
|
290
290
|
- - "~>"
|
291
291
|
- !ruby/object:Gem::Version
|
292
292
|
version: 3.3.0
|
293
|
-
- !ruby/object:Gem::Dependency
|
294
|
-
name: mini_racer
|
295
|
-
requirement: !ruby/object:Gem::Requirement
|
296
|
-
requirements:
|
297
|
-
- - "~>"
|
298
|
-
- !ruby/object:Gem::Version
|
299
|
-
version: '0.4'
|
300
|
-
type: :runtime
|
301
|
-
prerelease: false
|
302
|
-
version_requirements: !ruby/object:Gem::Requirement
|
303
|
-
requirements:
|
304
|
-
- - "~>"
|
305
|
-
- !ruby/object:Gem::Version
|
306
|
-
version: '0.4'
|
307
293
|
description: Basis of my applications
|
308
294
|
email:
|
309
295
|
- admin@luk4s.cz
|
@@ -333,6 +319,8 @@ files:
|
|
333
319
|
- app/assets/javascripts/symphonia/filters.js
|
334
320
|
- app/assets/javascripts/symphonia/symphonia_bootstrap_dialog.js
|
335
321
|
- app/assets/javascripts/symphonia/symphonia_ckeditor.js
|
322
|
+
- app/assets/stylesheets/symphonia/_font_awesome.scss
|
323
|
+
- app/assets/stylesheets/symphonia/_layout.scss
|
336
324
|
- app/assets/stylesheets/symphonia/application.css
|
337
325
|
- app/assets/stylesheets/symphonia/basic.scss
|
338
326
|
- app/assets/stylesheets/symphonia/filters.scss
|
@@ -435,6 +423,7 @@ files:
|
|
435
423
|
- lib/generators/symphonia/setup/templates/app/assets/javascripts/application.js.tt
|
436
424
|
- lib/generators/symphonia/setup/templates/app/config/initializers/settings.rb.tt
|
437
425
|
- lib/generators/symphonia/setup/templates/base_layout.html.erb
|
426
|
+
- lib/generators/symphonia/setup/templates/config/initializers/symphonia.rb.tt
|
438
427
|
- lib/generators/symphonia/setup/templates/design.scss
|
439
428
|
- lib/generators/symphonia/setup/templates/public/404.html.tt
|
440
429
|
- lib/generators/symphonia/setup/templates/public/500.html.tt
|