ditty 0.6.0 → 0.7.0.pre.rc1

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.
Files changed (43) hide show
  1. checksums.yaml +4 -4
  2. data/.rubocop.yml +1 -4
  3. data/config.ru +4 -18
  4. data/ditty.gemspec +2 -0
  5. data/lib/ditty/components/app.rb +4 -3
  6. data/lib/ditty/controllers/application.rb +28 -5
  7. data/lib/ditty/controllers/auth.rb +179 -0
  8. data/lib/ditty/controllers/component.rb +1 -3
  9. data/lib/ditty/controllers/main.rb +6 -155
  10. data/lib/ditty/controllers/users.rb +1 -0
  11. data/lib/ditty/helpers/component.rb +50 -22
  12. data/lib/ditty/helpers/response.rb +1 -0
  13. data/lib/ditty/helpers/views.rb +10 -0
  14. data/lib/ditty/listener.rb +1 -1
  15. data/lib/ditty/middleware/accept_extension.rb +31 -0
  16. data/lib/ditty/models/user.rb +1 -5
  17. data/lib/ditty/policies/identity_policy.rb +10 -2
  18. data/lib/ditty/policies/user_policy.rb +8 -1
  19. data/lib/ditty/services/authentication.rb +16 -7
  20. data/lib/ditty/services/logger.rb +4 -3
  21. data/lib/ditty/services/settings.rb +8 -0
  22. data/lib/ditty/version.rb +1 -1
  23. data/views/400.haml +2 -0
  24. data/views/{identity/forgot.haml → auth/forgot_password.haml} +1 -1
  25. data/views/auth/identity.haml +15 -0
  26. data/views/auth/login.haml +18 -0
  27. data/views/auth/register.haml +19 -0
  28. data/views/auth/register_identity.haml +14 -0
  29. data/views/{identity/reset.haml → auth/reset_password.haml} +2 -3
  30. data/views/layout.haml +2 -2
  31. data/views/partials/actions.haml +6 -4
  32. data/views/partials/form_tag.haml +2 -1
  33. data/views/partials/navbar.haml +2 -3
  34. data/views/partials/search.haml +1 -1
  35. data/views/partials/sidebar.haml +3 -3
  36. data/views/roles/display.haml +1 -2
  37. data/views/roles/index.haml +0 -4
  38. data/views/users/display.haml +2 -4
  39. data/views/users/index.haml +11 -10
  40. data/views/users/profile.haml +2 -4
  41. metadata +41 -8
  42. data/views/identity/login.haml +0 -29
  43. data/views/identity/register.haml +0 -29
@@ -3,9 +3,8 @@
3
3
  .col-md-8
4
4
  .panel.panel-default
5
5
  .panel-body
6
- %form.form-horizontal{ method: 'post', action: "#{settings.map_path}/auth/identity/reset" }
7
- %input{ name: '_method', value: 'PUT', type: 'hidden' }
8
- %input{ name: 'token', value: params['token'], type: 'hidden' }
6
+ = edit_form_tag("#{settings.map_path}/auth/reset-password") do
7
+ %input{ name: 'token', value: params[:token], type: 'hidden' }
9
8
  - if identity.errors[:password] && identity.errors[:password].include?('is not strong enough')
10
9
  .alert.alert-warning
11
10
  %p Make sure your password is at least 8 characters long, and including the following
@@ -36,8 +36,8 @@
36
36
  #page-wrapper
37
37
  -if defined?(title) || defined?(actions)
38
38
  .row
39
- %h1.col-md-9= defined?(title) ? title : '&nbsp'
40
- .col-md-3.text-left{ style: 'margin-top: 20px' }
39
+ %h1.col-md-9= defined?(title) ? title : ' '
40
+ .col-md-3.text-right{ style: 'margin-top: 20px' }
41
41
  = haml :'partials/actions', locals: { actions: defined?(actions) ? actions : {} }
42
42
  -else
43
43
  %div{ style: 'padding-top: 20px' }
@@ -1,12 +1,14 @@
1
1
  - if actions.count > 1
2
- .dropdown
3
- %button.btn.btn-default.btn-block.dropdown-toggle{ type: 'button', id: 'actions-toggle', data: { toggle: 'dropdown' } }
4
- Actions
2
+ - link, text = actions.shift
3
+ .btn-group.text-right
4
+ %a.btn.btn-primary{ href: link }= text
5
+ %button.btn.btn-primary.dropdown-toggle{ type: 'button', id: 'actions-toggle', data: { toggle: 'dropdown' } }
5
6
  %span.caret
7
+ %span.sr-only Toggle Dropdown
6
8
  %ul.dropdown-menu{ 'aria-labelledby': 'actions-toggle' }
7
9
  -actions.each do |k, v|
8
10
  %li
9
11
  %a{ href: k }= v
10
12
  - elsif actions.count > 0
11
13
  -actions.each do |k, v|
12
- %a.btn.btn-primary.btn-block{ href: k }= v
14
+ %a.btn.btn-primary{ href: k }= v
@@ -1,6 +1,7 @@
1
1
  %form{ { method: %i[get post].include?(form_verb.to_sym) ? form_verb : :post, action: url }.merge(attributes) }
2
+ = Rack::Csrf.csrf_tag(env) unless ENV['APP_ENV'] == 'test'
2
3
  - if form_verb.to_sym == :get && layout
3
4
  %input{ name: 'layout', value: layout, type: 'hidden' }
4
5
  - if %i[get post].include?(form_verb.to_sym) == false
5
6
  %input{ name: '_method', value: form_verb.upcase, type: 'hidden' }
6
- = capture_haml(&block).chomp
7
+ = capture_haml(&block).chomp
@@ -9,16 +9,15 @@
9
9
  Ditty
10
10
 
11
11
  -if authenticated?
12
- %form.nav.navbar-top-links.navbar-form.navbar-right{ action: "#{settings.map_path}/auth/identity", method: 'post' }
12
+ = delete_form_tag("#{settings.map_path}/auth", attributes: { class: 'nav navbar-top-links navbar-form navbar-right' }) do
13
13
  %a.btn.btn-default{ href: "#{settings.map_path}/users/profile" } My Account
14
- %input{ name: '_method', value: 'DELETE', type: 'hidden' }
15
14
  %button.btn.btn-default{ type: 'submit' }
16
15
  / %i.ti-panel
17
16
  Logout
18
17
  - else
19
18
  %ul.nav.navbar-top-links.navbar-right
20
19
  %li
21
- %a.btn.btn-link{ href: "#{settings.map_path}/auth/identity" }
20
+ %a.btn.btn-link{ href: "#{settings.map_path}/auth/login" }
22
21
  Log In
23
22
  .navbar-default.sidebar{ role: 'navigation' }
24
23
  = haml :'partials/sidebar'
@@ -3,7 +3,7 @@
3
3
  - if self.class.const_defined?(:SEARCHABLE)
4
4
  .form-group
5
5
  .input-group
6
- %input.form-control{ name: 'q', type: 'text', placeholder: 'Search...', value: params['q'] }
6
+ %input.form-control{ name: 'q', type: 'text', placeholder: 'Search...', value: params[:q] }
7
7
  .input-group-btn
8
8
  %button.btn.btn-primary{ type: 'submit' }
9
9
  %span.fa.fa-search
@@ -27,11 +27,11 @@
27
27
  = item[:text]
28
28
  - else
29
29
  %li.active
30
- %a{ href: "#{settings.map_path}/auth/identity" }
30
+ %a{ href: "#{settings.map_path}/auth/login" }
31
31
  %i.fa.fa-user.fa-fw
32
32
  Log In
33
- - if policy(::Ditty::Identity).register?
33
+ - if policy(::Ditty::User).register?
34
34
  %li
35
- %a{ href: "#{settings.map_path}/auth/identity/register" }
35
+ %a{ href: "#{settings.map_path}/auth/register" }
36
36
  %i.fa.fa-pencil-square-o.fa-fw
37
37
  Register
@@ -12,7 +12,6 @@
12
12
  %a.btn.btn-default{ href: "#{base_path}/#{entity.id}/edit" } Edit
13
13
  .col-md-6.text-right
14
14
  - if policy(entity).delete?
15
- %form{ method: 'post', action: "#{base_path}/#{entity.id}" }
16
- %input{ name: '_method', value: 'DELETE', type: 'hidden' }
15
+ = delete_form_tag("#{base_path}/#{entity.id}") do
17
16
  %button.btn.btn-warning{ type: 'submit' } Delete
18
17
  .col-md-2
@@ -15,8 +15,4 @@
15
15
  %tr
16
16
  %td.text-center{ colspan: 1 } No records
17
17
 
18
- - if policy(::Ditty::Role).create?
19
- .panel-body.text-right
20
- %a.btn.btn-primary{ href: "#{base_path}/new" } New Role
21
-
22
18
  =pagination(list, base_path)
@@ -27,8 +27,7 @@
27
27
  %a.btn.btn-default{ href: "#{base_path}/#{entity.id}/edit" } Edit
28
28
  .col-md-6.text-right
29
29
  - if policy(entity).delete?
30
- %form{ method: 'post', action: "#{base_path}/#{entity.id}" }
31
- %input{ name: '_method', value: 'DELETE', type: 'hidden' }
30
+ = delete_form_tag("#{base_path}/#{entity.id}") do
32
31
  %button.btn.btn-warning{ type: 'submit' } Delete
33
32
  .col-md-2
34
33
 
@@ -40,8 +39,7 @@
40
39
  .panel-heading
41
40
  %h4 Change Password
42
41
  .panel-body
43
- %form.form-horizontal{ method: 'post', action: "#{base_path}/#{entity.id}/identity" }
44
- %input{ name: '_method', value: 'PUT', type: 'hidden' }
42
+ = edit_form_tag("#{base_path}/#{entity.id}/identity") do
45
43
  = form_control(:password, entity.identity.first, type: 'password', placeholder: 'Your password', group: 'identity')
46
44
  = form_control(:password_confirmation, entity.identity.first, type: 'password', label: 'Confirm Password', placeholder: 'Confirm your password', group: 'identity')
47
45
  %button.btn.btn-primary{ type: 'submit' }
@@ -12,16 +12,17 @@
12
12
  %th Roles
13
13
  %th Signed Up
14
14
  %tbody
15
- - list.all.each do |entity|
15
+ - if list.count > 0
16
+ - list.all.each do |entity|
17
+ %tr
18
+ %td
19
+ %a{ href: "#{base_path}/#{entity.id}" }= entity.email
20
+ %td= entity.name
21
+ %td= entity.surname
22
+ %td= entity.roles_dataset.map(:name).map(&:titlecase).join(', ')
23
+ %td= entity.created_at.strftime('%Y-%m-%d')
24
+ - else
16
25
  %tr
17
- %td
18
- %a{ href: "#{base_path}/#{entity.id}" }= entity.email
19
- %td= entity.name
20
- %td= entity.surname
21
- %td= entity.roles_dataset.map(:name).map(&:titlecase).join(', ')
22
- %td= entity.created_at.strftime('%Y-%m-%d')
23
- - if policy(::Ditty::User).create?
24
- .panel-body.text-right
25
- %a.btn.btn-primary{ href: "#{base_path}/new" } New User
26
+ %td.text-center{ colspan: 5 } No records
26
27
 
27
28
  =pagination(list, base_path)
@@ -26,8 +26,7 @@
26
26
  %a.btn.btn-default{ href: "#{base_path}/#{entity.id}/edit" } Edit
27
27
  .col-md-6.text-right
28
28
  - if policy(entity).delete?
29
- %form{ method: 'post', action: "#{base_path}/#{entity.id}" }
30
- %input{ name: '_method', value: 'DELETE', type: 'hidden' }
29
+ = delete_form_tag("#{base_path}/#{entity.id}") do
31
30
  %button.btn.btn-warning{ type: 'submit' } Delete
32
31
  .col-md-2
33
32
 
@@ -38,8 +37,7 @@
38
37
  .panel-heading
39
38
  %h4 Change Password
40
39
  .panel-body
41
- %form.form-horizontal{ method: 'post', action: "#{base_path}/#{entity.id}/identity" }
42
- %input{ name: '_method', value: 'PUT', type: 'hidden' }
40
+ = edit_form_tag("#{base_path}/#{entity.id}/identity") do
43
41
  = form_control(:old_password, identity, type: 'password', placeholder: 'Your current password')
44
42
  = form_control(:password, identity, type: 'password', placeholder: 'Your new password')
45
43
  = form_control(:password_confirmation, identity, type: 'password', label: 'Confirm Password', placeholder: 'Confirm your password')
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: ditty
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.6.0
4
+ version: 0.7.0.pre.rc1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Jurgens du Toit
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2018-07-22 00:00:00.000000000 Z
11
+ date: 2018-08-30 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler
@@ -248,6 +248,20 @@ dependencies:
248
248
  - - "~>"
249
249
  - !ruby/object:Gem::Version
250
250
  version: '1.0'
251
+ - !ruby/object:Gem::Dependency
252
+ name: rack_csrf
253
+ requirement: !ruby/object:Gem::Requirement
254
+ requirements:
255
+ - - "~>"
256
+ - !ruby/object:Gem::Version
257
+ version: '1.0'
258
+ type: :runtime
259
+ prerelease: false
260
+ version_requirements: !ruby/object:Gem::Requirement
261
+ requirements:
262
+ - - "~>"
263
+ - !ruby/object:Gem::Version
264
+ version: '1.0'
251
265
  - !ruby/object:Gem::Dependency
252
266
  name: rake
253
267
  requirement: !ruby/object:Gem::Requirement
@@ -318,6 +332,20 @@ dependencies:
318
332
  - - "~>"
319
333
  - !ruby/object:Gem::Version
320
334
  version: '0.3'
335
+ - !ruby/object:Gem::Dependency
336
+ name: sinatra-param
337
+ requirement: !ruby/object:Gem::Requirement
338
+ requirements:
339
+ - - "~>"
340
+ - !ruby/object:Gem::Version
341
+ version: '1.5'
342
+ type: :runtime
343
+ prerelease: false
344
+ version_requirements: !ruby/object:Gem::Requirement
345
+ requirements:
346
+ - - "~>"
347
+ - !ruby/object:Gem::Version
348
+ version: '1.5'
321
349
  - !ruby/object:Gem::Dependency
322
350
  name: tilt
323
351
  requirement: !ruby/object:Gem::Requirement
@@ -400,6 +428,7 @@ files:
400
428
  - lib/ditty/components/app.rb
401
429
  - lib/ditty/controllers/application.rb
402
430
  - lib/ditty/controllers/audit_logs.rb
431
+ - lib/ditty/controllers/auth.rb
403
432
  - lib/ditty/controllers/component.rb
404
433
  - lib/ditty/controllers/main.rb
405
434
  - lib/ditty/controllers/roles.rb
@@ -413,6 +442,7 @@ files:
413
442
  - lib/ditty/helpers/response.rb
414
443
  - lib/ditty/helpers/views.rb
415
444
  - lib/ditty/listener.rb
445
+ - lib/ditty/middleware/accept_extension.rb
416
446
  - lib/ditty/middleware/error_catchall.rb
417
447
  - lib/ditty/models/audit_log.rb
418
448
  - lib/ditty/models/base.rb
@@ -446,8 +476,15 @@ files:
446
476
  - public/images/mstile-150x150.png
447
477
  - public/images/safari-pinned-tab.svg
448
478
  - public/manifest.json
479
+ - views/400.haml
449
480
  - views/404.haml
450
481
  - views/audit_logs/index.haml
482
+ - views/auth/forgot_password.haml
483
+ - views/auth/identity.haml
484
+ - views/auth/login.haml
485
+ - views/auth/register.haml
486
+ - views/auth/register_identity.haml
487
+ - views/auth/reset_password.haml
451
488
  - views/emails/base.haml
452
489
  - views/emails/forgot_password.haml
453
490
  - views/emails/layouts/action.haml
@@ -455,10 +492,6 @@ files:
455
492
  - views/emails/layouts/billing.haml
456
493
  - views/embedded.haml
457
494
  - views/error.haml
458
- - views/identity/forgot.haml
459
- - views/identity/login.haml
460
- - views/identity/register.haml
461
- - views/identity/reset.haml
462
495
  - views/index.haml
463
496
  - views/layout.haml
464
497
  - views/partials/actions.haml
@@ -499,9 +532,9 @@ required_ruby_version: !ruby/object:Gem::Requirement
499
532
  version: '0'
500
533
  required_rubygems_version: !ruby/object:Gem::Requirement
501
534
  requirements:
502
- - - ">="
535
+ - - ">"
503
536
  - !ruby/object:Gem::Version
504
- version: '0'
537
+ version: 1.3.1
505
538
  requirements: []
506
539
  rubyforge_project:
507
540
  rubygems_version: 2.7.7
@@ -1,29 +0,0 @@
1
- .row
2
- .col-sm-3
3
- .col-sm-6
4
- .panel.panel-default
5
- .panel-body
6
- %form{ method: 'post', action: "#{settings.map_path}/auth/identity/callback" }
7
- .form-group
8
- %label.control-label Email
9
- %input.form-control.border-input{ name: 'username', tabindex: '1' }
10
- .form-group
11
- %label.control-label{ style: 'display: block' }
12
- Password
13
- %a{ href: "#{settings.map_path}/auth/identity/forgot", style: 'float: right', tabindex: '5' }
14
- Forgot?
15
- %input.form-control.border-input{ name: 'password', type: 'password', tabindex: '2' }
16
- %button.btn.btn-primary{ type: 'submit', tabindex: '3' } Log In
17
- - if policy(::Ditty::Identity).register?
18
- .pull-right
19
- No account yet?
20
- %a.btn.btn-default{ href: "#{settings.map_path}/auth/identity/register", tabindex: '4' } Register
21
- .row
22
- .col-sm-12= "&nbsp"
23
- - if Ditty::Services::Authentication.provides? 'google_oauth2'
24
- .row
25
- .col-sm-8.col-sm-push-2
26
- %a.btn.btn-block.btn-default{ href: "#{settings.map_path}/auth/google_oauth2" }
27
- %i.fa.fa-google
28
- Log in with Google
29
- .col-sm-3
@@ -1,29 +0,0 @@
1
- .row
2
- .col-md-2
3
- .col-md-8
4
- .panel.panel-default
5
- .panel-body
6
- %form.form-horizontal{ method: 'post', action: "#{settings.map_path}/auth/identity/new" }
7
- = form_control(:username, identity, label: 'Email', placeholder: 'your@email.com')
8
- = form_control(:password, identity, label: 'Password', type: :password)
9
- = form_control(:password_confirmation, identity, label: 'Confirm Password', type: :password)
10
-
11
- - if identity.errors[:password] && identity.errors[:password].include?('is not strong enough')
12
- .alert.alert-warning
13
- %p Make sure your password is at least 8 characters long, and including the following
14
- %ul
15
- %li Upper- and lowercase letters
16
- %li Numbers
17
- %li Special Characters
18
-
19
- - if policy(::Ditty::Identity).register?
20
- %button.btn.btn-primary{ type: 'submit' } Register
21
- .row
22
- .col-sm-12= "&nbsp"
23
- - if Ditty::Services::Authentication.provides? 'google_oauth2'
24
- .row
25
- .col-sm-8.col-sm-push-2
26
- %a.btn.btn-block.btn-default{ href: "#{settings.map_path}/auth/google_oauth2" }
27
- %i.fa.fa-google
28
- Register with Google
29
- .col-md-2