Register form and confirmation messages
This commit is contained in:
@@ -2,7 +2,7 @@ use crate::startup::AppState;
|
||||
use axum::{
|
||||
extract::{Query, State},
|
||||
http::StatusCode,
|
||||
response::IntoResponse,
|
||||
response::{Html, IntoResponse, Response},
|
||||
};
|
||||
use serde::Deserialize;
|
||||
use sqlx::PgPool;
|
||||
@@ -14,23 +14,23 @@ pub async fn confirm(
|
||||
connection_pool, ..
|
||||
}): State<AppState>,
|
||||
Query(params): Query<Params>,
|
||||
) -> impl IntoResponse {
|
||||
) -> Response {
|
||||
let Ok(subscriber_id) =
|
||||
get_subscriber_id_from_token(&connection_pool, ¶ms.subscription_token).await
|
||||
else {
|
||||
return StatusCode::INTERNAL_SERVER_ERROR;
|
||||
return StatusCode::INTERNAL_SERVER_ERROR.into_response();
|
||||
};
|
||||
if let Some(subscriber_id) = subscriber_id {
|
||||
if confirm_subscriber(&connection_pool, &subscriber_id)
|
||||
.await
|
||||
.is_err()
|
||||
{
|
||||
StatusCode::INTERNAL_SERVER_ERROR
|
||||
StatusCode::INTERNAL_SERVER_ERROR.into_response()
|
||||
} else {
|
||||
StatusCode::OK
|
||||
Html(include_str!("register/confirm.html")).into_response()
|
||||
}
|
||||
} else {
|
||||
StatusCode::UNAUTHORIZED
|
||||
StatusCode::UNAUTHORIZED.into_response()
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user