Skip to content
GitLab
Menu
Projects
Groups
Snippets
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in
Toggle navigation
Menu
Open sidebar
gy4443
chemotion_eln_server
Commits
8680bb36
Commit
8680bb36
authored
Mar 13, 2017
by
PiTrem
Browse files
user devise: add confirmable
parent
329dc759
Changes
6
Hide whitespace changes
Inline
Side-by-side
app/models/user.rb
View file @
8680bb36
class
User
<
ActiveRecord
::
Base
acts_as_paranoid
# Include default devise modules. Others available are:
#
:confirmable,
:lockable, :timeoutable and :omniauthable
devise
:database_authenticatable
,
:registerable
,
# :lockable, :timeoutable and :omniauthable
devise
:database_authenticatable
,
:registerable
,
:confirmable
,
:recoverable
,
:rememberable
,
:trackable
,
:validatable
has_one
:profile
,
dependent: :destroy
...
...
config/environments/production.rb
View file @
8680bb36
...
...
@@ -75,4 +75,19 @@ Rails.application.configure do
# Use default logging formatter so that PID and timestamp are not suppressed.
config
.
log_formatter
=
::
Logger
::
Formatter
.
new
config
.
action_mailer
.
raise_delivery_errors
=
true
config
.
action_mailer
.
delivery_method
=
:smtp
config
.
action_mailer
.
default_url_options
=
{
host:
ENV
[
'SMTP_HOST'
]}
config
.
action_mailer
.
smtp_settings
=
{
:address
=>
ENV
[
"SMTP_ADDRESS"
],
:port
=>
ENV
[
"SMTP_PORT"
],
:user_name
=>
ENV
[
'SMTP_USERNAME'
],
:domain
=>
ENV
[
'SMTP_DOMAIN'
],
:password
=>
ENV
[
'SMTP_PASSWORD'
],
:authentication
=>
ENV
[
'SMTP_AUTH'
]
&&
ENV
[
'SMTP_AUTH'
].
to_sym
,
:enable_starttls_auto
=>
ENV
[
'SMTP_TLS'
]
&&
ENV
[
'SMTP_TLS'
].
match
(
/true/
)
:openssl_verify_mode
=>
ENV
[
'SMTP_SSL_MODE'
],
}
end
config/initializers/devise.rb
View file @
8680bb36
...
...
@@ -12,8 +12,8 @@ Devise.setup do |config|
# Configure the e-mail address which will be shown in Devise::Mailer,
# note that it will be overwritten if you use your own mailer class
# with default "from" parameter.
config
.
mailer_sender
=
'please-change-me-at-config-initializers-devise@example.com'
config
.
mailer_sender
=
ENV
[
'DEVISE_SENDER'
]
||
'please-change-me-at-config-initializers-devise@example.com'
# Configure the class responsible to send e-mails.
# config.mailer = 'Devise::Mailer'
...
...
@@ -107,7 +107,7 @@ Devise.setup do |config|
# able to access the website for two days without confirming their account,
# access will be blocked just in the third day. Default is 0.days, meaning
# the user cannot access the website without confirming their account.
#
config.allow_unconfirmed_access_for =
2
.days
config
.
allow_unconfirmed_access_for
=
0
.
days
# A period that the user is allowed to confirm their account before their
# token becomes invalid. For example, if set to 3.days, the user can confirm
...
...
db/migrate/20161201152821_add_confirmable_to_devise.rb
0 → 100644
View file @
8680bb36
class
AddConfirmableToDevise
<
ActiveRecord
::
Migration
def
up
add_column
:users
,
:confirmation_token
,
:string
add_column
:users
,
:confirmed_at
,
:datetime
add_column
:users
,
:confirmation_sent_at
,
:datetime
add_column
:users
,
:unconfirmed_email
,
:string
add_index
:users
,
:confirmation_token
,
unique:
true
User
.
reset_column_information
execute
(
"UPDATE users SET confirmed_at = NOW()"
)
end
def
down
remove_columns
:users
,
:confirmation_token
,
:confirmed_at
,
:confirmation_sent_at
remove_columns
:users
,
:unconfirmed_email
end
end
db/schema.rb
View file @
8680bb36
...
...
@@ -554,6 +554,10 @@ ActiveRecord::Schema.define(version: 20170215133510) do
t
.
boolean
"is_templates_moderator"
,
default:
false
,
null:
false
t
.
string
"type"
,
default:
"Person"
t
.
string
"reaction_name_prefix"
,
limit:
3
,
default:
"R"
t
.
string
"confirmation_token"
t
.
datetime
"confirmed_at"
t
.
datetime
"confirmation_sent_at"
t
.
string
"unconfirmed_email"
t
.
hstore
"layout"
,
default:
{
"sample"
=>
"1"
,
"screen"
=>
"4"
,
"reaction"
=>
"2"
,
"wellplate"
=>
"3"
,
"research_plan"
=>
"5"
},
null:
false
end
...
...
lib/tasks/data/ver_20161201152801.rake
0 → 100644
View file @
8680bb36
namespace
:data
do
desc
"data modifications for 20161201152801_add_confirmable_to_devise"
# confirm existing users (not mandatory)
task
ver_20161201152801: :environment
do
time_now
=
Time
.
now
User
.
all
.
each
do
|
user
|
user
.
confirmed_at
=
time_now
user
.
save!
end
end
end
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment