-
Notifications
You must be signed in to change notification settings - Fork 0
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
69e01e5
commit ea6b146
Showing
12 changed files
with
157 additions
and
6 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
#[derive(thiserror::Error, Debug)] | ||
pub enum AuthError { | ||
#[error("Invalid credentials.")] | ||
InvalidCredentials(#[source] anyhow::Error), | ||
#[error(transparent)] | ||
UnexpectedError(#[from] anyhow::Error), | ||
} |
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 |
---|---|---|
@@ -1,3 +1,4 @@ | ||
pub mod authentication; | ||
pub mod configuration; | ||
pub mod domain; | ||
pub mod email_client; | ||
|
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,11 @@ | ||
<!DOCTYPE html> | ||
<html lang="pt-br"> | ||
<head> | ||
<meta http-equiv="content-type" content="text/html; charset=utf-8" /> | ||
<title>Home</title> | ||
</head> | ||
|
||
<body> | ||
<p>Welcome to our newsletter!</p> | ||
</body> | ||
</html> |
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,7 @@ | ||
use actix_web::{http::header::ContentType, HttpResponse}; | ||
|
||
pub async fn home() -> HttpResponse { | ||
HttpResponse::Ok() | ||
.content_type(ContentType::html()) | ||
.body(include_str!("home.html")) | ||
} |
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,7 @@ | ||
use actix_web::{http::header::ContentType, HttpResponse}; | ||
|
||
pub async fn login_form() -> HttpResponse { | ||
HttpResponse::Ok() | ||
.content_type(ContentType::html()) | ||
.body(include_str!("login.html")) | ||
} |
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,21 @@ | ||
<!DOCTYPE html> | ||
<html lang="pt-br"> | ||
<head> | ||
<meta http-equiv="content-type" content="text/html; charset=utf-8" /> | ||
<title>Login</title> | ||
</head> | ||
<body> | ||
<form action="/login" method="post"> | ||
<label | ||
>Username | ||
<input type="text" placeholder="Enter Username" name="username" /> | ||
</label> | ||
<label | ||
>Password | ||
<input type="password" placeholder="Enter Password" name="password" /> | ||
</label> | ||
|
||
<button type="submit">Login</button> | ||
</form> | ||
</body> | ||
</html> |
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 @@ | ||
mod get; | ||
mod post; | ||
|
||
pub use get::login_form; | ||
pub use post::login; |
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 @@ | ||
use actix_web::http::header::LOCATION; | ||
use actix_web::web; | ||
use actix_web::HttpResponse; | ||
use secrecy::Secret; | ||
|
||
#[allow(unused)] | ||
#[derive(serde::Deserialize)] | ||
pub struct FormData { | ||
username: String, | ||
password: Secret<String>, | ||
} | ||
|
||
pub async fn login(_form: web::Form<FormData>) -> HttpResponse { | ||
HttpResponse::SeeOther() | ||
.insert_header((LOCATION, "/")) | ||
.finish() | ||
} |
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 |
---|---|---|
@@ -1,9 +1,13 @@ | ||
mod health_check; | ||
mod home; | ||
mod login; | ||
mod newsletters; | ||
mod subscriptions; | ||
mod subscriptions_confirm; | ||
|
||
pub use health_check::*; | ||
pub use home::*; | ||
pub use login::*; | ||
pub use newsletters::*; | ||
pub use subscriptions::*; | ||
pub use subscriptions_confirm::*; |
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