-
Notifications
You must be signed in to change notification settings - Fork 0
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Send Email #17
Merged
Merged
Send Email #17
Changes from 7 commits
Commits
Show all changes
15 commits
Select commit
Hold shift + click to select a range
648ae2b
add unused files to coveralls.json
nelsonic a2d6546
use SECRET_KEY_BASE environment variable for :joken JWT signing in al…
nelsonic 6b1bf96
create AuthMvp.Email and test for https://github.com/dwyl/auth/issues/41
nelsonic 36129d2
add export EMAIL_APP_URL=dwylmail.herokuapp.com to .env_sample
nelsonic 31e6871
implement sendemail/1 function for https://github.com/dwyl/auth/issue…
nelsonic 7f7819f
use sendemail/1 function in Google and GitHub auth controllers https:…
nelsonic ed13cc9
add lib/auth_mvp/application.ex to coveralls.json as not used directly
nelsonic 074c9ec
instruct to get SECRET_KEY_BASE from dashboard.heroku.com/apps/dwylma…
nelsonic 578a2f3
use recv_timeout: 10000 to ensure heroku app has time to wake
nelsonic 5502a84
add protocol (https://) to EMAIL_APP_URL
nelsonic e2d5000
use EMAIL_APP_URL environment variable in sendemail/1
nelsonic 96dceb4
remove IO.inspect
nelsonic f2735de
bump coverage up to 100% by repeating the invocation of GitHub/Google…
nelsonic 556f1b1
add travis and codecov badges to README.md now that coverage is 100% …
nelsonic 7848e56
fix typo
nelsonic File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -3,6 +3,9 @@ | |
"minimum_coverage": 100 | ||
}, | ||
"skip_files": [ | ||
"test/" | ||
"test/", | ||
"lib/auth_mvp_web.ex", | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. we aren't directly using these files so they aren't covered by tests hence adding them here. |
||
"lib/auth_mvp/application.ex", | ||
"lib/auth_mvp_web/views/error_helpers.ex" | ||
] | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
defmodule AuthMvp.Email do | ||
|
||
@doc """ | ||
`sendemail/1` sends an email using AWS SES. | ||
see: https://github.com/dwyl/email#sending-email | ||
params is a map that *must* contain the keys: email, name and template. | ||
|
||
## Examples | ||
|
||
iex> sendemail(%{"email" => "[email protected]", "name" => "Al", "template" => "hi"}) | ||
%{ | ||
"aud" => "Joken", | ||
"email" => "[email protected]", | ||
"exp" => 1616864371, | ||
"iat" => 1585327371, | ||
"id" => 33, | ||
"iss" => "Joken", | ||
"jti" => "2o03dm2ktf6f1j74es0001e3", | ||
"name" => "Al", | ||
"nbf" => 1585327371, | ||
"status" => "Pending", | ||
"template" => "hi" | ||
} | ||
""" | ||
|
||
def sendemail(params) do | ||
url = "https://dwylmail.herokuapp.com/api/send" | ||
jwt = AuthMvp.Token.generate_and_sign!(params) | ||
headers = ["Authorization": "#{jwt}"] | ||
options = [] # [ssl: [{:versions, [:'tlsv1.2']}], recv_timeout: 5000] | ||
{:ok, response} = HTTPoison.post(url, "_nobody", headers, options) | ||
Jason.decode!(response.body) | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
defmodule AuthMvp.EmailTest do | ||
use ExUnit.Case | ||
|
||
describe "AuthMvp.Email" do | ||
test "sendemail/1 an email" do | ||
params = %{ | ||
"email" => "[email protected]", | ||
"name" => "Super Successful", | ||
"template" => "welcome" | ||
} | ||
# IO.inspect(params, label: "params") | ||
res = AuthMvp.Email.sendemail(params) | ||
assert Map.get(params, "email") == Map.get(res, "email") | ||
assert Map.get(res, "id") > 0 | ||
end | ||
end | ||
end |
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this needs to match the
SECRET_KEY_BASE
on dashboard.heroku.com/apps/dwylmail/settings for email to work.