Change how usernames, introduce display names.

This commit is contained in:
Paul Makles
2020-07-25 11:36:43 +02:00
parent c271054613
commit 5e59c553f3
9 changed files with 640 additions and 504 deletions

View File

@@ -53,6 +53,13 @@ pub fn create(info: Json<Create>) -> Response {
return Response::Conflict(json!({ "error": "Email already in use!" }));
}
if let Some(_) = col
.find_one(doc! { "username": info.username.clone() }, None)
.expect("Failed user lookup")
{
return Response::Conflict(json!({ "error": "Username already in use!" }));
}
if let Ok(hashed) = hash(info.password.clone(), 10) {
let access_token = gen_token(92);
let code = gen_token(48);
@@ -62,6 +69,7 @@ pub fn create(info: Json<Create>) -> Response {
"_id": Ulid::new().to_string(),
"email": info.email.clone(),
"username": info.username.clone(),
"display_name": info.username.clone(),
"password": hashed,
"access_token": access_token,
"email_verification": {
@@ -133,7 +141,7 @@ pub fn verify_email(code: String) -> Response {
email::send_welcome_email(target.to_string(), user.username);
Response::Redirect(
super::Redirect::to("https://example.com"), // ! FIXME; redirect to landing page
super::Redirect::to("https://app.revolt.chat"),
)
}
} else {