mirror of
https://forgejo.ellis.link/continuwuation/continuwuity.git
synced 2026-11-14 04:37:00 +00:00
refactor: Split remote and deactivated users into their own columns
This commit is contained in:
32 files changed
+391
-278
No files matched your search
@@ -69,7 +69,7 @@ async fn route_change_password(
|
||||
let user_card = UserCard::for_local_user(&services, user_id.clone()).await;
|
||||
|
||||
let body = if let Some(form) = form {
|
||||
match change_password(&services, &user_id, form).await {
|
||||
match change_password(&services, &user_id, form).await? {
|
||||
| Ok(()) => ChangePasswordBody::Success,
|
||||
| Err(errors) =>
|
||||
ChangePasswordBody::Form(ChangePasswordForm::with_errors(context.clone(), errors)),
|
||||
@@ -85,7 +85,7 @@ async fn change_password(
|
||||
services: &crate::State,
|
||||
user_id: &UserId,
|
||||
form: ChangePasswordForm,
|
||||
) -> Result<(), ValidationErrors> {
|
||||
) -> Result<Result<(), ValidationErrors>> {
|
||||
form.validate()?;
|
||||
|
||||
if services
|
||||
@@ -100,12 +100,12 @@ async fn change_password(
|
||||
ValidationError::new("wrong").with_message("Incorrect password".into()),
|
||||
);
|
||||
|
||||
return Err(errors);
|
||||
return Ok(Err(errors));
|
||||
}
|
||||
|
||||
match HashedPassword::new(&form.new_password) {
|
||||
| Ok(hash) => {
|
||||
services.users.set_password(user_id, Some(hash));
|
||||
services.users.set_password(user_id, hash).await?;
|
||||
},
|
||||
| Err(err) => {
|
||||
let mut errors = ValidationErrors::new();
|
||||
@@ -114,9 +114,9 @@ async fn change_password(
|
||||
ValidationError::new("malformed").with_message(err.message().into()),
|
||||
);
|
||||
|
||||
return Err(errors);
|
||||
return Ok(Err(errors));
|
||||
},
|
||||
}
|
||||
|
||||
Ok(())
|
||||
Ok(Ok(()))
|
||||
}
|
||||
@@ -214,7 +214,7 @@ async fn route_reset_password_validate(
|
||||
| Ok(hash) => {
|
||||
let _ = session.consume();
|
||||
|
||||
services.users.set_password(&user_id, Some(hash));
|
||||
services.users.set_password(&user_id, hash).await?;
|
||||
|
||||
ResetPasswordValidateBody::ResetSuccess { user_card }
|
||||
},
|
||||
|
||||
@@ -310,7 +310,7 @@ async fn get_register_email_validate(
|
||||
|
||||
response!(
|
||||
complete_registration(&services, session_store, completed_registration, Some(email))
|
||||
.await
|
||||
.await?
|
||||
)
|
||||
}
|
||||
|
||||
@@ -502,7 +502,7 @@ async fn begin_registration(
|
||||
} else {
|
||||
// If email isn't required we can immediately complete registration
|
||||
Ok(response!(
|
||||
complete_registration(services, session_store, completed_registration, None).await
|
||||
complete_registration(services, session_store, completed_registration, None).await?
|
||||
))
|
||||
}
|
||||
}
|
||||
@@ -517,11 +517,11 @@ async fn complete_registration(
|
||||
next,
|
||||
}: CompletedRegistration,
|
||||
email: Option<Address>,
|
||||
) -> Redirect {
|
||||
) -> Result<Redirect> {
|
||||
services
|
||||
.users
|
||||
.create_local_account(&user_id, password_hash, email)
|
||||
.await;
|
||||
.await?;
|
||||
|
||||
if let Some(registration_token) = registration_token {
|
||||
services
|
||||
@@ -536,7 +536,7 @@ async fn complete_registration(
|
||||
.await
|
||||
.expect("should be able to serialize user session");
|
||||
|
||||
Redirect::to(&next.unwrap_or_default().target_path())
|
||||
Ok(Redirect::to(&next.unwrap_or_default().target_path()))
|
||||
}
|
||||
|
||||
pub(super) async fn registration_flow_status(
|
||||
|
||||
@@ -162,10 +162,8 @@ pub(crate) async fn require_active(
|
||||
user_id: &UserId,
|
||||
allow_locked: bool,
|
||||
) -> Result<(), Response> {
|
||||
if !services.users.is_active(user_id).await {
|
||||
return Err(
|
||||
WebError::Forbidden("Your account is deactivated.".to_owned()).into_response()
|
||||
);
|
||||
if let Err(err) = services.users.status(user_id).await.ensure_active() {
|
||||
return Err(WebError::Forbidden(err.message()).into_response());
|
||||
}
|
||||
|
||||
if !allow_locked
|
||||
|
||||
Reference in new issue
Block a user