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
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: 84189d5dfafb4e4a94047f813901e9a186888127
|
4
|
+
data.tar.gz: 6c6bba07971fd418c69dd12d15a7f911bf60db2a
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: 70590d219402889994ea4c8bd4c0191291e13cdd6cd17b4268dffcf6293c492b803899d44fc19c3464e03874886fded2e25782d821a5970e111c8934498a567d
|
7
|
+
data.tar.gz: e8a60b3c3d0c612ffbd20399594c47d8c736850eea1ee11995a2117a3859aeab62d5a323eafa92ce7e99501cdd910928cc8b4233120afede5e54f6eb76a86955
|
data/.envrc
ADDED
File without changes
|
data/.gitignore
ADDED
data/.rspec
ADDED
data/.ruby-version
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
2.2.1
|
data/.travis.yml
ADDED
data/CODE_OF_CONDUCT.md
ADDED
@@ -0,0 +1,13 @@
|
|
1
|
+
# Contributor Code of Conduct
|
2
|
+
|
3
|
+
As contributors and maintainers of this project, we pledge to respect all people who contribute through reporting issues, posting feature requests, updating documentation, submitting pull requests or patches, and other activities.
|
4
|
+
|
5
|
+
We are committed to making participation in this project a harassment-free experience for everyone, regardless of level of experience, gender, gender identity and expression, sexual orientation, disability, personal appearance, body size, race, age, or religion.
|
6
|
+
|
7
|
+
Examples of unacceptable behavior by participants include the use of sexual language or imagery, derogatory comments or personal attacks, trolling, public or private harassment, insults, or other unprofessional conduct.
|
8
|
+
|
9
|
+
Project maintainers have the right and responsibility to remove, edit, or reject comments, commits, code, wiki edits, issues, and other contributions that are not aligned to this Code of Conduct. Project maintainers who do not follow the Code of Conduct may be removed from the project team.
|
10
|
+
|
11
|
+
Instances of abusive, harassing, or otherwise unacceptable behavior may be reported by opening an issue or contacting one or more of the project maintainers.
|
12
|
+
|
13
|
+
This Code of Conduct is adapted from the [Contributor Covenant](http:contributor-covenant.org), version 1.0.0, available at [http://contributor-covenant.org/version/1/0/0/](http://contributor-covenant.org/version/1/0/0/)
|
data/Gemfile
ADDED
data/Guardfile
ADDED
@@ -0,0 +1,77 @@
|
|
1
|
+
# A sample Guardfile
|
2
|
+
# More info at https://github.com/guard/guard#readme
|
3
|
+
|
4
|
+
## Uncomment and set this to only include directories you want to watch
|
5
|
+
# directories %w(app lib config test spec features)
|
6
|
+
|
7
|
+
## Uncomment to clear the screen before every task
|
8
|
+
# clearing :on
|
9
|
+
|
10
|
+
## Guard internally checks for changes in the Guardfile and exits.
|
11
|
+
## If you want Guard to automatically start up again, run guard in a
|
12
|
+
## shell loop, e.g.:
|
13
|
+
##
|
14
|
+
## $ while bundle exec guard; do echo "Restarting Guard..."; done
|
15
|
+
##
|
16
|
+
## Note: if you are using the `directories` clause above and you are not
|
17
|
+
## watching the project directory ('.'), then you will want to move
|
18
|
+
## the Guardfile to a watched dir and symlink it back, e.g.
|
19
|
+
#
|
20
|
+
# $ mkdir config
|
21
|
+
# $ mv Guardfile config/
|
22
|
+
# $ ln -s config/Guardfile .
|
23
|
+
#
|
24
|
+
# and, you'll have to watch "config/Guardfile" instead of "Guardfile"
|
25
|
+
|
26
|
+
# Note: The cmd option is now required due to the increasing number of ways
|
27
|
+
# rspec may be run, below are examples of the most common uses.
|
28
|
+
# * bundler: 'bundle exec rspec'
|
29
|
+
# * bundler binstubs: 'bin/rspec'
|
30
|
+
# * spring: 'bin/rspec' (This will use spring if running and you have
|
31
|
+
# installed the spring binstubs per the docs)
|
32
|
+
# * zeus: 'zeus rspec' (requires the server to be started separately)
|
33
|
+
# * 'just' rspec: 'rspec'
|
34
|
+
|
35
|
+
guard :rspec, cmd: "bundle exec rspec" do
|
36
|
+
require "guard/rspec/dsl"
|
37
|
+
dsl = Guard::RSpec::Dsl.new(self)
|
38
|
+
|
39
|
+
# Feel free to open issues for suggestions and improvements
|
40
|
+
|
41
|
+
# RSpec files
|
42
|
+
rspec = dsl.rspec
|
43
|
+
watch(rspec.spec_helper) { rspec.spec_dir }
|
44
|
+
watch(rspec.spec_support) { rspec.spec_dir }
|
45
|
+
watch(rspec.spec_files)
|
46
|
+
|
47
|
+
# Ruby files
|
48
|
+
ruby = dsl.ruby
|
49
|
+
dsl.watch_spec_files_for(ruby.lib_files)
|
50
|
+
|
51
|
+
# Rails files
|
52
|
+
rails = dsl.rails(view_extensions: %w(erb haml slim))
|
53
|
+
dsl.watch_spec_files_for(rails.app_files)
|
54
|
+
dsl.watch_spec_files_for(rails.views)
|
55
|
+
|
56
|
+
watch(rails.controllers) do |m|
|
57
|
+
[
|
58
|
+
rspec.spec.("routing/#{m[1]}_routing"),
|
59
|
+
rspec.spec.("controllers/#{m[1]}_controller"),
|
60
|
+
rspec.spec.("acceptance/#{m[1]}")
|
61
|
+
]
|
62
|
+
end
|
63
|
+
|
64
|
+
# Rails config changes
|
65
|
+
watch(rails.spec_helper) { rspec.spec_dir }
|
66
|
+
watch(rails.routes) { "#{rspec.spec_dir}/routing" }
|
67
|
+
watch(rails.app_controller) { "#{rspec.spec_dir}/controllers" }
|
68
|
+
|
69
|
+
# Capybara features specs
|
70
|
+
watch(rails.view_dirs) { |m| rspec.spec.("features/#{m[1]}") }
|
71
|
+
|
72
|
+
# Turnip features and steps
|
73
|
+
watch(%r{^spec/acceptance/(.+)\.feature$})
|
74
|
+
watch(%r{^spec/acceptance/steps/(.+)_steps\.rb$}) do |m|
|
75
|
+
Dir[File.join("**/#{m[1]}.feature")][0] || "spec/acceptance"
|
76
|
+
end
|
77
|
+
end
|
data/LICENSE.txt
ADDED
@@ -0,0 +1,21 @@
|
|
1
|
+
The MIT License (MIT)
|
2
|
+
|
3
|
+
Copyright (c) 2015 Walther H Diechmann
|
4
|
+
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
7
|
+
in the Software without restriction, including without limitation the rights
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
10
|
+
furnished to do so, subject to the following conditions:
|
11
|
+
|
12
|
+
The above copyright notice and this permission notice shall be included in
|
13
|
+
all copies or substantial portions of the Software.
|
14
|
+
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
21
|
+
THE SOFTWARE.
|
data/README.md
ADDED
@@ -0,0 +1,39 @@
|
|
1
|
+
# OxenAccount
|
2
|
+
|
3
|
+
Welcome to your new gem! In this directory, you'll find the files you need to be able to package up your Ruby library into a gem. Put your Ruby code in the file `lib/account`. To experiment with that code, run `bin/console` for an interactive prompt.
|
4
|
+
|
5
|
+
TODO: Delete this and the text above, and describe your gem
|
6
|
+
|
7
|
+
## Installation
|
8
|
+
|
9
|
+
Add this line to your application's Gemfile:
|
10
|
+
|
11
|
+
```ruby
|
12
|
+
gem 'account'
|
13
|
+
```
|
14
|
+
|
15
|
+
And then execute:
|
16
|
+
|
17
|
+
$ bundle
|
18
|
+
|
19
|
+
Or install it yourself as:
|
20
|
+
|
21
|
+
$ gem install account
|
22
|
+
|
23
|
+
## Usage
|
24
|
+
|
25
|
+
TODO: Write usage instructions here
|
26
|
+
|
27
|
+
## Development
|
28
|
+
|
29
|
+
After checking out the repo, run `bin/setup` to install dependencies. Then, run `bin/console` for an interactive prompt that will allow you to experiment.
|
30
|
+
|
31
|
+
To install this gem onto your local machine, run `bundle exec rake install`. To release a new version, update the version number in `version.rb`, and then run `bundle exec rake release` to create a git tag for the version, push git commits and tags, and push the `.gem` file to [rubygems.org](https://rubygems.org).
|
32
|
+
|
33
|
+
## Contributing
|
34
|
+
|
35
|
+
1. Fork it ( https://github.com/[my-github-username]/account/fork )
|
36
|
+
2. Create your feature branch (`git checkout -b my-new-feature`)
|
37
|
+
3. Commit your changes (`git commit -am 'Add some feature'`)
|
38
|
+
4. Push to the branch (`git push origin my-new-feature`)
|
39
|
+
5. Create a new Pull Request
|
data/Rakefile
ADDED
@@ -0,0 +1,10 @@
|
|
1
|
+
require "bundler/gem_tasks"
|
2
|
+
|
3
|
+
Dir[File.join(File.dirname(__FILE__), 'tasks/**/*.rake')].each {|f| load f }
|
4
|
+
|
5
|
+
require 'rspec/core'
|
6
|
+
require 'rspec/core/rake_task'
|
7
|
+
desc "Run all specs in spec directory (excluding plugin specs)"
|
8
|
+
#
|
9
|
+
# not working in RoR => 4.1 RSpec::Core::RakeTask.new(:spec => 'app:db:test:prepare')
|
10
|
+
task :default => :spec
|
@@ -0,0 +1,90 @@
|
|
1
|
+
class AccountsController < AbstractResourcesController
|
2
|
+
|
3
|
+
# before_filter :authenticate_user!
|
4
|
+
# before_filter :set_parents, only: [ :new, :edit, :show ]
|
5
|
+
# before_action :set_account, only: [:show, :edit, :update, :destroy]
|
6
|
+
|
7
|
+
# GET /accounts
|
8
|
+
# GET /accounts.json
|
9
|
+
# def index
|
10
|
+
# @accounts = Account.all
|
11
|
+
# end
|
12
|
+
# def index
|
13
|
+
# @resources = policy_scope(Account)
|
14
|
+
# authorize Account
|
15
|
+
# end
|
16
|
+
|
17
|
+
# GET /accounts/1
|
18
|
+
# GET /accounts/1.json
|
19
|
+
# def show
|
20
|
+
# end
|
21
|
+
|
22
|
+
|
23
|
+
# GET /accounts/new
|
24
|
+
# def new
|
25
|
+
# @account = Account.new
|
26
|
+
# end
|
27
|
+
|
28
|
+
# GET /accounts/1/edit
|
29
|
+
# def edit
|
30
|
+
# end
|
31
|
+
|
32
|
+
# POST /accounts
|
33
|
+
# POST /accounts.json
|
34
|
+
# def create
|
35
|
+
# @account = Account.new(account_params)
|
36
|
+
#
|
37
|
+
# respond_to do |format|
|
38
|
+
# if @account.save
|
39
|
+
# format.html { redirect_to @account, notice: 'Account was successfully created.' }
|
40
|
+
# format.json { render :show, status: :created, location: @account }
|
41
|
+
# else
|
42
|
+
# format.html { render :new }
|
43
|
+
# format.json { render json: @account.errors, status: :unprocessable_entity }
|
44
|
+
# end
|
45
|
+
# end
|
46
|
+
# end
|
47
|
+
|
48
|
+
# PATCH/PUT /accounts/1
|
49
|
+
# PATCH/PUT /accounts/1.json
|
50
|
+
# def update
|
51
|
+
# respond_to do |format|
|
52
|
+
# if @account.update(account_params)
|
53
|
+
# format.html { redirect_to @account, notice: 'Account was successfully updated.' }
|
54
|
+
# format.json { render :show, status: :ok, location: @account }
|
55
|
+
# else
|
56
|
+
# format.html { render :edit }
|
57
|
+
# format.json { render json: @account.errors, status: :unprocessable_entity }
|
58
|
+
# end
|
59
|
+
# end
|
60
|
+
# end
|
61
|
+
|
62
|
+
# DELETE /accounts/1
|
63
|
+
# DELETE /accounts/1.json
|
64
|
+
# def destroy
|
65
|
+
# @account.destroy
|
66
|
+
# respond_to do |format|
|
67
|
+
# format.html { redirect_to accounts_url, notice: 'Account was successfully destroyed.' }
|
68
|
+
# format.json { head :no_content }
|
69
|
+
# end
|
70
|
+
# end
|
71
|
+
|
72
|
+
private
|
73
|
+
# Use callbacks to share common setup or constraints between actions.
|
74
|
+
# def set_account
|
75
|
+
# @account = Account.find(params[:id])
|
76
|
+
# end
|
77
|
+
|
78
|
+
# Never trust parameters from the scary internet, only allow the white list through.
|
79
|
+
# def account_params
|
80
|
+
# params.require(:account).permit(:name)
|
81
|
+
# end
|
82
|
+
|
83
|
+
def resource_params
|
84
|
+
params.require(:account).permit(:name, :active)
|
85
|
+
end
|
86
|
+
|
87
|
+
|
88
|
+
|
89
|
+
|
90
|
+
end
|
@@ -0,0 +1,61 @@
|
|
1
|
+
class Users::Base::InvitationsController < Devise::InvitationsController
|
2
|
+
|
3
|
+
#
|
4
|
+
# POST /resource/invitation
|
5
|
+
def create
|
6
|
+
self.resource = invite_resource
|
7
|
+
resource_invited = resource.errors.empty?
|
8
|
+
|
9
|
+
yield resource if block_given?
|
10
|
+
if resource_invited
|
11
|
+
# if is_flashing_format? && self.resource.invitation_sent_at
|
12
|
+
# set_flash_message :notice, :send_instructions, :email => self.resource.email
|
13
|
+
# end
|
14
|
+
render layout: false, status: 200, locals: { result: true }
|
15
|
+
else
|
16
|
+
render layout: false, status: 301, locals: { result: false }
|
17
|
+
#
|
18
|
+
# respond_with resource, :location => after_invite_path_for(current_inviter)
|
19
|
+
# else
|
20
|
+
# respond_with_navigational(resource) { render :new }
|
21
|
+
end
|
22
|
+
end
|
23
|
+
|
24
|
+
|
25
|
+
# def update
|
26
|
+
# if this
|
27
|
+
# redirect_to root_path
|
28
|
+
# else
|
29
|
+
# super
|
30
|
+
# end
|
31
|
+
# end
|
32
|
+
|
33
|
+
private
|
34
|
+
|
35
|
+
# this is called when creating invitation
|
36
|
+
# should return an instance of resource class
|
37
|
+
def invite_resource
|
38
|
+
## skip sending emails on invite
|
39
|
+
resource_class.invite!(resource_params, current_user) do |u|
|
40
|
+
# u.skip_invitation = true
|
41
|
+
end
|
42
|
+
end
|
43
|
+
|
44
|
+
def resource_params
|
45
|
+
{email: params[:user][:email], name: params[:user][:name], account_id: params[:user][:account_id] }
|
46
|
+
# params.permit(user: [:name, :email,:invitation_token, :your_params_here])[:user]
|
47
|
+
end
|
48
|
+
|
49
|
+
# this is called when accepting invitation
|
50
|
+
# should return an instance of resource class
|
51
|
+
def accept_resource
|
52
|
+
resource = resource_class.accept_invitation!(update_resource_params)
|
53
|
+
## Report accepting invitation to analytics
|
54
|
+
# Analytics.report('invite.accept', resource.id)
|
55
|
+
resource
|
56
|
+
end
|
57
|
+
|
58
|
+
# def after_invite_path_for(usr)
|
59
|
+
# end
|
60
|
+
|
61
|
+
end
|
@@ -0,0 +1,68 @@
|
|
1
|
+
class Users::Base::UsersController < AbstractResourcesController
|
2
|
+
# before_filter :authenticate_user!
|
3
|
+
# after_action :verify_authorized
|
4
|
+
before_filter :check_user_permissions, only: :create
|
5
|
+
|
6
|
+
# def index
|
7
|
+
# @users = User.all
|
8
|
+
# authorize User
|
9
|
+
# end
|
10
|
+
# def index
|
11
|
+
# @resources = policy_scope(User)
|
12
|
+
# authorize User
|
13
|
+
# end
|
14
|
+
#
|
15
|
+
# def show
|
16
|
+
# @user = User.find(params[:id])
|
17
|
+
# authorize @user
|
18
|
+
# end
|
19
|
+
#
|
20
|
+
# def update
|
21
|
+
# @user = User.find(params[:id])
|
22
|
+
# authorize @user
|
23
|
+
# if @user.update_attributes(secure_params)
|
24
|
+
# redirect_to users_path, :notice => "User updated."
|
25
|
+
# else
|
26
|
+
# redirect_to users_path, :alert => "Unable to update user."
|
27
|
+
# end
|
28
|
+
# end
|
29
|
+
#
|
30
|
+
# def destroy
|
31
|
+
# user = User.find(params[:id])
|
32
|
+
# authorize user
|
33
|
+
# user.destroy
|
34
|
+
# redirect_to users_path, :notice => "User deleted."
|
35
|
+
# end
|
36
|
+
|
37
|
+
def update
|
38
|
+
if params[:user][:password].blank? && params[:user][:password].blank?
|
39
|
+
params[:user].delete :password
|
40
|
+
params[:user].delete :password_confirmation
|
41
|
+
end
|
42
|
+
authorize resource
|
43
|
+
resource.max_role = current_user.role
|
44
|
+
if resource.update_attributes(secure_params)
|
45
|
+
redirect_to users_path, :notice => "User updated."
|
46
|
+
else
|
47
|
+
render :edit, :alert => "Unable to update user."
|
48
|
+
end
|
49
|
+
|
50
|
+
# super
|
51
|
+
end
|
52
|
+
|
53
|
+
|
54
|
+
private
|
55
|
+
|
56
|
+
def resource_params
|
57
|
+
secure_params
|
58
|
+
end
|
59
|
+
|
60
|
+
def secure_params
|
61
|
+
params.require(:user).permit(:role,:name,:email,:active,:account_id, :password, :password_confirmation)
|
62
|
+
end
|
63
|
+
|
64
|
+
def check_user_permissions
|
65
|
+
UserPermission.where(email: params[:user][:email]).count == 1
|
66
|
+
end
|
67
|
+
|
68
|
+
end
|
data/app/models/user.rb
ADDED
@@ -0,0 +1,18 @@
|
|
1
|
+
class User < AbstractResource #< ActiveRecord::Base
|
2
|
+
include Roleable
|
3
|
+
|
4
|
+
has_paper_trail
|
5
|
+
|
6
|
+
belongs_to :account
|
7
|
+
has_many :invitations, :class_name => self.to_s, :as => :invited_by
|
8
|
+
|
9
|
+
# Include default devise modules. Others available are:
|
10
|
+
# :confirmable, :lockable, :timeoutable and :omniauthable
|
11
|
+
devise :invitable, :database_authenticatable, :registerable, :confirmable,
|
12
|
+
:recoverable, :rememberable, :trackable, :validatable, :zxcvbnable
|
13
|
+
|
14
|
+
|
15
|
+
validates :name, presence: true
|
16
|
+
|
17
|
+
|
18
|
+
end
|
@@ -0,0 +1,43 @@
|
|
1
|
+
class AccountPolicy < AbstractResourcePolicy
|
2
|
+
|
3
|
+
class Scope < Scope
|
4
|
+
def resolve
|
5
|
+
if current_user.admin?
|
6
|
+
scope.all
|
7
|
+
else
|
8
|
+
scope.where(id: current_user.account.id)
|
9
|
+
end
|
10
|
+
end
|
11
|
+
end
|
12
|
+
|
13
|
+
|
14
|
+
|
15
|
+
def new?
|
16
|
+
current_user.admin?
|
17
|
+
end
|
18
|
+
|
19
|
+
def index?
|
20
|
+
@current_user.admin? || @current_user.account_admin?
|
21
|
+
end
|
22
|
+
|
23
|
+
def create?
|
24
|
+
@current_user.admin?
|
25
|
+
end
|
26
|
+
|
27
|
+
def show?
|
28
|
+
@current_user.admin? or @current_user.account==@model
|
29
|
+
end
|
30
|
+
|
31
|
+
def edit?
|
32
|
+
@current_user.admin? or @current_user.account==@model
|
33
|
+
end
|
34
|
+
|
35
|
+
def update?
|
36
|
+
@current_user.admin? or @current_user.account==@model
|
37
|
+
end
|
38
|
+
|
39
|
+
def destroy?
|
40
|
+
@current_user.admin?
|
41
|
+
end
|
42
|
+
|
43
|
+
end
|
@@ -0,0 +1,35 @@
|
|
1
|
+
class UserPolicy < AbstractResourcePolicy
|
2
|
+
|
3
|
+
class Scope < Scope
|
4
|
+
def resolve
|
5
|
+
if current_user.admin?
|
6
|
+
scope.all
|
7
|
+
else
|
8
|
+
scope.where(account_id: current_user.account.id)
|
9
|
+
end
|
10
|
+
end
|
11
|
+
end
|
12
|
+
|
13
|
+
|
14
|
+
def index?
|
15
|
+
current_user.admin? || current_user.account_admin?
|
16
|
+
end
|
17
|
+
|
18
|
+
def show?
|
19
|
+
current_user.admin? or current_user.account_admin? or current_user == model
|
20
|
+
end
|
21
|
+
|
22
|
+
def update?
|
23
|
+
current_user.admin? || current_user.account_admin?
|
24
|
+
end
|
25
|
+
|
26
|
+
def create?
|
27
|
+
current_user.admin? || current_user.account_admin?
|
28
|
+
end
|
29
|
+
|
30
|
+
def destroy?
|
31
|
+
return false if @current_user == model
|
32
|
+
current_user.admin? || current_user.account_admin?
|
33
|
+
end
|
34
|
+
|
35
|
+
end
|
@@ -0,0 +1,32 @@
|
|
1
|
+
|
2
|
+
= simple_form_for(resource, html: {class: 'col sl12'} ) do |f|
|
3
|
+
/ - if parent?
|
4
|
+
/ = render @parent
|
5
|
+
= f.error_notification
|
6
|
+
|
7
|
+
.form-inputs
|
8
|
+
.row
|
9
|
+
= f.input :name, class: :validate, disabled: @disabled, autofocus: true
|
10
|
+
|
11
|
+
.row
|
12
|
+
.input-field.col.s12
|
13
|
+
%label{ style: "margin-top: -20px"}= t('.account_active')
|
14
|
+
.switch
|
15
|
+
%label
|
16
|
+
= t(:passive)
|
17
|
+
=f.check_box :active, disabled: @disabled
|
18
|
+
%span.lever
|
19
|
+
= t(:active)
|
20
|
+
|
21
|
+
.row
|
22
|
+
.col.sl12{ style: "margin-bottom: 30px"}
|
23
|
+
%hr
|
24
|
+
|
25
|
+
- unless @disabled
|
26
|
+
.row
|
27
|
+
.form-actions.right-align
|
28
|
+
= f.button :submit, t(".#{params[:action]}.submit")
|
29
|
+
|
30
|
+
- if %w{ show edit }.include? params[:action]
|
31
|
+
:coffeescript
|
32
|
+
$('form label').addClass('active')
|
@@ -0,0 +1,37 @@
|
|
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:"account[q]", id:'account_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"=>"active"}= t('.active')
|
20
|
+
%th= t(:delete)
|
21
|
+
|
22
|
+
%tbody
|
23
|
+
- @resources.each do |account|
|
24
|
+
%tr{ id: "tr-#{account.id}"}
|
25
|
+
%td= link_to account.name, account
|
26
|
+
%td
|
27
|
+
- if account.active
|
28
|
+
%i.mdi-action-done.small
|
29
|
+
%td
|
30
|
+
= link_to account, class: 'delete_link', data: { url: '/admin/accounts', name: "#{account.name}", id: "#{account.id}", remove: "#tr-#{account.id}" } do
|
31
|
+
%i.mdi-action-delete.small{ title: "#{t('.delete')}"}
|
32
|
+
|
33
|
+
%br
|
34
|
+
|
35
|
+
.row
|
36
|
+
.right-align
|
37
|
+
= link_to t('.new'), new_account_path, class: 'waves-effect waves-light btn' if policy(resource).new?
|
@@ -0,0 +1,16 @@
|
|
1
|
+
- content_for :title do
|
2
|
+
= t( @resource_class.table_name + '.show.title')
|
3
|
+
|
4
|
+
- @disabled = true
|
5
|
+
|
6
|
+
%h3= t( @resource_class.table_name + '.show.title')
|
7
|
+
|
8
|
+
= render 'form'
|
9
|
+
|
10
|
+
.right-align
|
11
|
+
= link_to t( @resource_class.table_name + '.actions.edit'), edit_resource_url, class: 'waves-effect waves-light btn'
|
12
|
+
= link_to t( @resource_class.table_name + '.actions.index'), resources_url, class: 'waves-effect waves-light btn'
|
13
|
+
|
14
|
+
- if %w{ show }.include? params[:action]
|
15
|
+
= render partial: 'users/account_users'
|
16
|
+
= render partial: 'users/invitations/new', locals: { account_id: resource.id }
|
@@ -0,0 +1 @@
|
|
1
|
+
json.extract! @account, :id, :name, :created_at, :updated_at
|
@@ -0,0 +1,13 @@
|
|
1
|
+
%h2= t('resend.confirmation.instructions')
|
2
|
+
|
3
|
+
= simple_form_for(resource, as: resource_name, url: confirmation_path(resource_name), html: { method: :post }) do |f|
|
4
|
+
= f.error_notification
|
5
|
+
= f.full_error :confirmation_token
|
6
|
+
|
7
|
+
.form-inputs
|
8
|
+
= f.input :email, required: true, autofocus: true
|
9
|
+
|
10
|
+
.form-actions
|
11
|
+
= f.button :submit, t('resend.confirmation.instructions')
|
12
|
+
|
13
|
+
= render "devise/shared/links"
|
@@ -0,0 +1,7 @@
|
|
1
|
+
<p><%= t("devise.mailer.invitation_instructions.hello", email: @resource.email) %></p>
|
2
|
+
|
3
|
+
<p><%= t("devise.mailer.invitation_instructions.someone_invited_you", url: root_url) %></p>
|
4
|
+
|
5
|
+
<p><%= link_to t("devise.mailer.invitation_instructions.accept"), accept_invitation_url(@resource, :invitation_token => @token) %></p>
|
6
|
+
|
7
|
+
<p><%= t("devise.mailer.invitation_instructions.ignore").html_safe %></p>
|