Skip to content
This repository was archived by the owner on Jan 2, 2026. It is now read-only.

Commit cf3917e

Browse files
author
bitfl0wer
committed
feat: Registration is done!
1 parent a153b5c commit cf3917e

File tree

1 file changed

+7
-2
lines changed

1 file changed

+7
-2
lines changed

src/api/auth/register.rs

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,10 +3,11 @@ use argon2::{
33
password_hash::{PasswordHasher, SaltString, rand_core::OsRng},
44
};
55
use poem::{
6-
IntoResponse, handler,
6+
IntoResponse, Response, ResponseBuilder, handler,
77
http::StatusCode,
88
web::{Data, Json},
99
};
10+
use serde_json::json;
1011

1112
use crate::{
1213
api::models::{NISTPasswordRequirements, PasswordRequirements, RegisterSchema},
@@ -38,5 +39,9 @@ pub async fn register(
3839
// TODO: Check if registration is currently in whitelist mode
3940
let new_user =
4041
LocalActor::create(db, &payload.local_name, password_hash.serialize().as_str()).await?;
41-
Ok(poem::error::Error::from_status(StatusCode::NOT_IMPLEMENTED).into_response())
42+
let token_hash =
43+
token_store.generate_upsert_token(&new_user.unique_actor_identifier, None).await?;
44+
Ok(Response::builder()
45+
.status(StatusCode::CREATED)
46+
.body(json!({"token": token_hash}).to_string()))
4247
}

0 commit comments

Comments
 (0)