mirror of
https://github.com/perstarkse/minne.git
synced 2026-03-17 23:14:08 +01:00
feat: consistent styling
This commit is contained in:
@@ -1,7 +1,7 @@
|
||||
use axum::{
|
||||
extract::State,
|
||||
http::{StatusCode, Uri},
|
||||
response::{IntoResponse, Redirect},
|
||||
response::{Html, IntoResponse, Redirect},
|
||||
Form,
|
||||
};
|
||||
use axum_htmx::{HxBoosted, HxRedirect};
|
||||
@@ -52,10 +52,18 @@ pub async fn authenticate_user(
|
||||
auth: AuthSession<User, String, SessionSurrealPool<Any>, Surreal<Any>>,
|
||||
Form(form): Form<SignupParams>,
|
||||
) -> Result<impl IntoResponse, ApiError> {
|
||||
let user = User::authenticate(form.email, form.password, &state.surreal_db_client).await?;
|
||||
let user = match User::authenticate(form.email, form.password, &state.surreal_db_client).await {
|
||||
Ok(user) => user,
|
||||
Err(_) => {
|
||||
return Ok(Html("<p>Invalid email or password.</p>").into_response());
|
||||
}
|
||||
};
|
||||
|
||||
auth.login_user(user.id);
|
||||
|
||||
if form.remember_me.is_some_and(|string| string == *"on") {
|
||||
auth.remember_user(true);
|
||||
}
|
||||
|
||||
Ok((HxRedirect::from(Uri::from_static("/")), StatusCode::OK).into_response())
|
||||
}
|
||||
|
||||
@@ -1,9 +1,10 @@
|
||||
use axum::{
|
||||
extract::State,
|
||||
response::{IntoResponse, Redirect},
|
||||
http::{StatusCode, Uri},
|
||||
response::{Html, IntoResponse, Redirect},
|
||||
Form,
|
||||
};
|
||||
use axum_htmx::HxBoosted;
|
||||
use axum_htmx::{HxBoosted, HxRedirect};
|
||||
use axum_session_auth::AuthSession;
|
||||
use axum_session_surreal::SessionSurrealPool;
|
||||
use serde::{Deserialize, Serialize};
|
||||
@@ -50,7 +51,14 @@ pub async fn process_signup_and_show_verification(
|
||||
auth: AuthSession<User, String, SessionSurrealPool<Any>, Surreal<Any>>,
|
||||
Form(form): Form<SignupParams>,
|
||||
) -> Result<impl IntoResponse, ApiError> {
|
||||
let user = User::create_new(form.email, form.password, &state.surreal_db_client).await?;
|
||||
let user = match User::create_new(form.email, form.password, &state.surreal_db_client).await {
|
||||
Ok(user) => user,
|
||||
Err(_) => {
|
||||
return Ok(Html("<p>User already exists</p>").into_response());
|
||||
}
|
||||
};
|
||||
|
||||
auth.login_user(user.id);
|
||||
Ok(())
|
||||
|
||||
Ok((HxRedirect::from(Uri::from_static("/")), StatusCode::OK).into_response())
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user