the_role 2.1.1 → 2.3
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.gitignore +27 -3
- data/.ruby-gemset.example +1 -0
- data/.ruby-version.example +1 -0
- data/.rvmrc.example +1 -1
- data/.travis.yml +2 -2
- data/README.md +46 -47
- data/app/assets/javascripts/the_role_editinplace.js.coffee +32 -0
- data/app/controllers/admin/role_sections_controller.rb +2 -2
- data/app/controllers/admin/roles_controller.rb +2 -2
- data/app/controllers/concerns/controller.rb +23 -0
- data/{lib/generators/the_role/templates → app/models/_templates_}/role.rb +1 -1
- data/app/models/concerns/base.rb +37 -0
- data/app/models/concerns/role.rb +134 -0
- data/app/models/concerns/user.rb +57 -0
- data/app/views/admin/roles/_role.html.haml +90 -69
- data/app/views/admin/roles/_sidebar.html.haml +16 -9
- data/app/views/admin/roles/new.html.haml +11 -10
- data/config/locales/en.yml +1 -0
- data/config/locales/es.yml +28 -28
- data/config/locales/ru.yml +1 -1
- data/db/migrate/20111025025129_create_roles.rb +7 -1
- data/docs/2.1.1.png +0 -0
- data/lib/generators/the_role/USAGE +1 -1
- data/lib/generators/the_role/templates/the_role.rb +7 -2
- data/lib/generators/the_role/the_role_generator.rb +8 -5
- data/lib/tasks/roles.rake +1 -1
- data/lib/the_role/activerecord.rb +11 -0
- data/lib/the_role/config.rb +7 -0
- data/lib/the_role/version.rb +1 -1
- data/lib/the_role.rb +19 -5
- data/spec/dummy_app/.gitignore +18 -0
- data/spec/dummy_app/.rspec +1 -0
- data/spec/dummy_app/Gemfile +32 -0
- data/spec/dummy_app/README.md +39 -0
- data/spec/dummy_app/Rakefile +6 -0
- data/spec/dummy_app/app/assets/images/.keep +0 -0
- data/spec/dummy_app/app/assets/javascripts/application.js +17 -0
- data/spec/dummy_app/app/assets/stylesheets/app/style.css.scss +23 -0
- data/spec/dummy_app/app/assets/stylesheets/application.css +3 -0
- data/spec/dummy_app/app/controllers/application_controller.rb +38 -0
- data/spec/dummy_app/app/controllers/concerns/.keep +0 -0
- data/spec/dummy_app/app/controllers/pages_controller.rb +75 -0
- data/spec/dummy_app/app/controllers/users_controller.rb +32 -0
- data/spec/dummy_app/app/controllers/welcome_controller.rb +13 -0
- data/spec/dummy_app/app/helpers/application_helper.rb +2 -0
- data/spec/dummy_app/app/mailers/.keep +0 -0
- data/spec/dummy_app/app/models/.keep +0 -0
- data/spec/dummy_app/app/models/concerns/.keep +0 -0
- data/spec/dummy_app/app/models/page.rb +24 -0
- data/spec/dummy_app/app/models/role.rb +4 -0
- data/spec/dummy_app/app/models/user.rb +21 -0
- data/spec/dummy_app/app/views/layouts/_current_user_info.html.haml +17 -0
- data/spec/dummy_app/app/views/layouts/application.html.haml +68 -0
- data/spec/dummy_app/app/views/pages/_form.html.haml +19 -0
- data/spec/dummy_app/app/views/pages/edit.html.haml +7 -0
- data/spec/dummy_app/app/views/pages/index.html.haml +27 -0
- data/spec/dummy_app/app/views/pages/manage.html.haml +23 -0
- data/spec/dummy_app/app/views/pages/my.html.haml +10 -0
- data/spec/dummy_app/app/views/pages/new.html.haml +5 -0
- data/spec/dummy_app/app/views/pages/show.html.haml +15 -0
- data/spec/dummy_app/app/views/users/edit.html.haml +34 -0
- data/spec/dummy_app/app/views/welcome/index.html.haml +38 -0
- data/spec/dummy_app/app/views/welcome/profile.html.haml +2 -0
- data/spec/dummy_app/bin/bundle +3 -0
- data/spec/dummy_app/bin/rails +4 -0
- data/spec/dummy_app/bin/rake +4 -0
- data/spec/dummy_app/config/application.rb +23 -0
- data/spec/dummy_app/config/boot.rb +4 -0
- data/spec/dummy_app/config/database.yml +17 -0
- data/spec/dummy_app/config/environment.rb +5 -0
- data/spec/dummy_app/config/environments/development.rb +29 -0
- data/spec/dummy_app/config/environments/production.rb +80 -0
- data/spec/dummy_app/config/environments/test.rb +36 -0
- data/spec/dummy_app/config/initializers/backtrace_silencers.rb +7 -0
- data/spec/dummy_app/config/initializers/devise.rb +227 -0
- data/spec/dummy_app/config/initializers/filter_parameter_logging.rb +4 -0
- data/spec/dummy_app/config/initializers/inflections.rb +16 -0
- data/spec/dummy_app/config/initializers/mime_types.rb +5 -0
- data/spec/dummy_app/config/initializers/secret_token.rb +12 -0
- data/spec/dummy_app/config/initializers/session_store.rb +3 -0
- data/spec/dummy_app/config/initializers/the_role.rb +6 -0
- data/spec/dummy_app/config/initializers/wrap_parameters.rb +14 -0
- data/spec/dummy_app/config/locales/devise.en.yml +57 -0
- data/spec/dummy_app/config/locales/en.yml +7 -0
- data/spec/dummy_app/config/locales/ru.yml +4 -0
- data/spec/dummy_app/config/routes.rb +20 -0
- data/spec/dummy_app/config.ru +4 -0
- data/spec/dummy_app/db/migrate/20120212061952_devise_create_users.rb +63 -0
- data/spec/dummy_app/db/migrate/20120212063249_create_roles.rb +18 -0
- data/spec/dummy_app/db/migrate/20120314061307_create_pages.rb +14 -0
- data/spec/dummy_app/db/schema.rb +59 -0
- data/spec/dummy_app/db/seeds.rb +85 -0
- data/spec/dummy_app/lib/assets/.keep +0 -0
- data/spec/dummy_app/lib/tasks/.keep +0 -0
- data/spec/dummy_app/lib/tasks/assets.rake +15 -0
- data/spec/dummy_app/lib/tasks/db_bootstrap.rake +16 -0
- data/spec/dummy_app/log/.keep +0 -0
- data/spec/dummy_app/public/404.html +58 -0
- data/spec/dummy_app/public/422.html +58 -0
- data/spec/dummy_app/public/500.html +57 -0
- data/spec/dummy_app/public/favicon.ico +0 -0
- data/spec/dummy_app/public/robots.txt +5 -0
- data/spec/dummy_app/spec/controllers/admin_roles_controller_spec.rb +52 -0
- data/spec/dummy_app/spec/controllers/pages_controller_spec.rb +141 -0
- data/spec/dummy_app/spec/controllers/welcome_controller_spec.rb +66 -0
- data/spec/dummy_app/spec/factories/page.rb +6 -0
- data/spec/dummy_app/spec/factories/role.rb +55 -0
- data/spec/dummy_app/spec/factories/user.rb +11 -0
- data/spec/dummy_app/spec/models/hash_spec.rb +272 -0
- data/spec/dummy_app/spec/models/param_process_spec.rb +44 -0
- data/spec/dummy_app/spec/models/role_spec.rb +218 -0
- data/spec/dummy_app/spec/models/user_spec.rb +164 -0
- data/spec/dummy_app/spec/routing/admin_roles_routing_spec.rb +41 -0
- data/spec/dummy_app/spec/routing/pages_routing_spec.rb +35 -0
- data/spec/dummy_app/spec/spec_helper.rb +68 -0
- data/spec/dummy_app/vendor/assets/javascripts/.keep +0 -0
- data/spec/dummy_app/vendor/assets/stylesheets/.keep +0 -0
- data/the_role.gemspec +2 -1
- data/the_role.yml.teamocil.example +11 -0
- metadata +213 -16
- data/app/assets/javascripts/the_role.js.coffee +0 -31
- data/app/assets/stylesheets/the_role/bootstrap_sass.css.scss +0 -20
- data/app/assets/stylesheets/the_role.css.scss +0 -47
- data/app/controllers/the_role_controller.rb +0 -18
- data/app/models/concerns/role_model.rb +0 -125
- data/app/models/concerns/the_role_base.rb +0 -35
- data/app/models/concerns/the_role_user_model.rb +0 -54
@@ -0,0 +1,80 @@
|
|
1
|
+
RailsApp::Application.configure do
|
2
|
+
# Settings specified here will take precedence over those in config/application.rb.
|
3
|
+
|
4
|
+
# Code is not reloaded between requests.
|
5
|
+
config.cache_classes = true
|
6
|
+
|
7
|
+
# Eager load code on boot. This eager loads most of Rails and
|
8
|
+
# your application in memory, allowing both thread web servers
|
9
|
+
# and those relying on copy on write to perform better.
|
10
|
+
# Rake tasks automatically ignore this option for performance.
|
11
|
+
config.eager_load = true
|
12
|
+
|
13
|
+
# Full error reports are disabled and caching is turned on.
|
14
|
+
config.consider_all_requests_local = false
|
15
|
+
config.action_controller.perform_caching = true
|
16
|
+
|
17
|
+
# Enable Rack::Cache to put a simple HTTP cache in front of your application
|
18
|
+
# Add `rack-cache` to your Gemfile before enabling this.
|
19
|
+
# For large-scale production use, consider using a caching reverse proxy like nginx, varnish or squid.
|
20
|
+
# config.action_dispatch.rack_cache = true
|
21
|
+
|
22
|
+
# Disable Rails's static asset server (Apache or nginx will already do this).
|
23
|
+
config.serve_static_assets = true
|
24
|
+
|
25
|
+
# Compress JavaScripts and CSS.
|
26
|
+
config.assets.js_compressor = :uglifier
|
27
|
+
# config.assets.css_compressor = :sass
|
28
|
+
|
29
|
+
# Do not fallback to assets pipeline if a precompiled asset is missed.
|
30
|
+
config.assets.compile = false
|
31
|
+
|
32
|
+
# Generate digests for assets URLs.
|
33
|
+
config.assets.digest = true
|
34
|
+
|
35
|
+
# Version of your assets, change this if you want to expire all your assets.
|
36
|
+
config.assets.version = '1.0'
|
37
|
+
|
38
|
+
# Specifies the header that your server uses for sending files.
|
39
|
+
# config.action_dispatch.x_sendfile_header = "X-Sendfile" # for apache
|
40
|
+
# config.action_dispatch.x_sendfile_header = 'X-Accel-Redirect' # for nginx
|
41
|
+
|
42
|
+
# Force all access to the app over SSL, use Strict-Transport-Security, and use secure cookies.
|
43
|
+
# config.force_ssl = true
|
44
|
+
|
45
|
+
# Set to :debug to see everything in the log.
|
46
|
+
config.log_level = :info
|
47
|
+
|
48
|
+
# Prepend all log lines with the following tags.
|
49
|
+
# config.log_tags = [ :subdomain, :uuid ]
|
50
|
+
|
51
|
+
# Use a different logger for distributed setups.
|
52
|
+
# config.logger = ActiveSupport::TaggedLogging.new(SyslogLogger.new)
|
53
|
+
|
54
|
+
# Use a different cache store in production.
|
55
|
+
# config.cache_store = :mem_cache_store
|
56
|
+
|
57
|
+
# Enable serving of images, stylesheets, and JavaScripts from an asset server.
|
58
|
+
# config.action_controller.asset_host = "http://assets.example.com"
|
59
|
+
|
60
|
+
# Precompile additional assets.
|
61
|
+
# application.js, application.css, and all non-JS/CSS in app/assets folder are already added.
|
62
|
+
# config.assets.precompile += %w( search.js )
|
63
|
+
|
64
|
+
# Ignore bad email addresses and do not raise email delivery errors.
|
65
|
+
# Set this to true and configure the email server for immediate delivery to raise delivery errors.
|
66
|
+
# config.action_mailer.raise_delivery_errors = false
|
67
|
+
|
68
|
+
# Enable locale fallbacks for I18n (makes lookups for any locale fall back to
|
69
|
+
# the I18n.default_locale when a translation can not be found).
|
70
|
+
config.i18n.fallbacks = true
|
71
|
+
|
72
|
+
# Send deprecation notices to registered listeners.
|
73
|
+
config.active_support.deprecation = :notify
|
74
|
+
|
75
|
+
# Disable automatic flushing of the log to improve performance.
|
76
|
+
# config.autoflush_log = false
|
77
|
+
|
78
|
+
# Use default logging formatter so that PID and timestamp are not suppressed.
|
79
|
+
config.log_formatter = ::Logger::Formatter.new
|
80
|
+
end
|
@@ -0,0 +1,36 @@
|
|
1
|
+
RailsApp::Application.configure do
|
2
|
+
# Settings specified here will take precedence over those in config/application.rb.
|
3
|
+
|
4
|
+
# The test environment is used exclusively to run your application's
|
5
|
+
# test suite. You never need to work with it otherwise. Remember that
|
6
|
+
# your test database is "scratch space" for the test suite and is wiped
|
7
|
+
# and recreated between test runs. Don't rely on the data there!
|
8
|
+
config.cache_classes = true
|
9
|
+
|
10
|
+
# Do not eager load code on boot. This avoids loading your whole application
|
11
|
+
# just for the purpose of running a single test. If you are using a tool that
|
12
|
+
# preloads Rails for running tests, you may have to set it to true.
|
13
|
+
config.eager_load = false
|
14
|
+
|
15
|
+
# Configure static asset server for tests with Cache-Control for performance.
|
16
|
+
config.serve_static_assets = true
|
17
|
+
config.static_cache_control = "public, max-age=3600"
|
18
|
+
|
19
|
+
# Show full error reports and disable caching.
|
20
|
+
config.consider_all_requests_local = true
|
21
|
+
config.action_controller.perform_caching = false
|
22
|
+
|
23
|
+
# Raise exceptions instead of rendering exception templates.
|
24
|
+
config.action_dispatch.show_exceptions = false
|
25
|
+
|
26
|
+
# Disable request forgery protection in test environment.
|
27
|
+
config.action_controller.allow_forgery_protection = false
|
28
|
+
|
29
|
+
# Tell Action Mailer not to deliver emails to the real world.
|
30
|
+
# The :test delivery method accumulates sent emails in the
|
31
|
+
# ActionMailer::Base.deliveries array.
|
32
|
+
config.action_mailer.delivery_method = :test
|
33
|
+
|
34
|
+
# Print deprecation notices to the stderr.
|
35
|
+
config.active_support.deprecation = :stderr
|
36
|
+
end
|
@@ -0,0 +1,7 @@
|
|
1
|
+
# Be sure to restart your server when you modify this file.
|
2
|
+
|
3
|
+
# You can add backtrace silencers for libraries that you're using but don't wish to see in your backtraces.
|
4
|
+
# Rails.backtrace_cleaner.add_silencer { |line| line =~ /my_noisy_library/ }
|
5
|
+
|
6
|
+
# You can also remove all the silencers if you're trying to debug a problem that might stem from framework code.
|
7
|
+
# Rails.backtrace_cleaner.remove_silencers!
|
@@ -0,0 +1,227 @@
|
|
1
|
+
# Use this hook to configure devise mailer, warden hooks and so forth.
|
2
|
+
# Many of these configuration options can be set straight in your model.
|
3
|
+
Devise.setup do |config|
|
4
|
+
config.router_name = :main_app
|
5
|
+
|
6
|
+
config.secret_key = '828ff2a1001958fd6c0cea946e9807fe9bca809e4745fd5c9b2334d1190e16fe17ba281c6cdeecda4eeb9af9de6cb77b93bf9b0c7fcc5fa6e7f737e204e118e6'
|
7
|
+
|
8
|
+
# ==> Mailer Configuration
|
9
|
+
# Configure the e-mail address which will be shown in Devise::Mailer,
|
10
|
+
# note that it will be overwritten if you use your own mailer class with default "from" parameter.
|
11
|
+
config.mailer_sender = "please-change-me-at-config-initializers-devise@example.com"
|
12
|
+
|
13
|
+
# Configure the class responsible to send e-mails.
|
14
|
+
# config.mailer = "Devise::Mailer"
|
15
|
+
|
16
|
+
# Automatically apply schema changes in tableless databases
|
17
|
+
# config.apply_schema = false
|
18
|
+
|
19
|
+
# ==> ORM configuration
|
20
|
+
# Load and configure the ORM. Supports :active_record (default) and
|
21
|
+
# :mongoid (bson_ext recommended) by default. Other ORMs may be
|
22
|
+
# available as additional gems.
|
23
|
+
require 'devise/orm/active_record'
|
24
|
+
|
25
|
+
# ==> Configuration for any authentication mechanism
|
26
|
+
# Configure which keys are used when authenticating a user. The default is
|
27
|
+
# just :email. You can configure it to use [:username, :subdomain], so for
|
28
|
+
# authenticating a user, both parameters are required. Remember that those
|
29
|
+
# parameters are used only when authenticating and not when retrieving from
|
30
|
+
# session. If you need permissions, you should implement that in a before filter.
|
31
|
+
# You can also supply a hash where the value is a boolean determining whether
|
32
|
+
# or not authentication should be aborted when the value is not present.
|
33
|
+
# config.authentication_keys = [ :email ]
|
34
|
+
|
35
|
+
# Configure parameters from the request object used for authentication. Each entry
|
36
|
+
# given should be a request method and it will automatically be passed to the
|
37
|
+
# find_for_authentication method and considered in your model lookup. For instance,
|
38
|
+
# if you set :request_keys to [:subdomain], :subdomain will be used on authentication.
|
39
|
+
# The same considerations mentioned for authentication_keys also apply to request_keys.
|
40
|
+
# config.request_keys = []
|
41
|
+
|
42
|
+
# Configure which authentication keys should be case-insensitive.
|
43
|
+
# These keys will be downcased upon creating or modifying a user and when used
|
44
|
+
# to authenticate or find a user. Default is :email.
|
45
|
+
config.case_insensitive_keys = [ :email ]
|
46
|
+
|
47
|
+
# Configure which authentication keys should have whitespace stripped.
|
48
|
+
# These keys will have whitespace before and after removed upon creating or
|
49
|
+
# modifying a user and when used to authenticate or find a user. Default is :email.
|
50
|
+
config.strip_whitespace_keys = [ :email ]
|
51
|
+
|
52
|
+
# Tell if authentication through request.params is enabled. True by default.
|
53
|
+
# It can be set to an array that will enable params authentication only for the
|
54
|
+
# given strategies, for example, `config.params_authenticatable = [:database]` will
|
55
|
+
# enable it only for database (email + password) authentication.
|
56
|
+
# config.params_authenticatable = true
|
57
|
+
|
58
|
+
# Tell if authentication through HTTP Basic Auth is enabled. False by default.
|
59
|
+
# It can be set to an array that will enable http authentication only for the
|
60
|
+
# given strategies, for example, `config.http_authenticatable = [:token]` will
|
61
|
+
# enable it only for token authentication.
|
62
|
+
# config.http_authenticatable = false
|
63
|
+
|
64
|
+
# If http headers should be returned for AJAX requests. True by default.
|
65
|
+
# config.http_authenticatable_on_xhr = true
|
66
|
+
|
67
|
+
# The realm used in Http Basic Authentication. "Application" by default.
|
68
|
+
# config.http_authentication_realm = "Application"
|
69
|
+
|
70
|
+
# It will change confirmation, password recovery and other workflows
|
71
|
+
# to behave the same regardless if the e-mail provided was right or wrong.
|
72
|
+
# Does not affect registerable.
|
73
|
+
# config.paranoid = true
|
74
|
+
|
75
|
+
# By default Devise will store the user in session. You can skip storage for
|
76
|
+
# :http_auth and :token_auth by adding those symbols to the array below.
|
77
|
+
# Notice that if you are skipping storage for all authentication paths, you
|
78
|
+
# may want to disable generating routes to Devise's sessions controller by
|
79
|
+
# passing :skip => :sessions to `devise_for` in your config/routes.rb
|
80
|
+
config.skip_session_storage = [:http_auth]
|
81
|
+
|
82
|
+
# ==> Configuration for :database_authenticatable
|
83
|
+
# For bcrypt, this is the cost for hashing the password and defaults to 10. If
|
84
|
+
# using other encryptors, it sets how many times you want the password re-encrypted.
|
85
|
+
#
|
86
|
+
# Limiting the stretches to just one in testing will increase the performance of
|
87
|
+
# your test suite dramatically. However, it is STRONGLY RECOMMENDED to not use
|
88
|
+
# a value less than 10 in other environments.
|
89
|
+
config.stretches = Rails.env.test? ? 1 : 10
|
90
|
+
|
91
|
+
# Setup a pepper to generate the encrypted password.
|
92
|
+
# config.pepper = "bd420e8b4db2240dfc96eb3b958dcbbef5ffa78cd99e22f9215df3b91c2cd84cf116697fb430f3b9eea58e6f14248a390b0ee2af24aa9dc35d40b819cd34e2b9"
|
93
|
+
|
94
|
+
# ==> Configuration for :confirmable
|
95
|
+
# A period that the user is allowed to access the website even without
|
96
|
+
# confirming his account. For instance, if set to 2.days, the user will be
|
97
|
+
# able to access the website for two days without confirming his account,
|
98
|
+
# access will be blocked just in the third day. Default is 0.days, meaning
|
99
|
+
# the user cannot access the website without confirming his account.
|
100
|
+
# config.allow_unconfirmed_access_for = 2.days
|
101
|
+
|
102
|
+
# If true, requires any email changes to be confirmed (exctly the same way as
|
103
|
+
# initial account confirmation) to be applied. Requires additional unconfirmed_email
|
104
|
+
# db field (see migrations). Until confirmed new email is stored in
|
105
|
+
# unconfirmed email column, and copied to email column on successful confirmation.
|
106
|
+
config.reconfirmable = true
|
107
|
+
|
108
|
+
# Defines which key will be used when confirming an account
|
109
|
+
# config.confirmation_keys = [ :email ]
|
110
|
+
|
111
|
+
# ==> Configuration for :rememberable
|
112
|
+
# The time the user will be remembered without asking for credentials again.
|
113
|
+
# config.remember_for = 2.weeks
|
114
|
+
|
115
|
+
# If true, extends the user's remember period when remembered via cookie.
|
116
|
+
# config.extend_remember_period = false
|
117
|
+
|
118
|
+
# If true, uses the password salt as remember token. This should be turned
|
119
|
+
# to false if you are not using database authenticatable.
|
120
|
+
# config.use_salt_as_remember_token = true
|
121
|
+
|
122
|
+
# Options to be passed to the created cookie. For instance, you can set
|
123
|
+
# :secure => true in order to force SSL only cookies.
|
124
|
+
# config.cookie_options = {}
|
125
|
+
|
126
|
+
# ==> Configuration for :validatable
|
127
|
+
# Range for password length. Default is 6..128.
|
128
|
+
# config.password_length = 6..128
|
129
|
+
|
130
|
+
# Email regex used to validate email formats. It simply asserts that
|
131
|
+
# an one (and only one) @ exists in the given string. This is mainly
|
132
|
+
# to give user feedback and not to assert the e-mail validity.
|
133
|
+
# config.email_regexp = /\A[^@]+@[^@]+\z/
|
134
|
+
|
135
|
+
# ==> Configuration for :timeoutable
|
136
|
+
# The time you want to timeout the user session without activity. After this
|
137
|
+
# time the user will be asked for credentials again. Default is 30 minutes.
|
138
|
+
# config.timeout_in = 30.minutes
|
139
|
+
|
140
|
+
# ==> Configuration for :lockable
|
141
|
+
# Defines which strategy will be used to lock an account.
|
142
|
+
# :failed_attempts = Locks an account after a number of failed attempts to sign in.
|
143
|
+
# :none = No lock strategy. You should handle locking by yourself.
|
144
|
+
# config.lock_strategy = :failed_attempts
|
145
|
+
|
146
|
+
# Defines which key will be used when locking and unlocking an account
|
147
|
+
# config.unlock_keys = [ :email ]
|
148
|
+
|
149
|
+
# Defines which strategy will be used to unlock an account.
|
150
|
+
# :email = Sends an unlock link to the user email
|
151
|
+
# :time = Re-enables login after a certain amount of time (see :unlock_in below)
|
152
|
+
# :both = Enables both strategies
|
153
|
+
# :none = No unlock strategy. You should handle unlocking by yourself.
|
154
|
+
# config.unlock_strategy = :both
|
155
|
+
|
156
|
+
# Number of authentication tries before locking an account if lock_strategy
|
157
|
+
# is failed attempts.
|
158
|
+
# config.maximum_attempts = 20
|
159
|
+
|
160
|
+
# Time interval to unlock the account if :time is enabled as unlock_strategy.
|
161
|
+
# config.unlock_in = 1.hour
|
162
|
+
|
163
|
+
# ==> Configuration for :recoverable
|
164
|
+
#
|
165
|
+
# Defines which key will be used when recovering the password for an account
|
166
|
+
# config.reset_password_keys = [ :email ]
|
167
|
+
|
168
|
+
# Time interval you can reset your password with a reset password key.
|
169
|
+
# Don't put a too small interval or your users won't have the time to
|
170
|
+
# change their passwords.
|
171
|
+
config.reset_password_within = 6.hours
|
172
|
+
|
173
|
+
# ==> Configuration for :encryptable
|
174
|
+
# Allow you to use another encryption algorithm besides bcrypt (default). You can use
|
175
|
+
# :sha1, :sha512 or encryptors from others authentication tools as :clearance_sha1,
|
176
|
+
# :authlogic_sha512 (then you should set stretches above to 20 for default behavior)
|
177
|
+
# and :restful_authentication_sha1 (then you should set stretches to 10, and copy
|
178
|
+
# REST_AUTH_SITE_KEY to pepper)
|
179
|
+
# config.encryptor = :sha512
|
180
|
+
|
181
|
+
# ==> Configuration for :token_authenticatable
|
182
|
+
# Defines name of the authentication token params key
|
183
|
+
# config.token_authentication_key = :auth_token
|
184
|
+
|
185
|
+
# ==> Scopes configuration
|
186
|
+
# Turn scoped views on. Before rendering "sessions/new", it will first check for
|
187
|
+
# "users/sessions/new". It's turned off by default because it's slower if you
|
188
|
+
# are using only default views.
|
189
|
+
# config.scoped_views = false
|
190
|
+
|
191
|
+
# Configure the default scope given to Warden. By default it's the first
|
192
|
+
# devise role declared in your routes (usually :user).
|
193
|
+
# config.default_scope = :user
|
194
|
+
|
195
|
+
# Configure sign_out behavior.
|
196
|
+
# Sign_out action can be scoped (i.e. /users/sign_out affects only :user scope).
|
197
|
+
# The default is true, which means any logout action will sign out all active scopes.
|
198
|
+
# config.sign_out_all_scopes = true
|
199
|
+
|
200
|
+
# ==> Navigation configuration
|
201
|
+
# Lists the formats that should be treated as navigational. Formats like
|
202
|
+
# :html, should redirect to the sign in page when the user does not have
|
203
|
+
# access, but formats like :xml or :json, should return 401.
|
204
|
+
#
|
205
|
+
# If you have any extra navigational formats, like :iphone or :mobile, you
|
206
|
+
# should add them to the navigational formats lists.
|
207
|
+
#
|
208
|
+
# The "*/*" below is required to match Internet Explorer requests.
|
209
|
+
# config.navigational_formats = ["*/*", :html]
|
210
|
+
|
211
|
+
# The default HTTP method used to sign out a resource. Default is :delete.
|
212
|
+
config.sign_out_via = :delete
|
213
|
+
|
214
|
+
# ==> OmniAuth
|
215
|
+
# Add a new OmniAuth provider. Check the wiki for more information on setting
|
216
|
+
# up on your models and hooks.
|
217
|
+
# config.omniauth :github, 'APP_ID', 'APP_SECRET', :scope => 'user,public_repo'
|
218
|
+
|
219
|
+
# ==> Warden configuration
|
220
|
+
# If you want to use other strategies, that are not supported by Devise, or
|
221
|
+
# change the failure app, you can configure them inside the config.warden block.
|
222
|
+
#
|
223
|
+
# config.warden do |manager|
|
224
|
+
# manager.intercept_401 = false
|
225
|
+
# manager.default_strategies(:scope => :user).unshift :some_external_strategy
|
226
|
+
# end
|
227
|
+
end
|
@@ -0,0 +1,16 @@
|
|
1
|
+
# Be sure to restart your server when you modify this file.
|
2
|
+
|
3
|
+
# Add new inflection rules using the following format. Inflections
|
4
|
+
# are locale specific, and you may define rules for as many different
|
5
|
+
# locales as you wish. All of these examples are active by default:
|
6
|
+
# ActiveSupport::Inflector.inflections(:en) do |inflect|
|
7
|
+
# inflect.plural /^(ox)$/i, '\1en'
|
8
|
+
# inflect.singular /^(ox)en/i, '\1'
|
9
|
+
# inflect.irregular 'person', 'people'
|
10
|
+
# inflect.uncountable %w( fish sheep )
|
11
|
+
# end
|
12
|
+
|
13
|
+
# These inflection rules are supported but not enabled by default:
|
14
|
+
# ActiveSupport::Inflector.inflections(:en) do |inflect|
|
15
|
+
# inflect.acronym 'RESTful'
|
16
|
+
# end
|
@@ -0,0 +1,12 @@
|
|
1
|
+
# Be sure to restart your server when you modify this file.
|
2
|
+
|
3
|
+
# Your secret key is used for verifying the integrity of signed cookies.
|
4
|
+
# If you change this key, all old signed cookies will become invalid!
|
5
|
+
|
6
|
+
# Make sure the secret is at least 30 characters and all random,
|
7
|
+
# no regular words or you'll be exposed to dictionary attacks.
|
8
|
+
# You can use `rake secret` to generate a secure secret key.
|
9
|
+
|
10
|
+
# Make sure your secret_key_base is kept private
|
11
|
+
# if you're sharing your code publicly.
|
12
|
+
Rails.application.config.secret_key_base = '2c8a4e21c8caf3b6bac299ada85d1975c83931ab44c0b38c95b327b39da0d779a2f9c363ccf3af5786a0af34dcd13945c9e8be7c10be9e8dddbbf41c1a5b39c7'
|
@@ -0,0 +1,14 @@
|
|
1
|
+
# Be sure to restart your server when you modify this file.
|
2
|
+
|
3
|
+
# This file contains settings for ActionController::ParamsWrapper which
|
4
|
+
# is enabled by default.
|
5
|
+
|
6
|
+
# Enable parameter wrapping for JSON. You can disable this by setting :format to an empty array.
|
7
|
+
ActiveSupport.on_load(:action_controller) do
|
8
|
+
wrap_parameters format: [:json] if respond_to?(:wrap_parameters)
|
9
|
+
end
|
10
|
+
|
11
|
+
# To enable root element in JSON for ActiveRecord objects.
|
12
|
+
# ActiveSupport.on_load(:active_record) do
|
13
|
+
# self.include_root_in_json = true
|
14
|
+
# end
|
@@ -0,0 +1,57 @@
|
|
1
|
+
# Additional translations at https://github.com/plataformatec/devise/wiki/I18n
|
2
|
+
|
3
|
+
en:
|
4
|
+
errors:
|
5
|
+
messages:
|
6
|
+
expired: "has expired, please request a new one"
|
7
|
+
not_found: "not found"
|
8
|
+
already_confirmed: "was already confirmed, please try signing in"
|
9
|
+
not_locked: "was not locked"
|
10
|
+
not_saved:
|
11
|
+
one: "1 error prohibited this %{resource} from being saved:"
|
12
|
+
other: "%{count} errors prohibited this %{resource} from being saved:"
|
13
|
+
|
14
|
+
devise:
|
15
|
+
failure:
|
16
|
+
already_authenticated: 'You are already signed in.'
|
17
|
+
unauthenticated: 'You need to sign in or sign up before continuing.'
|
18
|
+
unconfirmed: 'You have to confirm your account before continuing.'
|
19
|
+
locked: 'Your account is locked.'
|
20
|
+
invalid: 'Invalid email or password.'
|
21
|
+
invalid_token: 'Invalid authentication token.'
|
22
|
+
timeout: 'Your session expired, please sign in again to continue.'
|
23
|
+
inactive: 'Your account was not activated yet.'
|
24
|
+
sessions:
|
25
|
+
signed_in: 'Signed in successfully.'
|
26
|
+
signed_out: 'Signed out successfully.'
|
27
|
+
passwords:
|
28
|
+
send_instructions: 'You will receive an email with instructions about how to reset your password in a few minutes.'
|
29
|
+
updated: 'Your password was changed successfully. You are now signed in.'
|
30
|
+
updated_not_active: 'Your password was changed successfully.'
|
31
|
+
send_paranoid_instructions: "If your e-mail exists on our database, you will receive a password recovery link on your e-mail"
|
32
|
+
confirmations:
|
33
|
+
send_instructions: 'You will receive an email with instructions about how to confirm your account in a few minutes.'
|
34
|
+
send_paranoid_instructions: 'If your e-mail exists on our database, you will receive an email with instructions about how to confirm your account in a few minutes.'
|
35
|
+
confirmed: 'Your account was successfully confirmed. You are now signed in.'
|
36
|
+
registrations:
|
37
|
+
signed_up: 'Welcome! You have signed up successfully.'
|
38
|
+
signed_up_but_unconfirmed: 'A message with a confirmation link has been sent to your email address. Please open the link to activate your account.'
|
39
|
+
signed_up_but_inactive: 'You have signed up successfully. However, we could not sign you in because your account is not yet activated.'
|
40
|
+
signed_up_but_locked: 'You have signed up successfully. However, we could not sign you in because your account is locked.'
|
41
|
+
updated: 'You updated your account successfully.'
|
42
|
+
update_needs_confirmation: "You updated your account successfully, but we need to verify your new email address. Please check your email and click on the confirm link to finalize confirming your new email address."
|
43
|
+
destroyed: 'Bye! Your account was successfully cancelled. We hope to see you again soon.'
|
44
|
+
unlocks:
|
45
|
+
send_instructions: 'You will receive an email with instructions about how to unlock your account in a few minutes.'
|
46
|
+
unlocked: 'Your account has been unlocked successfully. Please sign in to continue.'
|
47
|
+
send_paranoid_instructions: 'If your account exists, you will receive an email with instructions about how to unlock it in a few minutes.'
|
48
|
+
omniauth_callbacks:
|
49
|
+
success: 'Successfully authorized from %{kind} account.'
|
50
|
+
failure: 'Could not authorize you from %{kind} because "%{reason}".'
|
51
|
+
mailer:
|
52
|
+
confirmation_instructions:
|
53
|
+
subject: 'Confirmation instructions'
|
54
|
+
reset_password_instructions:
|
55
|
+
subject: 'Reset password instructions'
|
56
|
+
unlock_instructions:
|
57
|
+
subject: 'Unlock Instructions'
|
@@ -0,0 +1,20 @@
|
|
1
|
+
RailsApp::Application.routes.draw do
|
2
|
+
devise_for :users
|
3
|
+
|
4
|
+
root :to => 'welcome#index'
|
5
|
+
|
6
|
+
get 'welcome/index'
|
7
|
+
get 'welcome/profile'
|
8
|
+
get 'autologin' => 'welcome#autologin', :as => :autologin
|
9
|
+
|
10
|
+
put 'users/change_role' => "users#change_role", :as => :change_role
|
11
|
+
|
12
|
+
resources :users, :only => [:edit, :update]
|
13
|
+
|
14
|
+
resources :pages do
|
15
|
+
collection do
|
16
|
+
get :my
|
17
|
+
get :manage
|
18
|
+
end
|
19
|
+
end
|
20
|
+
end
|
@@ -0,0 +1,63 @@
|
|
1
|
+
class DeviseCreateUsers < ActiveRecord::Migration
|
2
|
+
def change
|
3
|
+
create_table(:users) do |t|
|
4
|
+
## Custom fields
|
5
|
+
t.string :name
|
6
|
+
t.string :company
|
7
|
+
t.string :address
|
8
|
+
|
9
|
+
# special field for Mass assignment test
|
10
|
+
t.string :some_protected_field, :default => "should_not_be_changed"
|
11
|
+
|
12
|
+
## Database authenticatable
|
13
|
+
t.string :email, :null => false, :default => ""
|
14
|
+
t.string :encrypted_password, :null => false, :default => ""
|
15
|
+
|
16
|
+
# Unsecure password
|
17
|
+
t.string :password, :null => false, :default => ""
|
18
|
+
|
19
|
+
## Recoverable
|
20
|
+
t.string :reset_password_token
|
21
|
+
t.datetime :reset_password_sent_at
|
22
|
+
|
23
|
+
# TheRole FIELD
|
24
|
+
t.integer :role_id
|
25
|
+
|
26
|
+
## Rememberable
|
27
|
+
t.datetime :remember_created_at
|
28
|
+
|
29
|
+
## Trackable
|
30
|
+
t.integer :sign_in_count, :default => 0
|
31
|
+
t.datetime :current_sign_in_at
|
32
|
+
t.datetime :last_sign_in_at
|
33
|
+
t.string :current_sign_in_ip
|
34
|
+
t.string :last_sign_in_ip
|
35
|
+
|
36
|
+
## Encryptable
|
37
|
+
# t.string :password_salt
|
38
|
+
|
39
|
+
## Confirmable
|
40
|
+
# t.string :confirmation_token
|
41
|
+
# t.datetime :confirmed_at
|
42
|
+
# t.datetime :confirmation_sent_at
|
43
|
+
# t.string :unconfirmed_email # Only if using reconfirmable
|
44
|
+
|
45
|
+
## Lockable
|
46
|
+
# t.integer :failed_attempts, :default => 0 # Only if lock strategy is :failed_attempts
|
47
|
+
# t.string :unlock_token # Only if unlock strategy is :email or :both
|
48
|
+
# t.datetime :locked_at
|
49
|
+
|
50
|
+
## Token authenticatable
|
51
|
+
# t.string :authentication_token
|
52
|
+
|
53
|
+
|
54
|
+
t.timestamps
|
55
|
+
end
|
56
|
+
|
57
|
+
add_index :users, :email, :unique => true
|
58
|
+
add_index :users, :reset_password_token, :unique => true
|
59
|
+
# add_index :users, :confirmation_token, :unique => true
|
60
|
+
# add_index :users, :unlock_token, :unique => true
|
61
|
+
# add_index :users, :authentication_token, :unique => true
|
62
|
+
end
|
63
|
+
end
|
@@ -0,0 +1,18 @@
|
|
1
|
+
class CreateRoles < ActiveRecord::Migration
|
2
|
+
def self.up
|
3
|
+
create_table :roles do |t|
|
4
|
+
|
5
|
+
t.string :name
|
6
|
+
t.string :title
|
7
|
+
t.text :description
|
8
|
+
|
9
|
+
t.text :the_role
|
10
|
+
|
11
|
+
t.timestamps
|
12
|
+
end
|
13
|
+
end
|
14
|
+
|
15
|
+
def self.down
|
16
|
+
drop_table :roles
|
17
|
+
end
|
18
|
+
end
|