symphonia 3.2.4 → 3.4.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (47) hide show
  1. checksums.yaml +4 -4
  2. data/CHANGELOG.md +106 -0
  3. data/app/controllers/symphonia/accounts_controller.rb +14 -13
  4. data/app/controllers/symphonia/roles_controller.rb +3 -64
  5. data/app/controllers/symphonia/users_controller.rb +0 -5
  6. data/app/helpers/symphonia/application_helper.rb +18 -62
  7. data/app/mailers/symphonia/notifier.rb +2 -1
  8. data/app/models/symphonia/user.rb +1 -29
  9. data/app/views/layouts/symphonia/application.pdf.erb +0 -1
  10. data/app/views/symphonia/accounts/_form.html.erb +5 -0
  11. data/app/views/symphonia/accounts/lost_password.html.erb +1 -1
  12. data/app/views/symphonia/accounts/reset_password.html.erb +2 -2
  13. data/app/views/symphonia/login/_form.html.erb +0 -2
  14. data/app/views/symphonia/notifier/reset_password_user.html.erb +1 -2
  15. data/app/views/symphonia/notifier/reset_password_user.text.erb +1 -1
  16. data/config/locales/cs.yml +2 -0
  17. data/lib/symphonia.rb +0 -1
  18. data/lib/symphonia/base_controller.rb +0 -1
  19. data/lib/symphonia/controller_extensions.rb +2 -2
  20. data/lib/symphonia/engine.rb +5 -5
  21. data/lib/symphonia/user_management.rb +14 -4
  22. data/lib/symphonia/version.rb +1 -1
  23. data/spec/controllers/account_controller_spec.rb +1 -1
  24. data/spec/factories/factories.rb +2 -15
  25. data/spec/libs/some_lib_spec.rb +5 -0
  26. data/spec/mailers/previews/symphonia/notifier_preview.rb +1 -2
  27. data/spec/mailers/symphonia/notifier_spec.rb +1 -1
  28. data/spec/requests/accounts_spec.rb +2 -2
  29. data/spec/spec_helper.rb +1 -2
  30. metadata +36 -98
  31. data/app/controllers/concerns/symphonia/swagger/base_controller.rb +0 -134
  32. data/app/controllers/symphonia/api_controller.rb +0 -78
  33. data/app/controllers/symphonia/attachments_controller.rb +0 -37
  34. data/app/controllers/symphonia/images_controller.rb +0 -16
  35. data/app/models/symphonia/attachment.rb +0 -16
  36. data/app/models/symphonia/common_file.rb +0 -9
  37. data/app/models/symphonia/image.rb +0 -46
  38. data/app/models/symphonia/swagger/error_model.rb +0 -24
  39. data/app/models/symphonia/swagger/parameters.rb +0 -21
  40. data/app/models/symphonia/swagger/responses.rb +0 -27
  41. data/lib/symphonia/attachable.rb +0 -35
  42. data/spec/controllers/api_controller_spec.rb +0 -9
  43. data/spec/controllers/images_controller_spec.rb +0 -5
  44. data/spec/models/attachment_spec.rb +0 -22
  45. data/spec/requests/attachments_controller_spec.rb +0 -23
  46. data/spec/support/common_file.txt +0 -2
  47. data/spec/support/symphonia.jpg +0 -0
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: b8c4882e677df5174631e7c902cdd589ea7c7f8f42a1dbce8fa00b9105e27006
4
- data.tar.gz: 2b9451d2738bf8e8cb55646b8544c4448a9caa8e6ce18d61e9fdae9ecd115bd1
3
+ metadata.gz: 690d5654253b68fefb5088b8938130e37baf32e2ac3a533af0ded29909f66a01
4
+ data.tar.gz: 208b3dac35095799df42c565300f8c7877dad70a52ce966c6c7ad8e75048c710
5
5
  SHA512:
6
- metadata.gz: 1db4480246a6121eff843b2b158a969c39301319110318373ea2c6cf54ed5a6aae35f984cc34eee52fe6cf90f3f00525c2f75ecb04c7a128b53cf1b3570607f3
7
- data.tar.gz: 2f922eda59ca2e52695805829fc0de5b76cf7b679152e81eac2392c2538eadf40211226df007366b778ea0cc86ce7896215d5e9b084c7599ac1cdc41f60fcca2
6
+ metadata.gz: c23c2f1972886ac602da1fcd7fc0259b998a53787999bab18b7c320044b64a176a77227d20ec7d896868d74829464812f8a95a6910216e295f5b263dd65c3e65
7
+ data.tar.gz: caa04002e0307779c75a0542124e6ca09a76463fb27b23aec0aa079b81d0af0b8c8cfabed6541472bc146ac1c086087910196969b85c83251b7a865eb906e4fe
data/CHANGELOG.md ADDED
@@ -0,0 +1,106 @@
1
+ # Changelog
2
+ All notable changes to this project will be documented in this file.
3
+
4
+ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
5
+ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
6
+
7
+ ## [Unreleased]
8
+ ## [3.4.0] - 2021-03-22
9
+ ### Changed
10
+ - upgrade authlogic to 6.4.1 (rails6.1 compatible)
11
+
12
+ ## [3.3.4] - 2020-12-28
13
+ ### Fixed
14
+ - default responses (render_40x) works for any format
15
+ ## [3.3.3] - 2020-10-24
16
+ ### Changed
17
+ - prefill login from email
18
+ - allow login edit for legacy accounts
19
+ ## [3.3.2] - 2020-10-17
20
+ ### Added
21
+ - `render_super` for templates
22
+ ### Changed
23
+ - lost password check
24
+ ## [3.3.1] - 2020-09-28
25
+ ### Removed
26
+ - openapi (it seems to be unnecessarily)
27
+ - paperclip support
28
+ - the_sortable_tree
29
+ ### Changed
30
+ - upgrade authlogic to 6.2.0
31
+ ## [3.2.4] - 2020-05-10
32
+ ### Added
33
+ - sidekiq-cron gem
34
+ ## [3.2.3] - 2020-05-07
35
+ ### Fixed
36
+ - find user by token from session
37
+ ## [3.2.2] - 2020-05-05
38
+ ### Changed
39
+ - user/account form layout
40
+ - Sidekiq v6
41
+ ### Fixed
42
+ - UsersController#update Role should be sorted
43
+ ## [3.2.1] - 2020-05-01
44
+ ### Added
45
+ - avatar_url to users
46
+ - uuid to users
47
+ - openapi support
48
+ ### Changed
49
+ - improve setup generator
50
+ - anonymous user have no "enforced" language
51
+ ### Fixed
52
+ - update .rubocop
53
+ - bootstrap_form update to 4.4.0
54
+ - show time in localtime
55
+ ### Removed
56
+ - ckeditor-jquery
57
+ ## [3.1.5] - 2020-01-20
58
+ ### Changed
59
+ - improve split name (Symphonia::UserManagement#name=)
60
+ ## [3.1.4] - 2020-01-17
61
+ ### Changed
62
+ - improve role form
63
+ ## [3.1.3] - 2019-12-21
64
+ ### Added
65
+ - bootstrap_modal_helper extended by `link_to_modal` feature
66
+ ### Changed
67
+ - helper Symphonia::BootstrapModalHelper in BaseController
68
+ - new argument options in `icon` method (pass into `fa_icon`)
69
+ ## [3.1.2] - 2019-12-07
70
+ ### Added
71
+ - skip permission check in link_to_new_entity method
72
+ ### Fixed
73
+ - login form additional buttons
74
+ - lost_password form & mail
75
+ - reset_password form & mail
76
+ ## [3.1.1] - 2019-12-07
77
+ ### Changed
78
+ - accounts registration validation
79
+ - update static 500.html
80
+ ## [3.1.0] - 2019-12-07
81
+ ### Added
82
+ - BaseController for simplier create CRUD inheritance
83
+ - base views (new, form, edit, show and index)
84
+ - general EntityDecorator
85
+ - input field in model Attribute
86
+ - TextAttribute format
87
+ ### Changed
88
+ - registration form refactored
89
+ - update dummy to Rails 6
90
+ ### Removed
91
+ - wicked_pdf dependency
92
+ ## [3.0.3] - 2019-10-06
93
+ ### Changed
94
+ - rubocop.yml
95
+ - use real user in tests instead a dummy object
96
+ ## [3.0.1] - 2019-07-08
97
+ ### Changed
98
+ - do not require password for SSO users
99
+ - hide password field from form of SSO users
100
+ ## [3.0.0] - 2019-07-06
101
+ ### Added
102
+ - external_id on user
103
+ ### Changed
104
+ - users/show only for logged users
105
+ - upgrade to authlogic 5
106
+ - minor improvements
@@ -100,38 +100,39 @@ module Symphonia
100
100
 
101
101
  end
102
102
 
103
+ # @!group Reset lost password
104
+
103
105
  def reset_password
104
106
  @user = find_account_by_token(params.require(:id))
105
107
  return render_404 if @user.nil?
106
108
 
107
109
  if params[:password] # && params[:password_confirmation]
108
110
  @user.password = params[:password]
109
- # @user.password_confirmation = params[:password_confirmation]
110
111
  end
111
112
 
112
113
  if @user.changed? && @user.save
113
- return redirect_to(user_current_path, notice: t(:text_updated))
114
+ logger.info "#{@user.id} has changed password"
115
+ return redirect_to(login_path, notice: t(:text_password_reset_success))
114
116
  end
115
117
  end
116
118
 
117
119
  def lost_password
118
120
  @user = find_account_by_mail(params[:email]) if params[:email]
119
- if @user
120
- if @user.active?
121
- @user.reset_perishable_token!
122
- Notifier.reset_password_user(@user).deliver_later
121
+ if @user&.active?
122
+ @user.reset_perishable_token!
123
+ activation_url = url_for(action: "reset_password", id: @user.perishable_token, only_path: false)
124
+ Notifier.reset_password_user(@user, activation_url).deliver_later
125
+ end
126
+ respond_to do |format|
127
+ format.html do
123
128
  redirect_to login_path, notice: t(:text_reset_password_resend)
124
- else
125
- redirect_to login_path, flash: { error: t("authlogic.error_messages.not_active") }
126
- end
127
- else
128
- respond_to do |format|
129
- format.html
130
- format.js
131
129
  end
130
+ format.js
132
131
  end
133
132
  end
134
133
 
134
+ # @!endgroup
135
+
135
136
  private
136
137
 
137
138
  def prepare_user
@@ -14,87 +14,26 @@ module Symphonia
14
14
  #
15
15
  # before_action :authorize
16
16
  before_action :load_permissions, only: [:new, :edit, :update, :create]
17
- #
18
- # #layout 'admin'
19
- #
20
- # def index
21
- # @query = Symphonia::Role.query.new(self)
22
- # @entities = @query.entities
23
- # respond_to do |format|
24
- # format.html do
25
- # @entities = @entities.page(params[:page])
26
- # render layout: !request.xhr?
27
- # end
28
- # format.xml { render xml: @entities.all }
29
- # format.json { render json: @entities.all }
30
- # end
31
- # end
32
- #
33
- # def show
34
- # @role = Role.find(params[:id])
35
- # respond_to do |format|
36
- # format.html
37
- # format.json { render json: @role }
38
- # end
39
- # end
40
- #
41
- # def new
42
- # @role = Role.new
43
- # end
44
- #
45
- # def edit
46
- # @role = Role.find(params[:id])
47
- # end
48
17
 
49
18
  def create
50
19
  @entity = @role = Role.new(entity_params)
51
20
  @role.permissions = Symphonia::Permissions.find_all(params[:permissions]).map(&:name)
52
21
  super
53
- # respond_to do |format|
54
- # if @role.save
55
- # format.html { redirect_to((params[:continue] ? new_role_path : roles_path), notice: t(:text_created)) }
56
- # format.json { render(json: @role, status: :created, location: @role) }
57
- # else
58
- # format.html { render(action: 'new') }
59
- # format.json { render(json: @role.errors, status: :unprocessable_entity) }
60
- # end
61
- # end
62
22
  end
63
23
 
64
24
  def update
65
25
  @entity = @role = Role.find(params[:id])
66
26
  @role.permissions = Symphonia::Permissions.find_all(params[:permissions]).map(&:name)
67
27
  super
68
- # respond_to do |format|
69
- # if @role.update_attributes(role_params)
70
- # format.html { redirect_to(edit_role_path(@role), notice: t(:text_updated)) }
71
- # format.json { head(:no_content) }
72
- # else
73
- # format.html { render(action: 'edit') }
74
- # format.json { render(json: @role.errors, status: :unprocessable_entity) }
75
- # end
76
- # end
28
+
77
29
  end
78
30
 
79
- # def destroy
80
- # @role = Role.find(params[:id])
81
- # @role.destroy
82
- # respond_to do |format|
83
- # format.html { redirect_to(roles_url, notice: t(:text_destroyed)) }
84
- # format.json { head :no_content }
85
- # format.js { render js: "Symphonia.filters.removeRow('#{view_context.dom_id(@role)}')"}
86
- # end
87
- # end
88
- #
89
31
  private
90
- #
32
+
91
33
  def load_permissions
92
34
  @permissions = Symphonia::Permissions.all
93
35
  end
94
- #
95
- # def role_params
96
- # params.require(:role).permit(:name, :description, permissions: [])
97
- # end
36
+
98
37
  end
99
38
 
100
39
  end
@@ -1,10 +1,5 @@
1
1
  module Symphonia
2
2
  class UsersController < ApplicationController
3
- include Symphonia::Swagger::BaseController
4
- def self.tag_list
5
- %w[User admin]
6
- end
7
- swagger_me entity: "User", base_path: "/admin/users"
8
3
 
9
4
  helper Symphonia::RendererHelper
10
5
 
@@ -38,7 +38,7 @@ module Symphonia
38
38
  end
39
39
  options[:container_class] ||= 'mr-auto'
40
40
 
41
- return content_tag(:ul, s.html_safe, itemscope: '', itemtype: 'http://data-vocabulary.org/BreadcrumbList', class: "navbar-nav #{options[:container_class]}", id: menu.to_s)
41
+ return 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 = {})
@@ -242,6 +242,23 @@ module Symphonia
242
242
  fa_icon(fa, (text && { text: content_tag(:span, text, class: 'd-none d-sm-inline') } || {}).merge(options))
243
243
  end
244
244
 
245
+ # Render original template from engine
246
+ # Useful for override part of engine view
247
+ #
248
+ # @example render_super "login/new"
249
+ # @param [String] template_name
250
+ # @param [Class<Symphonia::Engine>] engine
251
+ # @param [String] format
252
+ def render_super(template_name, engine: Symphonia::Engine, format: "html")
253
+ resolver = lookup_context.view_paths.paths.find do |resolver|
254
+ resolver.path == engine.root.join("app", "views").to_s
255
+ end
256
+ template = resolver.find_all(template_name, engine.engine_name, false, { locale: ["."], formats: [format], variants: [], handlers: [:erb] }, nil, {}).first
257
+ return "" unless template
258
+
259
+ render template: template
260
+ end
261
+
245
262
  def render_symphonia_dialog(*args, &block)
246
263
  ActiveSupport::Deprecation.warn "Use `render_modal` instead"
247
264
  options = args.extract_options!
@@ -356,67 +373,6 @@ module Symphonia
356
373
  end
357
374
 
358
375
  end
359
-
360
- # Example of use
361
- # <%=
362
- # table_header_tag_for(User) do |t|
363
- # t.th :login
364
- # t.th :email
365
- # end
366
- # %>
367
- # options:
368
- # => column : DB full name of column
369
- #
370
- # def table_header_tag_for(model, &block)
371
- # tags = TableHeaderTag.new(model, self)
372
- # yield tags
373
- # tags.to_html
374
- # end
375
- #
376
- # class TableHeaderTag
377
- #
378
- # attr_reader :view, :model
379
- #
380
- # def initialize(model, view)
381
- # @model = model
382
- # @tags = Array.new
383
- # @view = view
384
- # end
385
- #
386
- # def th(*args)
387
- # options = args.extract_options!
388
- # attribute = args.first
389
- # label = args[1]
390
- # raise ArgumentError if attribute.nil?
391
- #
392
- # sort_options = options.delete(:sort_options) || {}
393
- # html_options = options.delete(:html_options) || {}
394
- #
395
- # label ||= @model.send(:human_attribute_name, attribute, options[:i18n] || {})
396
- # @tags << @view.content_tag(:th, html_options) do
397
- # if options[:sort] === false
398
- # label
399
- # else
400
- # sort_options[:column] ||= options.delete(:column)
401
- # sort_options[:column] ||= "#{@model.send(:table_name)}.#{attribute}"
402
- # # @view.sortable_column(label, sort_options) # TODO: Rails 5 error
403
- # label
404
- # end
405
- # end
406
- #
407
- # end
408
- #
409
- # def to_html
410
- # @tags.join("\n").html_safe
411
- # end
412
- #
413
- # end
414
-
415
- # def render_share_buttons(url, name, options = {})
416
- # options[:icon_css] ||= ''
417
- # render(partial: 'common/share_links', locals: options.merge({ url: url, name: name }))
418
- # end
419
376
  end
420
377
  end
421
378
 
422
- #ApplicationHelper.send :include, Symphonia::ApplicationHelperExtension
@@ -21,8 +21,9 @@ module Symphonia
21
21
  mail({ to: @user.mail, subject: 'Váš účet je aktivován' })
22
22
  end
23
23
 
24
- def reset_password_user(user)
24
+ def reset_password_user(user, url)
25
25
  @user = user
26
+ @url = url
26
27
  mail({ to: @user.mail, subject: t(:subject_reset_password_mail) })
27
28
  end
28
29
 
@@ -19,8 +19,8 @@ module Symphonia
19
19
  end
20
20
 
21
21
  acts_as_authentic do |config|
22
+ config.crypto_provider = ::Authlogic::CryptoProviders::SCrypt
22
23
  end
23
- validates :email, uniqueness: { case_sensitive: false }
24
24
  validates :password,
25
25
  confirmation: { if: :require_password? },
26
26
  length: {
@@ -30,31 +30,6 @@ module Symphonia
30
30
 
31
31
  include UserManagement
32
32
 
33
- include ::Swagger::Blocks
34
- swagger_component do
35
- schema :User do
36
- key :required, %w[id login email]
37
- property :id do
38
- key :type, "integer"
39
- key :format, "int64"
40
- end
41
- property :fist_name do
42
- key :type, "string"
43
- end
44
- property :last_name do
45
- key :type, "string"
46
- end
47
- property :email do
48
- key :type, "string"
49
- key :format, "email"
50
- end
51
- property :status do
52
- key :type, "string"
53
- key :enum, Symphonia::User.statuses.keys
54
- end
55
- end
56
- end
57
-
58
33
  attr_writer :password_confirmation
59
34
 
60
35
  has_and_belongs_to_many :preferences, foreign_key: 'user_id'
@@ -75,9 +50,6 @@ module Symphonia
75
50
  before_save do |model|
76
51
  Rails.cache.delete_matched('user_allowed_to*') if model.role_id_changed?
77
52
  end
78
- before_validation do |model|
79
- model.login ||= model.email
80
- end
81
53
 
82
54
  def allowed_to?(action)
83
55
  return true if admin?
@@ -10,6 +10,5 @@
10
10
  <section id="main" class="container-fluid">
11
11
  <%= yield %>
12
12
  </section>
13
-
14
13
  </body>
15
14
  </html>