Skip to content

Commit f186567

Browse files
committed
devise-async for Mail send
1 parent 775853b commit f186567

File tree

5 files changed

+14
-8
lines changed

5 files changed

+14
-8
lines changed

Gemfile

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,7 @@ gem 'mongoid_rails_migrations', '1.0.0'
3737

3838
# 用户系统
3939
gem 'devise', '~> 3.4.0'
40+
gem "devise-async"
4041
gem 'devise-encryptable', '0.1.2'
4142

4243
# 分页

Gemfile.lock

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -126,6 +126,8 @@ GEM
126126
responders
127127
thread_safe (~> 0.1)
128128
warden (~> 1.2.3)
129+
devise-async (0.10.1)
130+
devise (~> 3.2)
129131
devise-encryptable (0.1.2)
130132
devise (>= 2.1.0)
131133
diff-lcs (1.2.5)
@@ -417,6 +419,7 @@ DEPENDENCIES
417419
database_cleaner
418420
derailed_benchmarks!
419421
devise (~> 3.4.0)
422+
devise-async
420423
devise-encryptable (= 0.1.2)
421424
doorkeeper
422425
doorkeeper-i18n!

app/models/user.rb

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ class User
1212
ALLOW_LOGIN_CHARS_REGEXP = /\A\w+\z/
1313

1414
devise :database_authenticatable, :registerable, :recoverable,
15-
:rememberable, :trackable, :validatable, :omniauthable
15+
:rememberable, :trackable, :validatable, :omniauthable, :async
1616

1717
field :email, type: String, default: ""
1818
# Email 的 md5 值,用于 Gravatar 头像
@@ -454,7 +454,7 @@ def unfollow_user(user)
454454
return false if user.blank?
455455
self.following.delete(user)
456456
end
457-
457+
458458
def avatar_url
459459
if self.avatar?
460460
self.avatar.url(:large)
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
<p>你好 <%= @resource.login %>!</p>
22
<p>有人请求找回在 <%= Setting.app_name %> 上面,账号为 <%= @resource.login %> 的密码,如果你是,那么你可以通过下面的连接进入网站修改密码.</p>
3-
<p style="margin:20px 0;"><%= link_to "修改我的密码", edit_password_url(@resource, reset_password_token: @token) %><p>
3+
<p><%= link_to "修改我的密码", edit_password_url(@resource, reset_password_token: @token) %><p>
44
<p>如果看不到连接,请复制下面的连接然后在浏览器里面打开:</p>
55
<p><%= edit_password_url(@resource, reset_password_token: @token) %></p>
66
<p>如果你没有申请,可以忽略这封邮件,你的账号不会受到影响。</p>

config/initializers/devise.rb

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
# four configuration values can also be set straight in your models.
55
Devise.setup do |config|
66
config.secret_key = '899836258327a309c761fb0aeb6c4a85c2ccb0924ffce6fce4f6355d029dac7b7b96afdc1b51544f7c7a235b83cc8a41b538cf54553a690d3bbe45f9c4672ecf'
7-
7+
88
# ==> Mailer Configuration
99
# Configure the e-mail address which will be shown in DeviseMailer.
1010
config.mailer_sender = Setting.email_sender
@@ -37,7 +37,7 @@
3737
# These keys will have whitespace before and after removed upon creating or
3838
# modifying a user and when used to authenticate or find a user. Default is :email.
3939
config.strip_whitespace_keys = [ :email, :login ]
40-
40+
4141
# Tell if authentication through request.params is enabled. True by default.
4242
# config.params_authenticatable = true
4343

@@ -49,7 +49,7 @@
4949

5050
# The realm used in Http Basic Authentication
5151
# config.http_authentication_realm = "Application"
52-
52+
5353
# It will change confirmation, password recovery and other workflows
5454
# to behave the same regardless if the e-mail provided was right or wrong.
5555
# Does not affect registerable.
@@ -89,7 +89,7 @@
8989
# (ie 2 days).
9090
# config.allow_unconfirmed_access_for = 2.days
9191
# config.confirm_within = 3.days
92-
92+
9393
# If true, requires any email changes to be confirmed (exactly the same way as
9494
# initial account confirmation) to be applied. Requires additional unconfirmed_email
9595
# db field (see migrations). Until confirmed new email is stored in
@@ -123,7 +123,7 @@
123123
# The time you want to timeout the user session without activity. After this
124124
# time the user will be asked for credentials again.
125125
# config.timeout_in = 30.minutes
126-
126+
127127
# If true, expires auth token on session timeout.
128128
# config.expire_auth_token_on_timeout = false
129129

@@ -191,3 +191,5 @@
191191
# manager.default_strategies(:scope => :user).unshift :twitter_oauth
192192
# end
193193
end
194+
195+
Devise::Async.backend = :sidekiq

0 commit comments

Comments
 (0)