Use more descriptive errors for signup checks
This commit is contained in:
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user