oxen_user 0.2.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (55) hide show
  1. checksums.yaml +7 -0
  2. data/.envrc +0 -0
  3. data/.gitignore +10 -0
  4. data/.rspec +3 -0
  5. data/.ruby-version +1 -0
  6. data/.travis.yml +3 -0
  7. data/CODE_OF_CONDUCT.md +13 -0
  8. data/Gemfile +7 -0
  9. data/Guardfile +77 -0
  10. data/LICENSE.txt +21 -0
  11. data/README.md +39 -0
  12. data/Rakefile +10 -0
  13. data/app/assets/javascripts/oxen_user.js +3 -0
  14. data/app/assets/javascripts/pw_strength.js.coffee +24 -0
  15. data/app/assets/javascripts/zxcvbn.js +43 -0
  16. data/app/controllers/oxen/invitations_controller.rb +66 -0
  17. data/app/controllers/oxen/users_controller.rb +96 -0
  18. data/app/helpers/oxen/users_helper.rb +8 -0
  19. data/app/models/ox_user.rb +89 -0
  20. data/app/policies/oxen/user_policy.rb +48 -0
  21. data/app/views/devise/confirmations/new.html.haml +13 -0
  22. data/app/views/devise/mailer/eksempel +10 -0
  23. data/app/views/devise/mailer/invitation_instructions.html.erb +1087 -0
  24. data/app/views/devise/passwords/edit.html.haml +21 -0
  25. data/app/views/devise/passwords/new.html.haml +10 -0
  26. data/app/views/devise/registrations/edit.html.haml +51 -0
  27. data/app/views/devise/registrations/new.html.haml +32 -0
  28. data/app/views/devise/sessions/new.html.haml +25 -0
  29. data/app/views/devise/shared/_links.html.haml +24 -0
  30. data/app/views/devise/unlocks/new.html.haml +13 -0
  31. data/app/views/oxen/users/_account_user.html.haml +14 -0
  32. data/app/views/oxen/users/_account_users.html.haml +15 -0
  33. data/app/views/oxen/users/_form.html.haml +41 -0
  34. data/app/views/oxen/users/_user_form.html.erb +12 -0
  35. data/app/views/oxen/users/confirm.html.haml +4 -0
  36. data/app/views/oxen/users/invitations/_new.html.haml +38 -0
  37. data/app/views/oxen/users/invitations/create.html.haml +5 -0
  38. data/app/views/oxen/users/invitations/edit.html.haml +22 -0
  39. data/bin/console +14 -0
  40. data/bin/setup +7 -0
  41. data/config/initializers/devise.rb +360 -0
  42. data/config/initializers/devise_permitted_parameters.rb +17 -0
  43. data/config/locales/devise.da.yml +58 -0
  44. data/config/locales/devise.en.yml +61 -0
  45. data/config/locales/devise_invitable.da.yml +26 -0
  46. data/config/locales/devise_invitable.en.yml +23 -0
  47. data/config/routes.rb +51 -0
  48. data/lib/generators/oxen_user/account_generator.rb +26 -0
  49. data/lib/generators/oxen_user/templates/user.rb +10 -0
  50. data/lib/generators/oxen_user/templates/user_permission.rb +14 -0
  51. data/lib/oxen_user/engine.rb +17 -0
  52. data/lib/oxen_user/version.rb +3 -0
  53. data/lib/oxen_user.rb +10 -0
  54. data/oxen_user.gemspec +57 -0
  55. metadata +377 -0
@@ -0,0 +1,21 @@
1
+ - content_for :title do
2
+ = t('.title')
3
+
4
+ %h3= t('.change_password')
5
+ %p= t('.instruction_on_setting')
6
+
7
+ .row
8
+ .col.s12
9
+ .authform
10
+ = simple_form_for( resource, as: resource_name, url: password_path(resource_name), html: { method: :put, role: 'form'}) do |f|
11
+ = devise_error_messages!
12
+ = f.hidden_field :reset_password_token
13
+ .row
14
+ .input-field.col.s6
15
+ = f.input :password, class: :validate, autofocus: true
16
+
17
+ .input-field.col.s6
18
+ = f.input :password_confirmation, class: :validate, autofocus: true
19
+
20
+ .form-actions
21
+ = f.submit t('.labels.set'), class: 'btn right'
@@ -0,0 +1,10 @@
1
+ .authform
2
+ =form_for( resource, as: resource_name, url: password_path(resource_name), html: { method: :post, role: 'form'}) do |f|
3
+ %h3= t('password.forgot')
4
+ %p= t('password.instruction_on_sending_reset')
5
+ = devise_error_messages!
6
+ .form_group
7
+ = f.label :email
8
+ = f.email_field :email, autofocus: true, class: 'form-control'
9
+ .form-actions
10
+ = f.submit t('password.labels.reset'), class: 'btn right'
@@ -0,0 +1,51 @@
1
+ - title = t( '%s.%s.title' % [resource_class.table_name,params[:action]])
2
+ - content_for :title do
3
+ = title
4
+
5
+ %h3= title
6
+
7
+ = simple_form_for(resource, as: resource_name, url: registration_path(resource_name), html: { method: :put, class: 'col sl12', role: 'form'}) do |f|
8
+ = f.error_notification
9
+
10
+ .form-inputs
11
+ .row
12
+ .input-field.col.s12
13
+ = f.input :name, class: :validate, autofocus: true
14
+
15
+ .row
16
+ .input-field.col.s12
17
+ = f.input :email, class: :validate, autofocus: true
18
+
19
+ .row
20
+ .input-field.col.sl12
21
+ %p.col= t('.leave_blank_if_no_change')
22
+ .input-field.col.s12.m6
23
+ = f.input :password, class: :validate, autofocus: true, autocomplete: 'off'
24
+
25
+ .input-field.col.s12.m6
26
+ = f.input :password_confirmation, class: :validate, autofocus: true
27
+
28
+
29
+ .row
30
+ .input-field.col.sl12
31
+ %p.col= t('.current_password_required_to_make_changes')
32
+ .input-field.col.s12
33
+ = f.input :current_password, class: :validate, autofocus: true
34
+
35
+ .row
36
+ .col.sl12{ style: "margin-bottom: 30px"}
37
+ %hr
38
+
39
+ .row{ style: "margin-right: 0px"}
40
+ .form-actions.right-align
41
+ = f.button :submit, t('.update'), class: 'right'
42
+
43
+ %h3= t('.cancel_account')
44
+ %p= t('.unhappy_sad_to_see_you_go')
45
+
46
+ = button_to t('.cancel_account'), registration_path(resource_name), :data => { :confirm => "Are you sure?" }, :method => :delete, :class => 'btn btn-default right'
47
+
48
+
49
+ - if %w{ show edit }.include? params[:action]
50
+ :coffeescript
51
+ $('form label').addClass('active')
@@ -0,0 +1,32 @@
1
+ - title = t( '%s.%s.title' % [resource_class.table_name,params[:action]])
2
+ - content_for :title do
3
+ = title
4
+
5
+ %h3= title
6
+
7
+ = simple_form_for(resource, as: resource_name, url: registration_path(resource_name), html: { class: 'col sl12', role: 'form'}) do |f|
8
+ = f.error_notification
9
+
10
+ .form-inputs
11
+ .row
12
+ .input-field.col.s12
13
+ = f.input :name, class: :validate, autofocus: true
14
+
15
+ .row
16
+ .input-field.col.s12
17
+ = f.input :email, class: :validate, autofocus: true
18
+
19
+ .row
20
+ .input-field.col.s12.m6
21
+ = f.input :password, class: "validate estimate-password", autofocus: true
22
+
23
+ .input-field.col.s12.m6
24
+ = f.input :password_confirmation, class: :validate, autofocus: true
25
+
26
+ .row
27
+ .col.sl12{ style: "margin-bottom: 30px"}
28
+ %hr
29
+
30
+ .row
31
+ .form-actions.right-align
32
+ = f.button :submit, t('.submit')
@@ -0,0 +1,25 @@
1
+ / TODO 2015-05-08 make users sign-up / sign-in with OAuth
2
+ / see http://www.sitepoint.com/rails-authentication-oauth-2-0-omniauth/
3
+ /
4
+ - content_for :title do
5
+ = t('.title')
6
+
7
+ .row
8
+ %h3= t('.title')
9
+ = simple_form_for(resource, as: resource_name, url: session_path(resource_name), :html => { :role => 'form', class: 'col s12'}) do |f|
10
+ = devise_error_messages!
11
+ .row
12
+ -# - if devise_mapping.registerable?
13
+ -# = link_to t(:sign_up), new_registration_path(resource_name), class: 'right'
14
+ = f.input :email, required: false, autofocus: true
15
+ .row
16
+ - if devise_mapping.recoverable?
17
+ = link_to t(:forgot_password), new_password_path(resource_name), class: 'right'
18
+ = f.input :password, required: false
19
+ .row
20
+ = f.input( :remember_me, as: :boolean) if devise_mapping.rememberable?
21
+
22
+ %hr{ style: "margin-top: 100px"}
23
+
24
+ .form-actions.right-align
25
+ = f.button :submit
@@ -0,0 +1,24 @@
1
+ - if controller_name != 'sessions'
2
+ = link_to "Log in", new_session_path(resource_name)
3
+ %br
4
+
5
+ - if devise_mapping.registerable? && controller_name != 'registrations'
6
+ = link_to "Sign in", new_registration_path(resource_name)
7
+ %br
8
+
9
+ - if devise_mapping.recoverable? && controller_name != 'passwords' && controller_name != 'registrations'
10
+ = link_to "Forgot your password?", new_password_path(resource_name)
11
+ %br
12
+
13
+ - if devise_mapping.confirmable? && controller_name != 'confirmations'
14
+ = link_to "Didn't receive confirmation instructions?", new_confirmation_path(resource_name)
15
+ %br
16
+
17
+ - if devise_mapping.lockable? && resource_class.unlock_strategy_enabled?(:email) && controller_name != 'unlocks'
18
+ = link_to "Didn't receive unlock instructions?", new_unlock_path(resource_name)
19
+ %br
20
+
21
+ - if devise_mapping.omniauthable?
22
+ - resource_class.omniauth_providers.each do |provider|
23
+ = link_to "Sign in with #{provider.to_s.titleize}", omniauth_authorize_path(resource_name, provider)
24
+ %br
@@ -0,0 +1,13 @@
1
+ %h2 Resend unlock instructions
2
+
3
+ = simple_form_for(resource, as: resource_name, url: unlock_path(resource_name), html: { method: :post }) do |f|
4
+ = f.error_notification
5
+ = f.full_error :unlock_token
6
+
7
+ .form-inputs
8
+ = f.input :email, required: true, autofocus: true
9
+
10
+ .form-actions
11
+ = f.button :submit, "Resend unlock instructions"
12
+
13
+ = render "devise/shared/links"
@@ -0,0 +1,14 @@
1
+ %tr{ id: "tr-#{user.id}", class:"#{invited_user? user}"}
2
+ %td= link_to user.name, user
3
+ %td= user.email
4
+ %td= show_resource_active user
5
+ %td
6
+ - if user.confirmed?
7
+ %i.small.material-icons done
8
+ - else
9
+ = link_to url_for(user) + '/confirm', class: "unconfirmed yellow-text" do
10
+ = content_tag :i, 'report_problem', class: "material-icons"
11
+ %td
12
+ -# TODO use API into mgmt.oxen.dk
13
+ -# = link_to user, class: 'delete_link', data: { url: '/admin/users', name: "#{user.name}", id: "#{user.id}", remove: "#tr-#{user.id}" } do
14
+ -# %i.mdi-action-delete.small{ title: "#{t('.delete')}"}
@@ -0,0 +1,15 @@
1
+ .row
2
+ .col.s12
3
+ %h5= t('.users')
4
+ %table.responsive-table.hoverable.striped.resources_table
5
+ %thead
6
+ %tr
7
+ %th{ :"data-field"=>"name"}= t('.name')
8
+ %th{ :"data-field"=>"email"}= t('.email')
9
+ %th{ :"data-field"=>"active"}= t('.active')
10
+ %th{ :"data-field"=>"active"}= t('.confirmed')
11
+ %th= t(:delete)
12
+
13
+ %tbody#account_users.resources_list
14
+ - resource.users.each do |user|
15
+ = render partial: 'users/account_user', locals: { user: user}
@@ -0,0 +1,41 @@
1
+ = simple_form_for(resource, html: {class: 'col sl12'} ) do |f|
2
+ / - if parent?
3
+ / = render @parent
4
+ = f.error_notification
5
+
6
+ .form-inputs
7
+ .row
8
+ .input-field.col.s12
9
+ = f.input :name, class: :validate, disabled: @disabled, autofocus: true
10
+
11
+ .row
12
+ .input-field.col.s12
13
+ = f.input :account_id, collection: policy_scope(Account), class: :validate, disabled: @disabled, autofocus: true
14
+
15
+ .row
16
+ .input-field.col.s12
17
+ = f.input :email, class: :validate, disabled: @disabled, autofocus: true
18
+
19
+ .row
20
+ .input-field.col.s6
21
+ = f.input :password, class: :validate, disabled: @disabled, autofocus: true
22
+
23
+ .input-field.col.s6
24
+ = f.input :password_confirmation, class: :validate, disabled: @disabled, autofocus: true
25
+
26
+
27
+ .row
28
+ .input-field.col.s6
29
+ = f.input :role, collection: User.policed_roles(current_user), class: :validate, disabled: @disabled
30
+ .input-field.col.s6
31
+ %label{ style: "margin-top: -20px"}= t('.account_active')
32
+ .switch
33
+ %label
34
+ = t(:passive)
35
+ =f.check_box :active, disabled: @disabled
36
+ %span.lever
37
+ = t(:active)
38
+
39
+ .row
40
+ .col.sl12{ style: "margin-bottom: 30px"}
41
+ %hr
@@ -0,0 +1,12 @@
1
+ <td>
2
+ <%= link_to user.email, user %>
3
+ </td>
4
+ <td>
5
+ <%= form_for(user) do |f| %>
6
+ <%= f.select(:role, User.roles.keys.map {|role| [role.titleize,role]}) %>
7
+ <%= f.submit 'Change Role', :class => 'button-xs' %>
8
+ <% end %>
9
+ </td>
10
+ <td>
11
+ <%= link_to("Delete user", user_path(user), :data => { :confirm => "Are you sure?" }, :method => :delete, :class => 'button-xs') unless user == current_user %>
12
+ </td>
@@ -0,0 +1,4 @@
1
+ %i.material-icons done
2
+
3
+ :javascript
4
+ eval("#{set_toasts}");
@@ -0,0 +1,38 @@
1
+ .row
2
+ .col.s12
3
+ .card-panel
4
+ %h5= t('.invite_user')
5
+ = simple_form_for User.new, url: invitation_path('user'), html: {method: :post} do |f|
6
+ = devise_error_messages!
7
+
8
+ %input{ type: 'hidden', name: 'user[account_id]', value: account_id }
9
+ .form-inputs
10
+ .row
11
+ .input-field.col.s12
12
+ = f.input :name, class: :validate, autofocus: true
13
+
14
+ .row
15
+ .input-field.col.s12
16
+ = f.input :email, class: :validate
17
+
18
+ .form-actions.right-align
19
+ = f.button :submit, t('.invite_user_submit')
20
+
21
+ :coffeescript
22
+
23
+ $ ->
24
+ $(document.body).on 'click', 'input[name="commit"]', (e) ->
25
+ e.preventDefault()
26
+ e.stopPropagation()
27
+ $form = $(e.target).closest('form')
28
+ data = $form.serialize()
29
+ jqxhr = $.ajax
30
+ url: '/users/invitation.js',
31
+ type: 'post',
32
+ data: data
33
+ .done (response) ->
34
+ $('#account_users').append(response)
35
+ fadeItOut $('.message_container .alert-success')
36
+ .fail (response) ->
37
+ $('body').append(response.responseText)
38
+ fadeItOut $('.message_container .alert-danger'), 5000
@@ -0,0 +1,5 @@
1
+ - if result
2
+ = render partial: 'users/account_user', locals: { user: resource }
3
+
4
+ :javascript
5
+ eval("#{set_toasts}");
@@ -0,0 +1,22 @@
1
+ - content_for :title do
2
+ = t 'devise.invitations.edit.title'
3
+
4
+ - @disabled = false
5
+
6
+ %h3= t 'devise.invitations.edit.header'
7
+ %p= t 'devise.invitations.edit.instructions'
8
+ = simple_form_for resource, :as => resource_name, :url => invitation_path(resource_name), :html => { :method => :put } do |f|
9
+ = f.error_notification
10
+ = f.hidden_field :invitation_token
11
+
12
+ .form-inputs
13
+ .row
14
+ .input-field.col.s12.m6
15
+ = f.input :password, class: :validate, disabled: @disabled, autofocus: true
16
+
17
+ .input-field.col.s12.m6
18
+ = f.input :password_confirmation, class: :validate, disabled: @disabled, autofocus: true
19
+
20
+ .form-actions.right-align
21
+ .row
22
+ = f.button :submit, t("devise.invitations.edit.submit_button")
data/bin/console ADDED
@@ -0,0 +1,14 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ require "bundler/setup"
4
+ require "account"
5
+
6
+ # You can add fixtures and/or initialization code here to make experimenting
7
+ # with your gem easier. You can also use a different console, if you like.
8
+
9
+ # (If you use this, don't forget to add pry to your Gemfile!)
10
+ # require "pry"
11
+ # Pry.start
12
+
13
+ require "irb"
14
+ IRB.start
data/bin/setup ADDED
@@ -0,0 +1,7 @@
1
+ #!/bin/bash
2
+ set -euo pipefail
3
+ IFS=$'\n\t'
4
+
5
+ bundle install
6
+
7
+ # Do any other automated setup that you need to do here