Skip to content

Commit

Permalink
put user on hold if there is no email or phone identity yet
Browse files Browse the repository at this point in the history
  • Loading branch information
valzav committed Jun 26, 2017
1 parent 9dcb220 commit 2d38de9
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 3 deletions.
6 changes: 4 additions & 2 deletions app/admin/user.rb
Original file line number Diff line number Diff line change
Expand Up @@ -221,9 +221,11 @@ def auto_approve_everyone
next unless user.account_status == 'waiting'
next unless user.account
eid = user.email_identity
next unless eid
pid = user.phone_identity
next unless pid
if !eid or !pid
user.putonhold!
next
end
if eid.verified and pid.verified
result = user.approve
if result[:error]
Expand Down
2 changes: 1 addition & 1 deletion app/models/user.rb
Original file line number Diff line number Diff line change
Expand Up @@ -159,8 +159,8 @@ def approve
},
"template_id": "#{ENV['SDC_SENDGRID_APPROVETEMPLATE']}"
}})
sg = SendGrid::API.new(api_key: ENV['SDC_SENDGRID_API_KEY'])
if Rails.env.production?
sg = SendGrid::API.new(api_key: ENV['SDC_SENDGRID_API_KEY'])
response = sg.client.mail._("send").post(request_body: data)
if response.status_code.to_i >= 300
logger.error 'SendGrid error', response.inspect
Expand Down

0 comments on commit 2d38de9

Please sign in to comment.