protected 1.0.0
Sign up to get free protection for your applications and to get access to all the features.
- data/MIT-LICENSE +20 -0
- data/README.rdoc +151 -0
- data/Rakefile +32 -0
- data/app/assets/images/protected/Sorting icons.psd +0 -0
- data/app/assets/images/protected/back_disabled.png +0 -0
- data/app/assets/images/protected/back_enabled.png +0 -0
- data/app/assets/images/protected/back_enabled_hover.png +0 -0
- data/app/assets/images/protected/favicon.ico +0 -0
- data/app/assets/images/protected/forward_disabled.png +0 -0
- data/app/assets/images/protected/forward_enabled.png +0 -0
- data/app/assets/images/protected/forward_enabled_hover.png +0 -0
- data/app/assets/images/protected/glyphicons-halflings-white.png +0 -0
- data/app/assets/images/protected/glyphicons-halflings.png +0 -0
- data/app/assets/images/protected/sort_asc.png +0 -0
- data/app/assets/images/protected/sort_asc_disabled.png +0 -0
- data/app/assets/images/protected/sort_both.png +0 -0
- data/app/assets/images/protected/sort_desc.png +0 -0
- data/app/assets/images/protected/sort_desc_disabled.png +0 -0
- data/app/assets/javascripts/protected/application.js +164 -0
- data/app/assets/javascripts/protected/bootstrap.min.js +6 -0
- data/app/assets/javascripts/protected/jquery.dataTables.min.js +154 -0
- data/app/assets/stylesheets/protected/application.css +51 -0
- data/app/assets/stylesheets/protected/bootstrap-responsive.min.css +12 -0
- data/app/assets/stylesheets/protected/bootstrap.min.css +689 -0
- data/app/controllers/protected/admin/protected_controller.rb +14 -0
- data/app/controllers/protected/admin/users_controller.rb +70 -0
- data/app/controllers/protected/application_controller.rb +18 -0
- data/app/controllers/protected/passwords_controller.rb +39 -0
- data/app/controllers/protected/sessions_controller.rb +44 -0
- data/app/controllers/protected/users_controller.rb +12 -0
- data/app/helpers/protected/application_helper.rb +4 -0
- data/app/helpers/protected/passwords_helper.rb +21 -0
- data/app/mailers/user_mailer.rb +9 -0
- data/app/models/protected.rb +5 -0
- data/app/models/protected/old_password.rb +18 -0
- data/app/models/protected/user.rb +165 -0
- data/app/views/layouts/protected/application.html.haml +38 -0
- data/app/views/protected/admin/users/_form.html.haml +27 -0
- data/app/views/protected/admin/users/_password_fields.html.haml +9 -0
- data/app/views/protected/admin/users/_role_fields.html.haml +10 -0
- data/app/views/protected/admin/users/confirm_delete.html.haml +9 -0
- data/app/views/protected/admin/users/edit.html.haml +9 -0
- data/app/views/protected/admin/users/index.html.haml +27 -0
- data/app/views/protected/admin/users/new.html.haml +9 -0
- data/app/views/protected/admin/users/show.html.haml +0 -0
- data/app/views/protected/passwords/edit.html.haml +28 -0
- data/app/views/protected/passwords/forgot_password.html.haml +20 -0
- data/app/views/protected/passwords/new.html.haml +22 -0
- data/app/views/protected/sessions/first_login.html.haml +25 -0
- data/app/views/protected/sessions/new.html.haml +22 -0
- data/app/views/protected/sessions/not_authorized.html.haml +9 -0
- data/app/views/protected/users/_form.html.haml +19 -0
- data/app/views/protected/users/edit.html.haml +19 -0
- data/app/views/user_mailer/welcome_existing_user.haml +5 -0
- data/app/views/user_mailer/welcome_login_instructions.html.haml +6 -0
- data/app/views/user_mailer/welcome_password_instructions.haml +7 -0
- data/config/initializers/devise.rb +220 -0
- data/config/locales/devise.en.yml +62 -0
- data/config/routes.rb +34 -0
- data/db/migrate/20120418194256_devise_create_add_users.rb +60 -0
- data/lib/generators/protected/USAGE +5 -0
- data/lib/generators/protected/install/install_generator.rb +26 -0
- data/lib/generators/protected/templates/README +32 -0
- data/lib/generators/protected/templates/devise.rb +233 -0
- data/lib/generators/protected/views/views_generator.rb +40 -0
- data/lib/protected.rb +4 -0
- data/lib/protected/devise_recoverable_extensions.rb +19 -0
- data/lib/protected/engine.rb +10 -0
- data/lib/protected/password_utils.rb +46 -0
- data/lib/protected/version.rb +3 -0
- data/lib/tasks/protected_tasks.rake +44 -0
- metadata +414 -0
@@ -0,0 +1,62 @@
|
|
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 login 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
|
+
user:
|
25
|
+
password_expired: "Your password has expired"
|
26
|
+
locked: 'Your account is locked.'
|
27
|
+
invalid: 'Invalid login or password.'
|
28
|
+
locked: 'Your account is locked.'
|
29
|
+
login_exists: 'Login already exists'
|
30
|
+
first_and_last_name_exists: 'User with same First and Last Name already exists.'
|
31
|
+
sessions:
|
32
|
+
signed_in: 'Signed in successfully.'
|
33
|
+
signed_out: 'Signed out successfully.'
|
34
|
+
passwords:
|
35
|
+
send_instructions: 'You will receive an email with instructions about how to reset your password in a few minutes.'
|
36
|
+
updated: 'Your password was changed successfully. You are now signed in.'
|
37
|
+
updated_not_active: 'Your password was changed successfully.'
|
38
|
+
password_strength: "is not strong enough"
|
39
|
+
too_short: "is too short"
|
40
|
+
send_paranoid_instructions: "If your e-mail exists on our database, you will receive a password recovery link on your e-mail"
|
41
|
+
confirmations:
|
42
|
+
send_instructions: 'You will receive an email with instructions about how to confirm your account in a few minutes.'
|
43
|
+
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.'
|
44
|
+
confirmed: 'Your account was successfully confirmed. You are now signed in.'
|
45
|
+
registrations:
|
46
|
+
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.'
|
47
|
+
signed_up_but_inactive: 'You have signed up successfully. However, we could not sign you in because your account is not yet activated.'
|
48
|
+
signed_up_but_locked: 'You have signed up successfully. However, we could not sign you in because your account is locked.'
|
49
|
+
unlocks:
|
50
|
+
send_instructions: 'You will receive an email with instructions about how to unlock your account in a few minutes.'
|
51
|
+
unlocked: 'Your account was successfully unlocked. You are now signed in.'
|
52
|
+
send_paranoid_instructions: 'If your account exists, you will receive an email with instructions about how to unlock it in a few minutes.'
|
53
|
+
omniauth_callbacks:
|
54
|
+
success: 'Successfully authorized from %{kind} account.'
|
55
|
+
failure: 'Could not authorize you from %{kind} because "%{reason}".'
|
56
|
+
mailer:
|
57
|
+
confirmation_instructions:
|
58
|
+
subject: 'Confirmation instructions'
|
59
|
+
reset_password_instructions:
|
60
|
+
subject: 'Reset password instructions'
|
61
|
+
unlock_instructions:
|
62
|
+
subject: 'Unlock Instructions'
|
data/config/routes.rb
ADDED
@@ -0,0 +1,34 @@
|
|
1
|
+
Protected::Engine.routes.draw do
|
2
|
+
devise_for :users, {
|
3
|
+
:skip => :all,
|
4
|
+
:class_name => 'Protected::User',
|
5
|
+
:controllers => { :sessions => 'protected/sessions',
|
6
|
+
:passwords => "protected/passwords" },
|
7
|
+
:module => :devise
|
8
|
+
}
|
9
|
+
|
10
|
+
devise_scope :user do
|
11
|
+
get "/users/sign_in", :to => "sessions#new", :as => "new_user_session"
|
12
|
+
post "sessions", :to => "sessions#create", :as => "user_session"
|
13
|
+
get "/users/sign_out", :to => "sessions#destroy", :as => "destroy_user_session"
|
14
|
+
get 'first_login', :to => 'sessions#first_login', :as => 'first_login'
|
15
|
+
put 'update_first_login', :to => 'sessions#update_first_login', :as => 'update_first_login'
|
16
|
+
put "/users/password", :to => "passwords#update", :as => "update_password"
|
17
|
+
post "/users/password", :to => "passwords#create", :as => "create_password"
|
18
|
+
get "/users/password/new", :to => "passwords#new", :as => "new_user_password"
|
19
|
+
get "/users/password/edit", :to => "passwords#edit", :as => "edit_user_password"
|
20
|
+
match 'not_authorized', :to => 'sessions#not_authorized'
|
21
|
+
end
|
22
|
+
|
23
|
+
resources :users, :only => [:edit, :update]
|
24
|
+
namespace :admin do
|
25
|
+
resources :users do
|
26
|
+
member do
|
27
|
+
get :unlock
|
28
|
+
get :confirm_delete
|
29
|
+
end
|
30
|
+
end
|
31
|
+
end
|
32
|
+
match '/admin/', :to => 'admin/users#index', :via => [:get, :post]
|
33
|
+
root :to => 'sessions#new'
|
34
|
+
end
|
@@ -0,0 +1,60 @@
|
|
1
|
+
class DeviseCreateAddUsers < ActiveRecord::Migration
|
2
|
+
def change
|
3
|
+
create_table "protected_users", :force => true do |t|
|
4
|
+
t.string "first_name"
|
5
|
+
t.string "last_name"
|
6
|
+
t.string "company"
|
7
|
+
t.string "password_salt", :default => "", :null => false
|
8
|
+
t.string "remember_token"
|
9
|
+
t.boolean "first_login", :default => true
|
10
|
+
t.boolean "is_admin"
|
11
|
+
t.datetime "created_at", :null => false
|
12
|
+
t.datetime "updated_at", :null => false
|
13
|
+
t.string "email", :default => "", :null => false
|
14
|
+
t.string "encrypted_password", :limit => 128, :default => "", :null => false
|
15
|
+
t.string "reset_password_token"
|
16
|
+
t.datetime "reset_password_sent_at"
|
17
|
+
t.datetime "remember_created_at"
|
18
|
+
t.integer "sign_in_count", :default => 0
|
19
|
+
t.datetime "current_sign_in_at"
|
20
|
+
t.datetime "last_sign_in_at"
|
21
|
+
t.string "current_sign_in_ip"
|
22
|
+
t.string "last_sign_in_ip"
|
23
|
+
t.integer "failed_attempts", :default => 0
|
24
|
+
t.string "unlock_token"
|
25
|
+
t.datetime "locked_at"
|
26
|
+
t.string "login"
|
27
|
+
end
|
28
|
+
|
29
|
+
add_index "protected_users", ["email"], :name => "index_users_on_email", :unique => true
|
30
|
+
add_index "protected_users", ["company"], :name => "index_users_on_company"
|
31
|
+
add_index "protected_users", ["first_name","last_name"], :name => "index_users_on_first_and_last_name"
|
32
|
+
add_index "protected_users", ["login"], :name => "index_users_on_login"
|
33
|
+
add_index "protected_users", ["reset_password_token"], :name => "index_users_on_reset_password_token", :unique => true
|
34
|
+
add_index "protected_users", ["unlock_token"], :name => "index_users_on_unlock_token", :unique => true
|
35
|
+
|
36
|
+
create_table "protected_old_passwords", :force => true do |t|
|
37
|
+
t.string "encrypted_password", :limit => 128, :null => false
|
38
|
+
t.string "password_salt"
|
39
|
+
t.integer "password_archivable_id", :null => false
|
40
|
+
t.string "password_archivable_type", :null => false
|
41
|
+
t.datetime "created_at"
|
42
|
+
end
|
43
|
+
|
44
|
+
add_index "protected_old_passwords", ["password_archivable_type", "password_archivable_id"], :name => "index_password_archivable"
|
45
|
+
|
46
|
+
create_table "audit_records", :force => true do |t|
|
47
|
+
t.integer "user_id"
|
48
|
+
t.string "action"
|
49
|
+
t.text "modifications"
|
50
|
+
t.string "remote_address"
|
51
|
+
t.string "auditable_type"
|
52
|
+
t.integer "auditable_id"
|
53
|
+
t.datetime "created_at", :null => false
|
54
|
+
t.datetime "updated_at", :null => false
|
55
|
+
end
|
56
|
+
|
57
|
+
add_index "audit_records", ["auditable_id", "auditable_type"], :name => "index_audit_records_on_auditable_id_and_auditable_type"
|
58
|
+
add_index "audit_records", ["user_id"], :name => "index_audit_records_on_user_id"
|
59
|
+
end
|
60
|
+
end
|
@@ -0,0 +1,26 @@
|
|
1
|
+
module Protected
|
2
|
+
module Generators
|
3
|
+
class InstallGenerator < ::Rails::Generators::Base
|
4
|
+
source_root File.dirname(__FILE__) + "/../templates"
|
5
|
+
|
6
|
+
desc "Creates a Devise initializer and copy locale files to your application."
|
7
|
+
|
8
|
+
def copy_initializer
|
9
|
+
template "devise.rb", "config/initializers/devise.rb"
|
10
|
+
end
|
11
|
+
|
12
|
+
def add_protected_routes
|
13
|
+
devise_route = <<EOF
|
14
|
+
|
15
|
+
# Ensure you place your root path above this engine.
|
16
|
+
mount Protected::Engine => "/"
|
17
|
+
EOF
|
18
|
+
route devise_route
|
19
|
+
end
|
20
|
+
|
21
|
+
def show_readme
|
22
|
+
readme "README" if behavior == :invoke
|
23
|
+
end
|
24
|
+
end
|
25
|
+
end
|
26
|
+
end
|
@@ -0,0 +1,32 @@
|
|
1
|
+
===============================================================================
|
2
|
+
|
3
|
+
Some setup you must do manually:
|
4
|
+
|
5
|
+
|
6
|
+
1. Setup default url options for your specific environment. Here is an
|
7
|
+
example of development environment:
|
8
|
+
|
9
|
+
config.action_mailer.default_url_options = { :host => 'localhost:3000' }
|
10
|
+
|
11
|
+
This is a required Rails configuration. In production it must be the
|
12
|
+
actual host of your application
|
13
|
+
|
14
|
+
2. Ensure you have defined root_url to *something* in your config/routes.rb.
|
15
|
+
For example:
|
16
|
+
|
17
|
+
root :to => "home#index"
|
18
|
+
|
19
|
+
3. Ensure you have flash messages in app/views/layouts/application.html.erb.
|
20
|
+
For example:
|
21
|
+
|
22
|
+
<p class="notice"><%= notice %></p>
|
23
|
+
<p class="alert"><%= alert %></p>
|
24
|
+
|
25
|
+
4. If you are deploying Rails 3.1 on Heroku, you may want to set:
|
26
|
+
|
27
|
+
config.assets.initialize_on_precompile = false
|
28
|
+
|
29
|
+
On config/application.rb forcing your application to not access the DB
|
30
|
+
or load models when precompiling your assets.
|
31
|
+
|
32
|
+
===============================================================================
|
@@ -0,0 +1,233 @@
|
|
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
|
+
# ==> Mailer Configuration
|
5
|
+
# Configure the e-mail address which will be shown in Devise::Mailer,
|
6
|
+
# note that it will be overwritten if you use your own mailer class with default "from" parameter.
|
7
|
+
config.mailer_sender = "please-change-me-at-config-initializers-devise@example.com"
|
8
|
+
|
9
|
+
# Configure the class responsible to send e-mails.
|
10
|
+
# config.mailer = "Devise::Mailer"
|
11
|
+
|
12
|
+
# Automatically apply schema changes in tableless databases
|
13
|
+
config.apply_schema = false
|
14
|
+
|
15
|
+
# ==> ORM configuration
|
16
|
+
# Load and configure the ORM. Supports :active_record (default) and
|
17
|
+
# :mongoid (bson_ext recommended) by default. Other ORMs may be
|
18
|
+
# available as additional gems.
|
19
|
+
require 'devise/orm/active_record'
|
20
|
+
|
21
|
+
# ==> Configuration for any authentication mechanism
|
22
|
+
# Configure which keys are used when authenticating a user. The default is
|
23
|
+
# just :email. You can configure it to use [:username, :subdomain], so for
|
24
|
+
# authenticating a user, both parameters are required. Remember that those
|
25
|
+
# parameters are used only when authenticating and not when retrieving from
|
26
|
+
# session. If you need permissions, you should implement that in a before filter.
|
27
|
+
# You can also supply a hash where the value is a boolean determining whether
|
28
|
+
# or not authentication should be aborted when the value is not present.
|
29
|
+
config.authentication_keys = [ :login ]
|
30
|
+
|
31
|
+
# Configure parameters from the request object used for authentication. Each entry
|
32
|
+
# given should be a request method and it will automatically be passed to the
|
33
|
+
# find_for_authentication method and considered in your model lookup. For instance,
|
34
|
+
# if you set :request_keys to [:subdomain], :subdomain will be used on authentication.
|
35
|
+
# The same considerations mentioned for authentication_keys also apply to request_keys.
|
36
|
+
# config.request_keys = []
|
37
|
+
|
38
|
+
# Configure which authentication keys should be case-insensitive.
|
39
|
+
# These keys will be downcased upon creating or modifying a user and when used
|
40
|
+
# to authenticate or find a user. Default is :email.
|
41
|
+
config.case_insensitive_keys = [ :email, :login ]
|
42
|
+
|
43
|
+
# Configure which authentication keys should have whitespace stripped.
|
44
|
+
# These keys will have whitespace before and after removed upon creating or
|
45
|
+
# modifying a user and when used to authenticate or find a user. Default is :email.
|
46
|
+
config.strip_whitespace_keys = [ :email, :login ]
|
47
|
+
|
48
|
+
# Tell if authentication through request.params is enabled. True by default.
|
49
|
+
# It can be set to an array that will enable params authentication only for the
|
50
|
+
# given strategies, for example, `config.params_authenticatable = [:database]` will
|
51
|
+
# enable it only for database (email + password) authentication.
|
52
|
+
# config.params_authenticatable = true
|
53
|
+
|
54
|
+
# Tell if authentication through HTTP Basic Auth is enabled. False by default.
|
55
|
+
# It can be set to an array that will enable http authentication only for the
|
56
|
+
# given strategies, for example, `config.http_authenticatable = [:token]` will
|
57
|
+
# enable it only for token authentication.
|
58
|
+
# config.http_authenticatable = false
|
59
|
+
|
60
|
+
# If http headers should be returned for AJAX requests. True by default.
|
61
|
+
# config.http_authenticatable_on_xhr = true
|
62
|
+
|
63
|
+
# The realm used in Http Basic Authentication. "Application" by default.
|
64
|
+
# config.http_authentication_realm = "Application"
|
65
|
+
|
66
|
+
# It will change confirmation, password recovery and other workflows
|
67
|
+
# to behave the same regardless if the e-mail provided was right or wrong.
|
68
|
+
# Does not affect registerable.
|
69
|
+
# config.paranoid = true
|
70
|
+
|
71
|
+
# By default Devise will store the user in session. You can skip storage for
|
72
|
+
# :http_auth and :token_auth by adding those symbols to the array below.
|
73
|
+
# Notice that if you are skipping storage for all authentication paths, you
|
74
|
+
# may want to disable generating routes to Devise's sessions controller by
|
75
|
+
# passing :skip => :sessions to `devise_for` in your config/routes.rb
|
76
|
+
config.skip_session_storage = [:http_auth]
|
77
|
+
|
78
|
+
# ==> Configuration for :database_authenticatable
|
79
|
+
# For bcrypt, this is the cost for hashing the password and defaults to 10. If
|
80
|
+
# using other encryptors, it sets how many times you want the password re-encrypted.
|
81
|
+
#
|
82
|
+
# Limiting the stretches to just one in testing will increase the performance of
|
83
|
+
# your test suite dramatically. However, it is STRONGLY RECOMMENDED to not use
|
84
|
+
# a value less than 10 in other environments.
|
85
|
+
config.stretches = Rails.env.test? ? 1 : 10
|
86
|
+
|
87
|
+
# Setup a pepper to generate the encrypted password.
|
88
|
+
# config.pepper = <%= SecureRandom.hex(64).inspect %>
|
89
|
+
|
90
|
+
# ==> Configuration for :confirmable
|
91
|
+
# A period that the user is allowed to access the website even without
|
92
|
+
# confirming his account. For instance, if set to 2.days, the user will be
|
93
|
+
# able to access the website for two days without confirming his account,
|
94
|
+
# access will be blocked just in the third day. Default is 0.days, meaning
|
95
|
+
# the user cannot access the website without confirming his account.
|
96
|
+
# config.allow_unconfirmed_access_for = 2.days
|
97
|
+
|
98
|
+
# If true, requires any email changes to be confirmed (exctly the same way as
|
99
|
+
# initial account confirmation) to be applied. Requires additional unconfirmed_email
|
100
|
+
# db field (see migrations). Until confirmed new email is stored in
|
101
|
+
# unconfirmed email column, and copied to email column on successful confirmation.
|
102
|
+
config.reconfirmable = true
|
103
|
+
|
104
|
+
# Defines which key will be used when confirming an account
|
105
|
+
# config.confirmation_keys = [ :email ]
|
106
|
+
|
107
|
+
# ==> Configuration for :rememberable
|
108
|
+
# The time the user will be remembered without asking for credentials again.
|
109
|
+
# config.remember_for = 2.weeks
|
110
|
+
|
111
|
+
# If true, extends the user's remember period when remembered via cookie.
|
112
|
+
# config.extend_remember_period = false
|
113
|
+
|
114
|
+
# If true, uses the password salt as remember token. This should be turned
|
115
|
+
# to false if you are not using database authenticatable.
|
116
|
+
config.use_salt_as_remember_token = true
|
117
|
+
|
118
|
+
# Options to be passed to the created cookie. For instance, you can set
|
119
|
+
# :secure => true in order to force SSL only cookies.
|
120
|
+
# config.cookie_options = {}
|
121
|
+
|
122
|
+
# ==> Configuration for :validatable
|
123
|
+
# Range for password length. Default is 6..128.
|
124
|
+
config.password_length = 8..128
|
125
|
+
|
126
|
+
# Email regex used to validate email formats. It simply asserts that
|
127
|
+
# an one (and only one) @ exists in the given string. This is mainly
|
128
|
+
# to give user feedback and not to assert the e-mail validity.
|
129
|
+
# config.email_regexp = /\A[^@]+@[^@]+\z/
|
130
|
+
|
131
|
+
# ==> Configuration for :timeoutable
|
132
|
+
# The time you want to timeout the user session without activity. After this
|
133
|
+
# time the user will be asked for credentials again. Default is 30 minutes.
|
134
|
+
# config.timeout_in = 30.minutes
|
135
|
+
|
136
|
+
# ==> Configuration for :lockable
|
137
|
+
# Defines which strategy will be used to lock an account.
|
138
|
+
# :failed_attempts = Locks an account after a number of failed attempts to sign in.
|
139
|
+
# :none = No lock strategy. You should handle locking by yourself.
|
140
|
+
config.lock_strategy = :failed_attempts
|
141
|
+
|
142
|
+
# Defines which key will be used when locking and unlocking an account
|
143
|
+
# config.unlock_keys = [ :email ]
|
144
|
+
|
145
|
+
# Defines which strategy will be used to unlock an account.
|
146
|
+
# :email = Sends an unlock link to the user email
|
147
|
+
# :time = Re-enables login after a certain amount of time (see :unlock_in below)
|
148
|
+
# :both = Enables both strategies
|
149
|
+
# :none = No unlock strategy. You should handle unlocking by yourself.
|
150
|
+
# config.unlock_strategy = :both
|
151
|
+
|
152
|
+
# Number of authentication tries before locking an account if lock_strategy
|
153
|
+
# is failed attempts.
|
154
|
+
# config.maximum_attempts = 20
|
155
|
+
|
156
|
+
# Time interval to unlock the account if :time is enabled as unlock_strategy.
|
157
|
+
# config.unlock_in = 1.hour
|
158
|
+
|
159
|
+
# ==> Configuration for :recoverable
|
160
|
+
#
|
161
|
+
# Defines which key will be used when recovering the password for an account
|
162
|
+
# config.reset_password_keys = [ :email ]
|
163
|
+
|
164
|
+
# Time interval you can reset your password with a reset password key.
|
165
|
+
# Don't put a too small interval or your users won't have the time to
|
166
|
+
# change their passwords.
|
167
|
+
config.reset_password_within = 2.hours
|
168
|
+
|
169
|
+
# ==> Configuration for :encryptable
|
170
|
+
# Allow you to use another encryption algorithm besides bcrypt (default). You can use
|
171
|
+
# :sha1, :sha512 or encryptors from others authentication tools as :clearance_sha1,
|
172
|
+
# :authlogic_sha512 (then you should set stretches above to 20 for default behavior)
|
173
|
+
# and :restful_authentication_sha1 (then you should set stretches to 10, and copy
|
174
|
+
# REST_AUTH_SITE_KEY to pepper)
|
175
|
+
# config.encryptor = :sha512
|
176
|
+
config.encryptor = :bcrypt
|
177
|
+
# config.password_archiving_count = 5
|
178
|
+
# config.deny_old_passwords = true
|
179
|
+
|
180
|
+
# ==> Configuration for :token_authenticatable
|
181
|
+
# Defines name of the authentication token params key
|
182
|
+
# config.token_authentication_key = :auth_token
|
183
|
+
|
184
|
+
# ==> Scopes configuration
|
185
|
+
# Turn scoped views on. Before rendering "sessions/new", it will first check for
|
186
|
+
# "users/sessions/new". It's turned off by default because it's slower if you
|
187
|
+
# are using only default views.
|
188
|
+
# config.scoped_views = false
|
189
|
+
|
190
|
+
# Configure the default scope given to Warden. By default it's the first
|
191
|
+
# devise role declared in your routes (usually :user).
|
192
|
+
# config.default_scope = :user
|
193
|
+
|
194
|
+
# Configure sign_out behavior.
|
195
|
+
# Sign_out action can be scoped (i.e. /users/sign_out affects only :user scope).
|
196
|
+
# The default is true, which means any logout action will sign out all active scopes.
|
197
|
+
# config.sign_out_all_scopes = true
|
198
|
+
|
199
|
+
# ==> Navigation configuration
|
200
|
+
# Lists the formats that should be treated as navigational. Formats like
|
201
|
+
# :html, should redirect to the sign in page when the user does not have
|
202
|
+
# access, but formats like :xml or :json, should return 401.
|
203
|
+
#
|
204
|
+
# If you have any extra navigational formats, like :iphone or :mobile, you
|
205
|
+
# should add them to the navigational formats lists.
|
206
|
+
#
|
207
|
+
# The "*/*" below is required to match Internet Explorer requests.
|
208
|
+
# config.navigational_formats = ["*/*", :html]
|
209
|
+
|
210
|
+
# The default HTTP method used to sign out a resource. Default is :delete.
|
211
|
+
config.sign_out_via = :delete
|
212
|
+
|
213
|
+
# ==> OmniAuth
|
214
|
+
# Add a new OmniAuth provider. Check the wiki for more information on setting
|
215
|
+
# up on your models and hooks.
|
216
|
+
# config.omniauth :github, 'APP_ID', 'APP_SECRET', :scope => 'user,public_repo'
|
217
|
+
|
218
|
+
# ==> Warden configuration
|
219
|
+
# If you want to use other strategies, that are not supported by Devise, or
|
220
|
+
# change the failure app, you can configure them inside the config.warden block.
|
221
|
+
#
|
222
|
+
# config.warden do |manager|
|
223
|
+
# manager.intercept_401 = false
|
224
|
+
# manager.default_strategies(:scope => :user).unshift :some_external_strategy
|
225
|
+
# end
|
226
|
+
|
227
|
+
config.warden do |manager|
|
228
|
+
manager.intercept_401 = false
|
229
|
+
manager.default_strategies(:scope => :user).unshift :database_authenticatable
|
230
|
+
end
|
231
|
+
config.router_name = :protected
|
232
|
+
config.parent_controller = 'ActionController::Base'
|
233
|
+
end
|