Skip to content

Commit b653945

Browse files
author
Tony Guntharp
committed
Merge pull request #185 from gabceb/kandan-184
Fixes Devise 2.0 migrations and update devise settings
2 parents 16d0108 + fd728f8 commit b653945

File tree

3 files changed

+86
-34
lines changed

3 files changed

+86
-34
lines changed

config/initializers/devise.rb

+46-19
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
# ==> Mailer Configuration
55
# Configure the e-mail address which will be shown in Devise::Mailer,
66
# 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"
7+
config.mailer_sender = "no-reply@kandan.com"
88

99
# Configure the class responsible to send e-mails.
1010
# config.mailer = "Devise::Mailer"
@@ -35,17 +35,23 @@
3535
# Configure which authentication keys should be case-insensitive.
3636
# These keys will be downcased upon creating or modifying a user and when used
3737
# to authenticate or find a user. Default is :email.
38-
config.case_insensitive_keys = [ :username ]
38+
config.case_insensitive_keys = [ :email, :username ]
3939

4040
# Configure which authentication keys should have whitespace stripped.
4141
# These keys will have whitespace before and after removed upon creating or
4242
# modifying a user and when used to authenticate or find a user. Default is :email.
43-
config.strip_whitespace_keys = [ :username ]
43+
config.strip_whitespace_keys = [ :email, :username ]
4444

4545
# Tell if authentication through request.params is enabled. True by default.
46+
# It can be set to an array that will enable params authentication only for the
47+
# given strategies, for example, `config.params_authenticatable = [:database]` will
48+
# enable it only for database (email + password) authentication.
4649
# config.params_authenticatable = true
4750

4851
# Tell if authentication through HTTP Basic Auth is enabled. False by default.
52+
# It can be set to an array that will enable http authentication only for the
53+
# given strategies, for example, `config.http_authenticatable = [:token]` will
54+
# enable it only for token authentication.
4955
# config.http_authenticatable = false
5056

5157
# If http headers should be returned for AJAX requests. True by default.
@@ -59,6 +65,13 @@
5965
# Does not affect registerable.
6066
# config.paranoid = true
6167

68+
# By default Devise will store the user in session. You can skip storage for
69+
# :http_auth and :token_auth by adding those symbols to the array below.
70+
# Notice that if you are skipping storage for all authentication paths, you
71+
# may want to disable generating routes to Devise's sessions controller by
72+
# passing :skip => :sessions to `devise_for` in your config/routes.rb
73+
config.skip_session_storage = [:http_auth]
74+
6275
# ==> Configuration for :database_authenticatable
6376
# For bcrypt, this is the cost for hashing the password and defaults to 10. If
6477
# using other encryptors, it sets how many times you want the password re-encrypted.
@@ -77,7 +90,13 @@
7790
# able to access the website for two days without confirming his account,
7891
# access will be blocked just in the third day. Default is 0.days, meaning
7992
# the user cannot access the website without confirming his account.
80-
# config.confirm_within = 2.days
93+
# config.allow_unconfirmed_access_for = 2.days
94+
95+
# If true, requires any email changes to be confirmed (exactly the same way as
96+
# initial account confirmation) to be applied. Requires additional unconfirmed_email
97+
# db field (see migrations). Until confirmed new email is stored in
98+
# unconfirmed email column, and copied to email column on successful confirmation.
99+
config.reconfirmable = true
81100

82101
# Defines which key will be used when confirming an account
83102
# config.confirmation_keys = [ :email ]
@@ -86,15 +105,12 @@
86105
# The time the user will be remembered without asking for credentials again.
87106
# config.remember_for = 2.weeks
88107

89-
# If true, a valid remember token can be re-used between multiple browsers.
90-
# config.remember_across_browsers = true
91-
92108
# If true, extends the user's remember period when remembered via cookie.
93109
# config.extend_remember_period = false
94110

95111
# Options to be passed to the created cookie. For instance, you can set
96112
# :secure => true in order to force SSL only cookies.
97-
# config.cookie_options = {}
113+
# config.rememberable_options = {}
98114

99115
# ==> Configuration for :validatable
100116
# Range for password length. Default is 6..128.
@@ -109,6 +125,9 @@
109125
# The time you want to timeout the user session without activity. After this
110126
# time the user will be asked for credentials again. Default is 30 minutes.
111127
# config.timeout_in = 30.minutes
128+
129+
# If true, expires auth token on session timeout.
130+
# config.expire_auth_token_on_timeout = false
112131

113132
# ==> Configuration for :lockable
114133
# Defines which strategy will be used to lock an account.
@@ -155,10 +174,6 @@
155174
# Defines name of the authentication token params key
156175
# config.token_authentication_key = :auth_token
157176

158-
# If true, authentication through token does not store user in session and needs
159-
# to be supplied on each request. Useful if you are using the token as API token.
160-
# config.stateless_token = false
161-
162177
# ==> Scopes configuration
163178
# Turn scoped views on. Before rendering "sessions/new", it will first check for
164179
# "users/sessions/new". It's turned off by default because it's slower if you
@@ -169,9 +184,8 @@
169184
# devise role declared in your routes (usually :user).
170185
# config.default_scope = :user
171186

172-
# Configure sign_out behavior.
173-
# Sign_out action can be scoped (i.e. /users/sign_out affects only :user scope).
174-
# The default is true, which means any logout action will sign out all active scopes.
187+
# Set this configuration to false if you want /users/sign_out to sign out
188+
# only the current scope. By default, Devise signs out all scopes.
175189
# config.sign_out_all_scopes = true
176190

177191
# ==> Navigation configuration
@@ -182,9 +196,8 @@
182196
# If you have any extra navigational formats, like :iphone or :mobile, you
183197
# should add them to the navigational formats lists.
184198
#
185-
# The :"*/*" and "*/*" formats below is required to match Internet
186-
# Explorer requests.
187-
# config.navigational_formats = [:"*/*", "*/*", :html]
199+
# The "*/*" below is required to match Internet Explorer requests.
200+
# config.navigational_formats = ["*/*", :html]
188201

189202
# The default HTTP method used to sign out a resource. Default is :delete.
190203
config.sign_out_via = :delete
@@ -202,4 +215,18 @@
202215
# manager.intercept_401 = false
203216
# manager.default_strategies(:scope => :user).unshift :some_external_strategy
204217
# end
205-
end
218+
219+
# ==> Mountable engine configurations
220+
# When using Devise inside an engine, let's call it `MyEngine`, and this engine
221+
# is mountable, there are some extra configurations to be taken into account.
222+
# The following options are available, assuming the engine is mounted as:
223+
#
224+
# mount MyEngine, at: "/my_engine"
225+
#
226+
# The router that invoked `devise_for`, in the example above, would be:
227+
# config.router_name = :my_engine
228+
#
229+
# When using omniauth, Devise cannot automatically set Omniauth path,
230+
# so you need to do it manually. For the users scope, it would be:
231+
# config.omniauth_path_prefix = "/my_engine/users/auth"
232+
end

config/locales/devise.en.yml

+3-5
Original file line numberDiff line numberDiff line change
@@ -35,13 +35,11 @@ en:
3535
confirmed: 'Your account was successfully confirmed. You are now signed in.'
3636
registrations:
3737
signed_up: 'Welcome! You have signed up successfully.'
38-
inactive_signed_up: 'You have signed up successfully. However, we could not sign you in because your account is %{reason}.'
3938
updated: 'You updated your account successfully.'
4039
destroyed: 'Bye! Your account was successfully cancelled. We hope to see you again soon.'
41-
reasons:
42-
inactive: 'inactive'
43-
unconfirmed: 'unconfirmed'
44-
locked: 'locked'
40+
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.'
41+
signed_up_but_inactive: 'You have signed up successfully. However, we could not sign you in because your account is not yet activated.'
42+
signed_up_but_locked: 'You have signed up successfully. However, we could not sign you in because your account is locked.'
4543
unlocks:
4644
send_instructions: 'You will receive an email with instructions about how to unlock your account in a few minutes.'
4745
unlocked: 'Your account was successfully unlocked. You are now signed in.'

db/migrate/20120306154555_devise_create_users.rb

+37-10
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,43 @@
11
class DeviseCreateUsers < ActiveRecord::Migration
22
def change
33
create_table(:users) do |t|
4-
t.database_authenticatable :null => false
5-
t.recoverable
6-
t.rememberable
7-
t.trackable
8-
t.token_authenticatable
9-
10-
# t.encryptable
11-
# t.confirmable
12-
# t.lockable :lock_strategy => :failed_attempts, :unlock_strategy => :both
13-
# t.token_authenticatable
4+
## Database authenticatable
5+
t.string :email, :null => false, :default => ""
6+
t.string :encrypted_password, :null => false, :default => ""
7+
8+
## Recoverable
9+
t.string :reset_password_token
10+
t.datetime :reset_password_sent_at
11+
12+
## Rememberable
13+
t.datetime :remember_created_at
14+
15+
## Trackable
16+
t.integer :sign_in_count, :default => 0
17+
t.datetime :current_sign_in_at
18+
t.datetime :last_sign_in_at
19+
t.string :current_sign_in_ip
20+
t.string :last_sign_in_ip
21+
22+
## Encryptable
23+
# t.string :password_salt
24+
25+
## Confirmable
26+
# t.string :confirmation_token
27+
# t.datetime :confirmed_at
28+
# t.datetime :confirmation_sent_at
29+
# t.string :unconfirmed_email # Only if using reconfirmable
30+
31+
## Lockable
32+
# t.integer :failed_attempts, :default => 0 # Only if lock strategy is :failed_attempts
33+
# t.string :unlock_token # Only if unlock strategy is :email or :both
34+
# t.datetime :locked_at
35+
36+
# Token authenticatable
37+
t.string :authentication_token
38+
39+
## Invitable
40+
# t.string :invitation_token
1441

1542
t.text :first_name
1643
t.text :last_name

0 commit comments

Comments
 (0)