Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
24d03c7
commit 1721bda
Showing
10 changed files
with
65 additions
and
2 deletions.
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
defmodule Passwordless.Accounts.Tokens do | ||
alias Phoenix.Token | ||
alias PasswordlessWeb.Endpoint | ||
|
||
@login_request_max_age 60 * 15 # 15 minutes | ||
@login_request_salt "login request salt" | ||
|
||
def sign_login_request(login_request) do | ||
Token.sign(Endpoint, @login_request_salt, login_request.id) | ||
end | ||
|
||
def verify_login_request(token) do | ||
Token.verify(Endpoint, @login_request_salt, token, max_age: @login_request_max_age) | ||
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
defmodule Passwordless.Email do | ||
use Bamboo.Phoenix, view: PasswordlessWeb.EmailView | ||
import Bamboo.Email | ||
|
||
alias Passwordless.Accounts.Tokens | ||
|
||
def login_request(user, login_request) do | ||
new_email() | ||
|> to(user.email) | ||
|> from("support@example.com") | ||
|> subject("Log in to Passwordless") | ||
|> assign(:token, Tokens.sign_login_request(login_request)) | ||
|> render("login_request.html") | ||
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
defmodule Passwordless.Mailer do | ||
use Bamboo.Mailer, otp_app: :passwordless | ||
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,5 @@ | ||
<p>Hello!</p> | ||
|
||
<p>Use the link below to log in to your Passwordless account. <strong>This link expires in 15 minutes.</strong></p> | ||
|
||
<p><%= link "Log in to Passwordless", to: "#todo" %></p> |
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,3 @@ | ||
defmodule PasswordlessWeb.EmailView do | ||
use PasswordlessWeb, :view | ||
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