oxen_account 0.1.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/.envrc +0 -0
- data/.gitignore +9 -0
- data/.rspec +3 -0
- data/.ruby-version +1 -0
- data/.travis.yml +3 -0
- data/CODE_OF_CONDUCT.md +13 -0
- data/Gemfile +6 -0
- data/Guardfile +77 -0
- data/LICENSE.txt +21 -0
- data/README.md +39 -0
- data/Rakefile +10 -0
- data/app/controllers/accounts_controller.rb +90 -0
- data/app/controllers/users/base/invitations_controller.rb +61 -0
- data/app/controllers/users/base/users_controller.rb +68 -0
- data/app/helpers/accounts_helper.rb +7 -0
- data/app/models/account.rb +8 -0
- data/app/models/user.rb +18 -0
- data/app/policies/account_policy.rb +43 -0
- data/app/policies/user_policy.rb +35 -0
- data/app/views/accounts/_form.html.haml +32 -0
- data/app/views/accounts/index.html.haml +37 -0
- data/app/views/accounts/index.json.jbuilder +4 -0
- data/app/views/accounts/show.html.haml +16 -0
- data/app/views/accounts/show.json.jbuilder +1 -0
- data/app/views/devise/confirmations/new.html.haml +13 -0
- data/app/views/devise/mailer/invitation_instructions.html.erb +7 -0
- data/app/views/devise/passwords/edit.html.haml +21 -0
- data/app/views/devise/passwords/new.html.haml +10 -0
- data/app/views/devise/registrations/edit.html.haml +51 -0
- data/app/views/devise/registrations/new.html.haml +32 -0
- data/app/views/devise/sessions/new.html.haml +25 -0
- data/app/views/devise/shared/_links.html.haml +24 -0
- data/app/views/devise/unlocks/new.html.haml +13 -0
- data/app/views/users/_account_user.html.haml +6 -0
- data/app/views/users/_account_users.html.haml +13 -0
- data/app/views/users/_form.html.haml +50 -0
- data/app/views/users/_user.html.erb +12 -0
- data/app/views/users/index.html.haml +43 -0
- data/app/views/users/invitations/_new.html.haml +37 -0
- data/app/views/users/invitations/create.html.haml +21 -0
- data/app/views/users/invitations/edit.html.haml +22 -0
- data/bin/console +14 -0
- data/bin/setup +7 -0
- data/config/initializers/devise.rb +303 -0
- data/config/initializers/devise_permitted_parameters.rb +17 -0
- data/config/locales/devise.da.yml +58 -0
- data/config/locales/devise.en.yml +61 -0
- data/config/locales/devise_invitable.da.yml +26 -0
- data/config/locales/devise_invitable.en.yml +23 -0
- data/config/routes.rb +8 -0
- data/lib/generators/oxen_account/account_generator.rb +26 -0
- data/lib/generators/oxen_account/templates/account.rb +10 -0
- data/lib/generators/oxen_account/templates/user_permission.rb +14 -0
- data/lib/oxen_account/engine.rb +17 -0
- data/lib/oxen_account/version.rb +3 -0
- data/lib/oxen_account.rb +7 -0
- data/oxen_account.gemspec +55 -0
- metadata +381 -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,13 @@
|
|
1
|
+
.row
|
2
|
+
.col.s12
|
3
|
+
%h5= t('.users')
|
4
|
+
%table.responsive-table.hoverable.striped
|
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
|
+
|
11
|
+
%tbody#account_users
|
12
|
+
- resource.users.each do |user|
|
13
|
+
= render partial: 'users/account_user', locals: { user: user}
|
@@ -0,0 +1,50 @@
|
|
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
|
42
|
+
|
43
|
+
- unless @disabled
|
44
|
+
.row
|
45
|
+
.form-actions.right-align
|
46
|
+
= f.button :submit, t(".#{params[:action]}.submit")
|
47
|
+
|
48
|
+
- if %w{ show edit }.include? params[:action]
|
49
|
+
:coffeescript
|
50
|
+
$('form label').addClass('active')
|
@@ -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,43 @@
|
|
1
|
+
|
2
|
+
- content_for :title do
|
3
|
+
= t('.title')
|
4
|
+
|
5
|
+
.row
|
6
|
+
.col.s12
|
7
|
+
%h3= t('.title')
|
8
|
+
%form{ class: 'col s12', style: "font-size: 1.5em"}
|
9
|
+
.input-field
|
10
|
+
%input.col.s11{ placeholder: "#{ t('.search')}", autofocus:"autofocus", type: "text", name:"user[q]", id:'user_q'}
|
11
|
+
%i.col.s1.mdi-action-search{ style: "font-size: 2em"}
|
12
|
+
|
13
|
+
.row
|
14
|
+
.col.s12
|
15
|
+
%table.responsive-table.hoverable.striped
|
16
|
+
%thead
|
17
|
+
%tr
|
18
|
+
%th{ :"data-field"=>"name"}= t('.name')
|
19
|
+
%th{ :"data-field"=>"account"}= t('.account')
|
20
|
+
%th{ :"data-field"=>"email"}= t('.email')
|
21
|
+
%th{ :"data-field"=>"active"}= t('.active')
|
22
|
+
%th{ :"data-field"=>"invitations"}= t('.invitations')
|
23
|
+
%th= t(:delete)
|
24
|
+
|
25
|
+
%tbody
|
26
|
+
- @resources.each do |user|
|
27
|
+
%tr{ id: "tr-#{user.id}", class:"#{invited_user? user}"}
|
28
|
+
%td= link_to user.name, user
|
29
|
+
%td= link_to( user.account.name, user.account) rescue ''
|
30
|
+
%td= user.email rescue ''
|
31
|
+
%td
|
32
|
+
- if user.active
|
33
|
+
%i.mdi-action-done.small
|
34
|
+
%td= user.invitations.count
|
35
|
+
%td
|
36
|
+
= link_to user, class: 'delete_link', data: { url: '/admin/users', name: "#{user.name}", id: "#{user.id}", remove: "#tr-#{user.id}" } do
|
37
|
+
%i.mdi-action-delete.small{ title: "#{t('.delete')}"}
|
38
|
+
|
39
|
+
%br
|
40
|
+
|
41
|
+
.row
|
42
|
+
.right-align
|
43
|
+
= link_to t('.new'), new_user_path, class: 'waves-effect waves-light btn' if policy(resource).new?
|
@@ -0,0 +1,37 @@
|
|
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
|
+
$('input[name="commit"]').on 'click', (e) ->
|
25
|
+
e.preventDefault()
|
26
|
+
$form = $(e.target).closest('form')
|
27
|
+
data = $form.serialize()
|
28
|
+
jqxhr = $.ajax
|
29
|
+
url: '/users/invitation',
|
30
|
+
type: 'post',
|
31
|
+
data: data
|
32
|
+
.done (response) ->
|
33
|
+
$('#account_users').append(response)
|
34
|
+
fadeItOut $('.message_container .alert-success')
|
35
|
+
.fail (response) ->
|
36
|
+
$('body').append(response.responseText)
|
37
|
+
fadeItOut $('.message_container .alert-danger'), 5000
|
@@ -0,0 +1,21 @@
|
|
1
|
+
- if result
|
2
|
+
= render partial: 'users/account_user', locals: { user: resource }
|
3
|
+
|
4
|
+
:coffeescript
|
5
|
+
$ ->
|
6
|
+
$('.message_container').append '<div class="alert alert-success">' +
|
7
|
+
'<a aria-hidden="true" class="btn-floating btn-small close-notice success waves-effect waves-light" data-dismiss="alert" type="button">'+
|
8
|
+
'<i class="mdi-navigation-close"></i>'+
|
9
|
+
'</a>'+
|
10
|
+
'<div id="flash_notice">#{t("devise.invitations.send_instructions", email: resource.email)}</div>'+
|
11
|
+
'</div>'
|
12
|
+
|
13
|
+
- else
|
14
|
+
:coffeescript
|
15
|
+
$ ->
|
16
|
+
$('.message_container').append '<div class="alert alert-danger">' +
|
17
|
+
'<a aria-hidden="true" class="btn-floating btn-small close-notice danger waves-effect waves-light" data-dismiss="alert" type="button">'+
|
18
|
+
'<i class="mdi-navigation-close"></i>'+
|
19
|
+
'</a>'+
|
20
|
+
'<div id="flash_notice">#{t("devise.failure.missing_data")}</div>'+
|
21
|
+
'</div>'
|
@@ -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
|