mirror of
https://github.com/LemmyNet/lemmy.git
synced 2024-06-18 05:10:34 +00:00
Merge branch 'main' into startup-error-503
This commit is contained in:
commit
b584b16653
|
@ -63,9 +63,9 @@
|
|||
setup: {
|
||||
# Username for the admin user
|
||||
admin_username: "admin"
|
||||
# Password for the admin user. It must be at least 10 characters.
|
||||
# Password for the admin user. It must be between 10 and 60 characters.
|
||||
admin_password: "tf6HHDS4RolWfFhk4Rq9"
|
||||
# Name of the site (can be changed later)
|
||||
# Name of the site, can be changed later. Maximum 20 characters.
|
||||
site_name: "My Lemmy Instance"
|
||||
# Email for the admin user (optional, can be omitted and set later through the website)
|
||||
admin_email: "user@example.com"
|
||||
|
|
|
@ -4,7 +4,6 @@ use bcrypt::verify;
|
|||
use lemmy_api_common::{
|
||||
context::LemmyContext,
|
||||
person::{Login, LoginResponse},
|
||||
utils,
|
||||
utils::check_user_valid,
|
||||
};
|
||||
use lemmy_db_schema::{
|
||||
|
@ -89,15 +88,12 @@ async fn check_registration_application(
|
|||
&& !local_user_view.local_user.accepted_application
|
||||
&& !local_user_view.local_user.admin
|
||||
{
|
||||
// Fetch the registration, see if its denied
|
||||
// Fetch the registration application. If no admin id is present its still pending. Otherwise it
|
||||
// was processed (either accepted or denied).
|
||||
let local_user_id = local_user_view.local_user.id;
|
||||
let registration = RegistrationApplication::find_by_local_user_id(pool, local_user_id).await?;
|
||||
if let Some(deny_reason) = registration.deny_reason {
|
||||
let lang = utils::get_interface_language(local_user_view);
|
||||
let registration_denied_message = format!("{}: {}", lang.registration_denied(), deny_reason);
|
||||
Err(LemmyErrorType::RegistrationDenied(
|
||||
registration_denied_message,
|
||||
))?
|
||||
if registration.admin_id.is_some() {
|
||||
Err(LemmyErrorType::RegistrationDenied(registration.deny_reason))?
|
||||
} else {
|
||||
Err(LemmyErrorType::RegistrationApplicationIsPending)?
|
||||
}
|
||||
|
|
|
@ -196,7 +196,7 @@ pub enum LemmyErrorType {
|
|||
EmailSendFailed,
|
||||
Slurs,
|
||||
CouldntFindObject,
|
||||
RegistrationDenied(String),
|
||||
RegistrationDenied(Option<String>),
|
||||
FederationDisabled,
|
||||
DomainBlocked(String),
|
||||
DomainNotInAllowList(String),
|
||||
|
@ -276,12 +276,12 @@ mod tests {
|
|||
|
||||
#[test]
|
||||
fn deserializes_with_message() {
|
||||
let reg_denied = LemmyErrorType::RegistrationDenied(String::from("reason"));
|
||||
let err = LemmyError::from(reg_denied).error_response();
|
||||
let reg_banned = LemmyErrorType::PersonIsBannedFromSite(String::from("reason"));
|
||||
let err = LemmyError::from(reg_banned).error_response();
|
||||
let json = String::from_utf8(err.into_body().try_into_bytes().unwrap().to_vec()).unwrap();
|
||||
assert_eq!(
|
||||
&json,
|
||||
"{\"error\":\"registration_denied\",\"message\":\"reason\"}"
|
||||
"{\"error\":\"person_is_banned_from_site\",\"message\":\"reason\"}"
|
||||
)
|
||||
}
|
||||
|
||||
|
|
|
@ -154,10 +154,10 @@ pub struct SetupConfig {
|
|||
/// Username for the admin user
|
||||
#[doku(example = "admin")]
|
||||
pub admin_username: String,
|
||||
/// Password for the admin user. It must be at least 10 characters.
|
||||
/// Password for the admin user. It must be between 10 and 60 characters.
|
||||
#[doku(example = "tf6HHDS4RolWfFhk4Rq9")]
|
||||
pub admin_password: String,
|
||||
/// Name of the site (can be changed later)
|
||||
/// Name of the site, can be changed later. Maximum 20 characters.
|
||||
#[doku(example = "My Lemmy Instance")]
|
||||
pub site_name: String,
|
||||
/// Email for the admin user (optional, can be omitted and set later through the website)
|
||||
|
|
Loading…
Reference in a new issue