Use more descriptive errors for signup checks

This commit is contained in:
2026-06-29 21:58:10 -04:00
parent 843572b487
commit ebfe18aca2

View File

@@ -17,12 +17,12 @@ use crate::util::error::{AuthError, Contextualize, Error, ErrorType};
#[post("/api/v1/auth/signup", mut auth: Extension<AuthSession>, db_pool: Extension<DbPool>, config: Extension<Config>)]
pub async fn signup(credentials: UserCredentials) -> Result<User> {
if !config.auth.open_signup {
return Err(Error::new_here(ErrorType::Auth(AuthError::Unauthorized)));
return Err(Error::message_here("Signup is disabled"));
}
// Don't allow signup when already logged in
if auth.user.is_some() {
return Err(Error::new_here(ErrorType::Auth(AuthError::Unauthorized)));
return Err(Error::message_here("Log out before creating an account"));
}
let hashed_creds = credentials