Skip to content

Commit

Permalink
Merge pull request #808 from code-corps/update-password-reset
Browse files Browse the repository at this point in the history
Update password reset to add email
  • Loading branch information
joshsmith committed May 30, 2017
2 parents 96354a8 + 267fcff commit eadef90
Show file tree
Hide file tree
Showing 14 changed files with 255 additions and 139 deletions.
1 change: 1 addition & 0 deletions config/dev.exs
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,7 @@ config :code_corps, CodeCorps.Mailer,
adapter: Bamboo.LocalAdapter

config :code_corps,
postmark_forgot_password_template: "123",
postmark_project_acceptance_template: "123",
postmark_receipt_template: "123"

Expand Down
1 change: 1 addition & 0 deletions config/prod.exs
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,7 @@ config :code_corps, CodeCorps.Mailer,
api_key: System.get_env("POSTMARK_API_KEY")

config :code_corps,
postmark_forgot_password_template: "1989483",
postmark_project_acceptance_template: "1447041",
postmark_receipt_template: "1255222"

Expand Down
1 change: 1 addition & 0 deletions config/remote-development.exs
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@ config :code_corps, CodeCorps.Mailer,
adapter: Bamboo.LocalAdapter

config :code_corps,
postmark_forgot_password_template: "123",
postmark_project_acceptance_template: "123",
postmark_receipt_template: "123"

Expand Down
1 change: 1 addition & 0 deletions config/staging.exs
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,7 @@ config :code_corps, CodeCorps.Mailer,
api_key: System.get_env("POSTMARK_API_KEY")

config :code_corps,
postmark_forgot_password_template: "1989481",
postmark_project_acceptance_template: "1447022",
postmark_receipt_template: "1252361"

Expand Down
1 change: 1 addition & 0 deletions config/test.exs
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,7 @@ config :code_corps, CodeCorps.Mailer,
adapter: Bamboo.TestAdapter

config :code_corps,
postmark_forgot_password_template: "123",
postmark_project_acceptance_template: "123",
postmark_receipt_template: "123"

Expand Down
90 changes: 90 additions & 0 deletions emails/forgot_password.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,90 @@
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
<title>Here's the link to reset your password.</title>
<!--
Make sure you copy the styles from styles.css into the email template in Postmark before saving there.
<style type="text/css" rel="stylesheet" media="all">
</style>
-->
<link rel="stylesheet" type="text/css" href="styles.css" media="screen" />
</head>
<body>
<span class="preheader">Here's the link to reset your password.</span>
<table class="email-wrapper" width="100%" cellpadding="0" cellspacing="0">
<tr>
<td align="center">
<table class="email-content" width="100%" cellpadding="0" cellspacing="0">
<tr>
<td class="email-masthead" width="100%" cellpadding="0" cellspacing="0">
<table class="email-masthead_inner" align="center" width="570" cellpadding="0" cellspacing="0">
<tr>
<td>
<a href="https://www.codecorps.org">
<img src="https://d3pgew4wbk2vb1.cloudfront.net/emails/images/logo-small@2x.png" class="email-masthead_logo" />
</a>
</td>
</tr>
</table>
</td>
</tr>
<!-- Email Body -->
<tr>
<td class="email-body" width="100%" cellpadding="0" cellspacing="0">
<table class="email-body_inner" align="center" width="570" cellpadding="0" cellspacing="0">
<!-- Body content -->
<tr>
<td class="content-cell">
<table width="100%" cellpadding="0" cellspacing="0">
<tr>
<td>
<p>Hi there,</p>
<p>To reset your password, please <a href="{{link}}">click here</a> or paste this link into your browser:</p>
<p><a href="{{link}}">{{link}}</a></p>
<p>Your link is only valid for the next hour.</p>
<p>If you have any issues, don't hesitate to <a href="https://help.codecorps.org">contact us</a>.</p>
</td>
</tr>
</table>
<table class="body-signature">
<tr>
<td>
<p>
Thanks!
<br><strong>The Code Corps Team</strong>
</p>
<p class="center small">
Questions? Feedback?
<br>Visit our <strong><a href="https://help.codecorps.org">Help Center</a></strong> or just reply to this email.</p>
</td>
</tr>
</table>
</td>
</tr>
</table>
</td>
</tr>
<tr>
<td>
<table class="email-footer" align="center" width="570" cellpadding="0" cellspacing="0">
<tr>
<td class="content-cell" align="center">
<p class="sub align-center">
Code Corps PBC
<br>4166 Wilson Ave #1
<br>San Diego, CA 92104
</p>
</td>
</tr>
</table>
</td>
</tr>
</table>
</td>
</tr>
</table>
</body>
</html>
7 changes: 5 additions & 2 deletions lib/code_corps/cloudex/cloudex_test.ex
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,11 @@ defmodule CloudexTest do
"""

defmodule Url do
def for(public_id, options) do
{public_id, options}
def for(_public_id, %{height: height, width: width}) do
"https://placehold.it/#{width}x#{height}"
end
def for(_public_id, _options) do
"https://placehold.it/500x500"
end
end
end
3 changes: 1 addition & 2 deletions lib/code_corps/services/forgot_password.ex
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ defmodule CodeCorps.Services.ForgotPasswordService do
alias CodeCorps.{AuthToken, Emails, Mailer, Repo, User}

@doc"""
forgot_password should take an email and generate an AuthToken model and send an email
Generates an AuthToken model and sends to the provided email.
"""
def forgot_password(email) do
with %User{} = user <- Repo.get_by(User, email: email),
Expand All @@ -14,5 +14,4 @@ defmodule CodeCorps.Services.ForgotPasswordService do
nil -> nil
end
end

end
Loading

0 comments on commit eadef90

Please sign in to comment.