ditty 0.8.0 → 0.9.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (123) hide show
  1. checksums.yaml +4 -4
  2. data/.gitignore +2 -0
  3. data/.pryrc +2 -0
  4. data/.rubocop.yml +1 -1
  5. data/.travis.yml +5 -4
  6. data/CNAME +1 -0
  7. data/Dockerfile +18 -0
  8. data/Gemfile.ci +0 -2
  9. data/Rakefile +2 -2
  10. data/_config.yml +1 -0
  11. data/config.ru +4 -4
  12. data/ditty.gemspec +9 -3
  13. data/docs/CNAME +1 -0
  14. data/docs/_config.yml +1 -0
  15. data/docs/index.md +34 -0
  16. data/exe/ditty +2 -0
  17. data/lib/ditty.rb +4 -2
  18. data/lib/ditty/cli.rb +28 -4
  19. data/lib/ditty/components/{app.rb → ditty.rb} +19 -14
  20. data/lib/ditty/controllers/{application.rb → application_controller.rb} +58 -29
  21. data/lib/ditty/controllers/{audit_logs.rb → audit_logs_controller.rb} +2 -2
  22. data/lib/ditty/controllers/{auth.rb → auth_controller.rb} +17 -16
  23. data/lib/ditty/controllers/{component.rb → component_controller.rb} +19 -18
  24. data/lib/ditty/controllers/{main.rb → main_controller.rb} +6 -2
  25. data/lib/ditty/controllers/roles_controller.rb +23 -0
  26. data/lib/ditty/controllers/{user_login_traits.rb → user_login_traits_controller.rb} +4 -3
  27. data/lib/ditty/controllers/{users.rb → users_controller.rb} +11 -10
  28. data/lib/ditty/db.rb +4 -3
  29. data/lib/ditty/emails/base.rb +5 -2
  30. data/lib/ditty/generators/crud_generator.rb +104 -0
  31. data/lib/ditty/generators/migration_generator.rb +26 -0
  32. data/lib/ditty/generators/project_generator.rb +51 -0
  33. data/lib/ditty/helpers/component.rb +2 -1
  34. data/lib/ditty/helpers/pundit.rb +20 -4
  35. data/lib/ditty/helpers/response.rb +20 -13
  36. data/lib/ditty/helpers/views.rb +7 -3
  37. data/lib/ditty/listener.rb +5 -3
  38. data/lib/ditty/memcached.rb +8 -0
  39. data/lib/ditty/middleware/accept_extension.rb +2 -2
  40. data/lib/ditty/middleware/error_catchall.rb +2 -2
  41. data/lib/ditty/models/base.rb +4 -0
  42. data/lib/ditty/models/role.rb +1 -0
  43. data/lib/ditty/models/user.rb +14 -1
  44. data/lib/ditty/policies/role_policy.rb +1 -1
  45. data/lib/ditty/policies/user_login_trait_policy.rb +1 -1
  46. data/lib/ditty/services/authentication.rb +11 -10
  47. data/lib/ditty/services/email.rb +8 -4
  48. data/lib/ditty/services/logger.rb +1 -1
  49. data/lib/ditty/tasks/ditty.rake +17 -0
  50. data/lib/ditty/tasks/omniauth-ldap.rake +2 -2
  51. data/lib/ditty/templates/.gitignore +5 -0
  52. data/lib/ditty/templates/.rspec +2 -0
  53. data/lib/ditty/templates/.rubocop.yml +7 -0
  54. data/lib/ditty/templates/Rakefile +12 -0
  55. data/lib/ditty/templates/application.rb +12 -0
  56. data/lib/ditty/templates/config.ru +37 -0
  57. data/lib/ditty/templates/controller.rb.erb +58 -0
  58. data/lib/ditty/templates/env.example +4 -0
  59. data/lib/ditty/templates/lib/project.rb.erb +5 -0
  60. data/lib/ditty/templates/migration.rb.erb +7 -0
  61. data/lib/ditty/templates/model.rb.erb +26 -0
  62. data/lib/ditty/templates/pids/.empty_directory +0 -0
  63. data/lib/ditty/templates/policy.rb.erb +48 -0
  64. data/lib/ditty/templates/public/css/sb-admin-2.min.css +10 -0
  65. data/lib/ditty/templates/public/js/sb-admin-2.min.js +7 -0
  66. data/lib/ditty/templates/settings.yml.erb +18 -0
  67. data/lib/ditty/templates/sidekiq.rb +18 -0
  68. data/lib/ditty/templates/sidekiq.yml +9 -0
  69. data/lib/ditty/templates/spec_helper.rb +43 -0
  70. data/lib/ditty/templates/type.rb.erb +21 -0
  71. data/lib/ditty/templates/views/display.haml.tt +20 -0
  72. data/lib/ditty/templates/views/edit.haml.tt +10 -0
  73. data/lib/ditty/templates/views/form.haml.tt +11 -0
  74. data/lib/ditty/templates/views/index.haml.tt +29 -0
  75. data/lib/ditty/templates/views/new.haml.tt +10 -0
  76. data/lib/ditty/version.rb +1 -1
  77. data/lib/rubocop/cop/ditty/call_services_directly.rb +2 -2
  78. data/migrate/20181209_add_user_login_traits.rb +4 -4
  79. data/migrate/20190220_add_parent_id_to_roles.rb +9 -0
  80. data/public/css/styles.css +13 -0
  81. data/public/js/scripts.js +1 -0
  82. data/views/404.haml +2 -4
  83. data/views/audit_logs/index.haml +32 -34
  84. data/views/auth/forgot_password.haml +27 -16
  85. data/views/auth/identity.haml +14 -13
  86. data/views/auth/ldap.haml +2 -2
  87. data/views/auth/login.haml +22 -17
  88. data/views/auth/register.haml +19 -18
  89. data/views/auth/register_identity.haml +27 -12
  90. data/views/auth/reset_password.haml +2 -2
  91. data/views/blank.haml +42 -0
  92. data/views/index.haml +1 -1
  93. data/views/layout.haml +37 -30
  94. data/views/partials/content_tag.haml +0 -0
  95. data/views/partials/delete_form.haml +1 -1
  96. data/views/partials/filter_control.haml +1 -1
  97. data/views/partials/footer.haml +5 -5
  98. data/views/partials/form_control.haml +19 -12
  99. data/views/partials/navitems.haml +44 -0
  100. data/views/partials/notifications.haml +12 -8
  101. data/views/partials/pager.haml +17 -17
  102. data/views/partials/search.haml +6 -7
  103. data/views/partials/sidebar.haml +15 -37
  104. data/views/partials/topbar.haml +68 -0
  105. data/views/roles/display.haml +27 -6
  106. data/views/roles/edit.haml +3 -3
  107. data/views/roles/form.haml +1 -0
  108. data/views/roles/index.haml +23 -16
  109. data/views/roles/new.haml +2 -2
  110. data/views/user_login_traits/display.haml +4 -4
  111. data/views/user_login_traits/edit.haml +3 -3
  112. data/views/user_login_traits/index.haml +4 -4
  113. data/views/user_login_traits/new.haml +2 -2
  114. data/views/users/display.haml +11 -12
  115. data/views/users/edit.haml +3 -3
  116. data/views/users/form.haml +0 -0
  117. data/views/users/index.haml +31 -24
  118. data/views/users/login_traits.haml +6 -8
  119. data/views/users/new.haml +2 -2
  120. data/views/users/profile.haml +13 -13
  121. metadata +143 -15
  122. data/lib/ditty/controllers/roles.rb +0 -13
  123. data/views/partials/navbar.haml +0 -22
@@ -0,0 +1,21 @@
1
+ # frozen_string_literal: true
2
+
3
+ require '<%= folder %>/types/base_object'
4
+
5
+ module <%= namespace %>
6
+ module Types
7
+ class <%= model_name %>Type < BaseObject
8
+ description 'A <%= model_name %>.'
9
+ <%- if columns.include? :guid -%>
10
+ field :id, ID, 'The unique GUID', null: false, resolver_method: :guid
11
+ <%- end -%>
12
+ <%- many_to_ones.each do |rel| -%>
13
+ field :<%= rel[:table].to_s.singularize %>, '<%= namespace %>::Types::<%= rel[:table].to_s.classify %>Type', null: <%= schema[rel[:columns].first][:allow_null] %>
14
+ <%- end -%>
15
+ <%- schema.each do |name, info| -%>
16
+ <%- next if %i[id guid].include?(name) || (name.to_s =~ /_id/ && info[:type] == :integer) -%>
17
+ field :<%= name %>, <%= graphql_types[info[:type]] %>, null: <%= info[:allow_null] %>
18
+ <%- end -%>
19
+ end
20
+ end
21
+ end
@@ -0,0 +1,20 @@
1
+ .row
2
+ .col-md-2
3
+ .col-md-8
4
+ .card
5
+ .card-body
6
+ <%- columns.each do |col| -%>
7
+ %p.description
8
+ %label <%= col.to_s.titleize %>:
9
+ = entity.<%= col %>
10
+ <%- end %>
11
+
12
+ .row
13
+ .col-md-6
14
+ - if policy(entity).update?
15
+ %a.btn.btn-secondary{ href: "#{base_path}/#{entity.display_id}/edit" } Edit
16
+ .col-md-6.text-right
17
+ - if policy(entity).delete?
18
+ = delete_form_tag("#{base_path}/#{entity.display_id}") do
19
+ %button.btn.btn-warning{ type: 'submit' } Delete
20
+ .col-md-2
@@ -0,0 +1,10 @@
1
+ .row
2
+ .col-md-2
3
+ .col-md-8
4
+ .card
5
+ .card-body
6
+ = edit_form_tag "#{base_path}/#{entity.display_id}" do
7
+ = haml :'<%= model_name.pluralize.underscore %>/form', locals: { entity: entity }
8
+ %button.btn.btn-primary{ type: 'submit' }
9
+ Update <%= model_name %>
10
+ .col-md-2
@@ -0,0 +1,11 @@
1
+ <%- if columns.include? :user_id -%>
2
+ = form_control(:user_id, entity, type: 'select', options: policy_scope(Ditty::User).order(:email).as_hash(:id, :email))
3
+ <%- end -%>
4
+ <%- many_to_ones.each do |rel| -%>
5
+ <%- next if %i[users].include?(rel[:tablename]) -%>
6
+ = form_control(:<%= rel[:columns].first %>, entity, type: 'select', options: policy_scope(<%= namespace %>::<%= rel[:table].to_s.classify %>).order(:<%= name_column(rel[:table]) %>).as_hash(:id, :<%= name_column(rel[:table]) %>))
7
+ <%- end -%>
8
+ <%- (columns - meta_columns).each do |col| -%>
9
+ <%- next if %i[id guid].include?(name) || (name.to_s =~ /_id/ && info[:type] == :integer) -%>
10
+ = form_control(:<%= col %>, entity, type: '<%= input_types[schema[col][:type]] %>')
11
+ <%- end -%>
@@ -0,0 +1,29 @@
1
+ .row
2
+ .col-md-12
3
+ = haml :'partials/search'
4
+ %table.table.table-striped.table-bordered.table-hover
5
+ %thead.thead-dark
6
+ %tr
7
+ <%- columns.each do |col| -%>
8
+ %th <%= col.to_s.titleize %>
9
+ <%- end %>
10
+ %th
11
+ %tbody
12
+ - if list.count > 0
13
+ - list.all.each do |entity|
14
+ %tr
15
+ <%- columns.each do |col| -%>
16
+ %td= entity.<%= col %>
17
+ <%- end %>
18
+ %td
19
+ %a{ href: "#{base_path}/#{entity.display_id}", title: 'Show' }
20
+ %i.fa.fa-search
21
+ - if policy(entity).update?
22
+ %a{ href: "#{base_path}/#{entity.display_id}/edit", title: 'Edit' }
23
+ %i.fa.fa-edit
24
+ - else
25
+ %tr
26
+ %td.text-center{ colspan: <%= columns.count + 1 %> } No <%= model_name.pluralize %>
27
+
28
+ - if list.count > 0
29
+ =pagination(list, base_path)
@@ -0,0 +1,10 @@
1
+ .row
2
+ .col-md-2
3
+ .col-md-8
4
+ .card
5
+ .card-body
6
+ = new_form_tag base_path do
7
+ = haml :'<%= model_name.pluralize.underscore %>/form', locals: { entity: entity }
8
+ %button.btn.btn-primary{ type: 'submit' }
9
+ Create <%= model_name %>
10
+ .col-md-2
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Ditty
4
- VERSION = '0.8.0'
4
+ VERSION = '0.9.0'
5
5
  end
@@ -13,10 +13,10 @@ module RuboCop
13
13
  #
14
14
  # @example
15
15
  # # bad
16
- # Ditty::Services::Logger.instance.info 'This is a log message'
16
+ # ::Ditty::Services::Logger.instance.info 'This is a log message'
17
17
  #
18
18
  # # good
19
- # Ditty::Services::Logger.info 'This is a log message'
19
+ # ::Ditty::Services::Logger.info 'This is a log message'
20
20
  class CallServicesDirectly < RuboCop::Cop::Cop
21
21
  MSG = 'Do not use `.instance` on services. Call the method directly instead'
22
22
 
@@ -5,10 +5,10 @@ Sequel.migration do
5
5
  create_table :user_login_traits do
6
6
  primary_key :id
7
7
  foreign_key :user_id, :users
8
- String :ip_address, nullable: true
9
- String :platform, nullable: true
10
- String :device, nullable: true
11
- String :browser, nullable: true
8
+ String :ip_address, null: true
9
+ String :platform, null: true
10
+ String :device, null: true
11
+ String :browser, null: true
12
12
  DateTime :created_at
13
13
  DateTime :updated_at
14
14
  end
@@ -0,0 +1,9 @@
1
+ # frozen_string_literal: true
2
+
3
+ Sequel.migration do
4
+ change do
5
+ alter_table :roles do
6
+ add_column :parent_id, Integer
7
+ end
8
+ end
9
+ end
@@ -0,0 +1,13 @@
1
+ /* Add your application specific styles here */
2
+
3
+ .bg-login-image {
4
+ background-image: url('https://source.unsplash.com/4rDCa5hBlCs/600x800');
5
+ }
6
+
7
+ .bg-password-image {
8
+ background-image: url('https://source.unsplash.com/4rDCa5hBlCs/600x800');
9
+ }
10
+
11
+ .bg-register-image {
12
+ background-image: url('https://source.unsplash.com/4rDCa5hBlCs/600x800');
13
+ }
@@ -0,0 +1 @@
1
+ // Add your application specific scripts here
@@ -1,7 +1,5 @@
1
- %h2 Whoops!
2
-
3
- %p.lead
1
+ %p.lead.text-center
4
2
  We could not find the page you were looking for...
5
3
 
6
4
  .text-center
7
- %iframe{ width: 560, height: 315, src: 'https://www.youtube.com/embed/e3-5YC_oHjE', frameborder: 0, allowfullscreen: true }
5
+ %iframe{ width: 560, height: 315, src: 'https://www.youtube.com/embed/e3-5YC_oHjE', frameborder: 0, allowfullscreen: true }
@@ -1,37 +1,35 @@
1
+ = haml :'partials/search'
1
2
  .row
2
- .col-md-12
3
- .panel.panel-default
4
- .panel-body
5
- = haml :'partials/search'
6
- %table.table.table-striped
7
- %thead
8
- %tr
9
- %th User email
10
- %th Action
11
- %th Details
12
- %th IP Address
13
- %th Browser
14
- %th Device
15
- %th Platform
16
- %th Created at
17
- %tbody
18
- - if list.count > 0
19
- - list.all.each do |entity|
20
- %tr
21
- %td
22
- -if entity.user
23
- %a{ href: "#{settings.map_path}/users/#{entity.user.id}" }= entity.user.email
24
- -else
25
- None
26
- %td= entity.action
27
- %td= entity.details
28
- %td= entity.ip_address || 'Unknown'
29
- %td= entity.browser || 'Unknown'
30
- %td= entity.device || 'Unknown'
31
- %td= entity.platform || 'Unknown'
32
- %td= entity.created_at&.strftime('%Y-%m-%d %H:%M:%S') || 'Unknown'
33
- - else
3
+ .col-12
4
+ %table.table.table-striped.table-bordered.table-hover
5
+ %thead.thead-dark
6
+ %tr
7
+ %th User email
8
+ %th Action
9
+ %th Details
10
+ %th IP Address
11
+ %th Browser
12
+ %th Device
13
+ %th Platform
14
+ %th Created at
15
+ %tbody
16
+ - if list.count > 0
17
+ - list.all.each do |entity|
34
18
  %tr
35
- %td.text-center{ colspan: 4 } No records
19
+ %td
20
+ -if entity.user
21
+ %a{ href: "#{settings.map_path}/users/#{entity.user.id}" }= entity.user.email
22
+ -else
23
+ None
24
+ %td= entity.action
25
+ %td= entity.details
26
+ %td= entity.ip_address || 'Unknown'
27
+ %td= entity.browser || 'Unknown'
28
+ %td= entity.device || 'Unknown'
29
+ %td= entity.platform || 'Unknown'
30
+ %td= entity.created_at&.strftime('%Y-%m-%d %H:%M:%S') || 'Unknown'
31
+ - else
32
+ %tr
33
+ %td.text-center{ colspan: 4 } No records
36
34
 
37
- =pagination(list, base_path)
35
+ =pagination(list, base_path)
@@ -1,16 +1,27 @@
1
- .row
2
- .col-md-4
3
- .col-md-4
4
- .panel.panel-default
5
- .panel-body
6
- %p.text-center
7
- Enter your email address and we will send you a link to reset your password if you've registered on the system.
8
- = form_tag("#{settings.map_path}/auth/forgot-password") do
9
- .form-group
10
- .col-sm-12
11
- %input.form-control{ name: 'email', type: 'text', placeholder: 'Enter your email address' }
12
- .row.text-right
13
- .col-md-12
14
- %button.btn.btn-primary.btn-block{ type: 'submit' }
15
- Email password reset link
16
- .col-md-4
1
+ .container
2
+ .card.o-hidden.border-0.shadow-lg.my-5
3
+ .card-body.p-0
4
+ / Nested Row within Card Body
5
+ .row
6
+ .col-lg-6.d-none.d-lg-block.bg-password-image
7
+ .col-lg-6
8
+ .p-5
9
+ .text-center
10
+ %h1.h4.text-gray-900.mb-2
11
+ Forgot Your Password?
12
+ %p.mb-4
13
+ We get it, stuff happens. Just enter your email address below and we'll send you a link to reset your password!
14
+ = form_tag("#{settings.map_path}/auth/forgot-password", attributes: { class: 'user' }) do
15
+ .form-group
16
+ %input.form-control.form-control-user{ type: 'email', placeholder: 'Enter Email Address...' }
17
+ %button.btn.btn-primary.btn-user.btn-block{ type: 'submit' }
18
+ Reset Password
19
+ %hr
20
+ - if policy(::Ditty::User).register?
21
+ .text-center
22
+ %a.small{ href: "#{settings.map_path}/auth/register" } Create an Account!
23
+ .text-center
24
+ %a.small{ href: "#{settings.map_path}/auth/login" } Already have an account? Login!
25
+
26
+ .row.justify-content-center
27
+ .col-xl-10.col-lg-12.col-md-9
@@ -1,15 +1,16 @@
1
- = form_tag("#{settings.map_path}/auth/identity/callback", attributes: { class: '' }) do
1
+ = form_tag("#{settings.map_path}/auth/identity/callback", attributes: { class: 'user' }) do
2
2
  .form-group
3
- %label.control-label Email
4
- %input.form-control.border-input{ name: 'username', tabindex: '1' }
3
+ %input.form-control.form-control-user{ name: 'username', type: 'email', 'aria-describedby': 'emailHelp', placeholder: 'Enter Email Address...' }
5
4
  .form-group
6
- %label.control-label{ style: 'display: block' }
7
- Password
8
- %a{ href: "#{settings.map_path}/auth/forgot-password", style: 'float: right', tabindex: '5' }
9
- Forgot?
10
- %input.form-control.border-input{ name: 'password', type: 'password', tabindex: '2' }
11
- %button.btn.btn-primary{ type: 'submit', tabindex: '3' } Log In
12
- - if policy(::Ditty::User).register?
13
- .pull-right
14
- No account yet?
15
- %a.btn.btn-default{ href: "#{settings.map_path}/auth/register", tabindex: '4' } Register
5
+ %input.form-control.form-control-user{ name: 'password', type: 'password', placeholder: 'Password' }
6
+ / .form-group
7
+ / .custom-control.custom-checkbox.small
8
+ / <input type="checkbox" class="custom-control-input" id="customCheck">
9
+ / <label class="custom-control-label" for="customCheck">Remember Me</label>
10
+ %button.btn.btn-primary.btn-user.btn-block{ type: 'submit' } Log In
11
+ %hr
12
+ .text-center
13
+ %a.small{ href: "#{settings.map_path}/auth/forgot-password" } Forgot Password?
14
+ - if policy(::Ditty::User).register?
15
+ .text-center
16
+ %a.small{ href: "#{settings.map_path}/auth/register" } Create an Account!
@@ -1,8 +1,8 @@
1
1
  .row
2
2
  .col-sm-2
3
3
  .col-sm-8
4
- .panel.panel-default
5
- .panel-body
4
+ .card.card-default
5
+ .card-body
6
6
  = form_tag("#{settings.map_path}/auth/ldap/callback", attributes: { class: '' }) do
7
7
  .form-group
8
8
  %label.control-label Username
@@ -1,18 +1,23 @@
1
- .row
2
- .col-sm-2
3
- .col-sm-8
4
- .panel.panel-default
5
- .panel-body
6
- - if Ditty::Services::Authentication.provides? 'identity'
7
- = haml :'auth/identity'
1
+ .container
2
+ / Outer Row
3
+ .row.justify-content-center
4
+ .col-xl-10.col-lg-12.col-md-9
5
+ .card.o-hidden.border-0.shadow-lg.my-5
6
+ .card-body.p-0
7
+ / Nested Row within Card Body
8
8
  .row
9
- .col-sm-12= "&nbsp;"
10
- .row
11
- .col-sm-8.col-sm-push-2
12
- - Ditty::Services::Authentication.providers.each do |name|
13
- - provider = Ditty::Services::Authentication[name]
14
- - next if provider[:login_prompt].nil?
15
- %a.btn.btn-block.btn-default{ href: "#{settings.map_path}/auth/#{name}" }
16
- %i.fa{ class: "fa-#{provider[:icon] || 'key'}"}
17
- = provider[:login_prompt]
18
- .col-sm-2
9
+ .col-lg-6.d-none.d-lg-block.bg-login-image
10
+ .col-lg-6
11
+ .p-5
12
+ .text-center
13
+ %h1.h4.text-gray-900.mb-4 Welcome Back!
14
+ - ::Ditty::Services::Authentication.providers.each do |name|
15
+ - provider = ::Ditty::Services::Authentication[name]
16
+ - next if provider[:login_prompt].nil?
17
+ %p
18
+ %a.btn.btn-block.btn-secondary{ href: "#{settings.map_path}/auth/#{name}" }
19
+ %i.fab.fw{ class: "fa-#{provider[:icon] || 'key'}"}
20
+ = provider[:login_prompt]
21
+ = haml :'partials/notifications'
22
+ - if ::Ditty::Services::Authentication.provides? 'identity'
23
+ = haml :'auth/identity'
@@ -1,19 +1,20 @@
1
- / TODO: How can we detect a google registration? Extra parameter to the callback? Or a custom callback page?
2
- .row
3
- .col-md-2
4
- .col-md-8
5
- .panel.panel-default
6
- .panel-body
7
- - if Ditty::Services::Authentication.provides? 'identity'
8
- = haml :'auth/register_identity', locals: { identity: identity }
9
- .row
10
- .col-sm-12= "&nbsp;"
11
- .row
12
- .col-sm-8.col-sm-push-2
13
- - Ditty::Services::Authentication.providers.each do |name|
14
- - provider = Ditty::Services::Authentication[name]
1
+ .container
2
+ .card.o-hidden.border-0.shadow-lg.my-5
3
+ .card-body.p-0
4
+ / Nested Row within Card Body
5
+ .row
6
+ .col-lg-5.d-none.d-lg-block.bg-register-image
7
+ .col-lg-7
8
+ .p-5
9
+ .text-center
10
+ %h1.h4.text-gray-900.mb-4 Create an Account!
11
+ = haml :'partials/notifications'
12
+ - ::Ditty::Services::Authentication.providers.each do |name|
13
+ - provider = ::Ditty::Services::Authentication[name]
15
14
  - next if provider[:register_prompt].nil?
16
- %a.btn.btn-block.btn-default{ href: "#{settings.map_path}/auth/#{name}" }
17
- %i.fa{ class: "fa-#{provider[:icon] || 'key'}"}
18
- = provider[:register_prompt]
19
- .col-md-2
15
+ %p
16
+ %a.btn.btn-user.btn-block{ href: "#{settings.map_path}/auth/#{name}", class: "btn-#{provider[:icon] || 'key'}" }
17
+ %i.fab.fa-fw{ class: "fa-#{provider[:icon] || 'key'}"}
18
+ = provider[:register_prompt]
19
+ - if ::Ditty::Services::Authentication.provides? 'identity'
20
+ = haml :'auth/register_identity', locals: { identity: identity }
@@ -1,14 +1,29 @@
1
- = form_tag("#{settings.map_path}/auth/register/identity") do
2
- = form_control(:username, identity, label: 'Email', placeholder: 'your@email.com')
3
- = form_control(:password, identity, label: 'Password', type: :password)
4
- = form_control(:password_confirmation, identity, label: 'Confirm Password', type: :password)
1
+ - if identity.errors[:password] && identity.errors[:password].include?('is not strong enough')
2
+ .alert.alert-warning
3
+ %p Make sure your password is at least 8 characters long, and including the following
4
+ %ul
5
+ %li Upper- and lowercase letters
6
+ %li Numbers
7
+ %li Special Characters
5
8
 
6
- - if identity.errors[:password] && identity.errors[:password].include?('is not strong enough')
7
- .alert.alert-warning
8
- %p Make sure your password is at least 8 characters long, and including the following
9
- %ul
10
- %li Upper- and lowercase letters
11
- %li Numbers
12
- %li Special Characters
9
+ = form_tag("#{settings.map_path}/auth/register/identity", attributes: { class: 'user' }) do
10
+ .form-group
11
+ %input.form-control.form-control-user{ name: 'identity[username]', type: 'email', placeholder: 'Email Address', class: identity.errors[:username] ? 'is-invalid' : 'is-valid' }
12
+ - if identity.errors[:username]
13
+ .invalid-feedback= identity.errors[:username].join(', ')
14
+ .form-group.row
15
+ .col-sm-6.mb-3.mb-sm-0
16
+ %input.form-control.form-control-user{ name: 'identity[password]', type: 'password', placeholder: 'Password', class: identity.errors[:password] ? 'is-invalid' : 'is-valid' }
17
+ - if identity.errors[:password]
18
+ .invalid-feedback= identity.errors[:password].join(', ')
19
+ .col-sm-6
20
+ %input.form-control.form-control-user{ name: 'identity[password_confirmation]', type: 'password', placeholder: 'Repeat Password', class: identity.errors[:password_confirmation] ? 'is-invalid' : 'is-valid' }
21
+ - if identity.errors[:password_confirmation]
22
+ .invalid-feedback= identity.errors[:password_confirmation].join(', ')
13
23
 
14
- %button.btn.btn-primary{ type: 'submit' } Register
24
+ %button.btn.btn-primary.btn-user.btn-block{ type: 'submit' } Register
25
+ %hr
26
+ .text-center
27
+ %a.small{ href: "#{settings.map_path}/auth/forgot-password" } Forgot Password?
28
+ .text-center
29
+ %a.small{ href: "#{settings.map_path}/auth/login" } Already have an account? Login!