Add web site settings
This commit is contained in:
parent
65489e7692
commit
f1ea7841a2
8 changed files with 74 additions and 19 deletions
|
|
@ -32,20 +32,29 @@ use crate::{
|
|||
|
||||
#[debug_handler]
|
||||
pub async fn sign_up_get(
|
||||
State(connection): State<db::Connection>,
|
||||
Extension(user): Extension<Option<model::User>>,
|
||||
Extension(tr): Extension<translation::Tr>,
|
||||
) -> Result<impl IntoResponse> {
|
||||
Ok(Html(
|
||||
SignUpFormTemplate {
|
||||
user,
|
||||
tr,
|
||||
email: String::new(),
|
||||
message: "",
|
||||
message_email: "",
|
||||
message_password: "",
|
||||
}
|
||||
.render()?,
|
||||
))
|
||||
) -> Result<Response> {
|
||||
if connection.get_new_user_registration_enabled().await? {
|
||||
Ok(Html(
|
||||
SignUpFormTemplate {
|
||||
user,
|
||||
tr,
|
||||
email: String::new(),
|
||||
message: "",
|
||||
message_email: "",
|
||||
message_password: "",
|
||||
}
|
||||
.render()?,
|
||||
)
|
||||
.into_response())
|
||||
} else {
|
||||
Ok(
|
||||
Html(MessageTemplate::new_with_user(tr.t(Sentence::SignUpClosed), tr, user).render()?)
|
||||
.into_response(),
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
#[derive(Deserialize, Debug)]
|
||||
|
|
@ -109,6 +118,13 @@ pub async fn sign_up_post(
|
|||
.into_response())
|
||||
}
|
||||
|
||||
if !connection.get_new_user_registration_enabled().await? {
|
||||
return Ok(Html(
|
||||
MessageTemplate::new_with_user(tr.t(Sentence::SignUpClosed), tr, user).render()?,
|
||||
)
|
||||
.into_response());
|
||||
}
|
||||
|
||||
// Validation of email and password.
|
||||
if form_data.email.parse::<Address>().is_err() {
|
||||
return error_response(SignUpError::InvalidEmail, &form_data, user, tr);
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue