• Home
  • Features
  • Pricing
  • Docs
  • Announcements
  • Sign In

polyphony-chat / sonata / 16250718729

13 Jul 2025 03:34PM UTC coverage: 63.362% (-16.7%) from 80.109%
16250718729

push

github

bitfl0wer
feat(squashme): Further work on register endpoint with TODOs

9 of 20 branches covered (45.0%)

Branch coverage included in aggregate %.

0 of 12 new or added lines in 1 file covered. (0.0%)

28 existing lines in 7 files now uncovered.

285 of 444 relevant lines covered (64.19%)

418.69 hits per line

Source File
Press 'n' to go to next uncovered line, 'b' for previous

0.0
/src/api/auth/register.rs
1
use argon2::{
2
        Argon2,
3
        password_hash::{PasswordHash, PasswordHasher, SaltString, rand_core::OsRng},
4
};
5
use poem::{
6
        IntoResponse, handler,
7
        http::StatusCode,
8
        web::{Data, Json},
9
};
10

11
use crate::{
12
        api::models::{NISTPasswordRequirements, PasswordRequirements, RegisterSchema},
13
        database::{Database, LocalActor, tokens::TokenStore},
14
        errors::{Context, Errcode, Error, SonataApiError},
15
};
16

17
#[handler]
×
18
pub async fn register(
×
19
        Json(payload): Json<RegisterSchema>,
×
20
        Data(db): Data<&Database>,
×
21
        Data(token_store): Data<&TokenStore>,
×
22
) -> Result<impl IntoResponse, SonataApiError> {
×
23
        // TODO: Check if registration is currently allowed
24
        // TODO: Check if registration is currently in invite-only mode
NEW
25
        if LocalActor::by_local_name(db, &payload.local_name).await?.is_some() {
×
NEW
26
                return Err(SonataApiError::Error(Error::new(
×
NEW
27
                        Errcode::Duplicate,
×
NEW
28
                        Some(Context::new(Some("local_name"), Some(&payload.local_name), None)),
×
NEW
29
                )));
×
NEW
30
        }
×
NEW
31
        let password = NISTPasswordRequirements::verify_requirements(&payload.password)?;
×
NEW
32
        let salt = SaltString::generate(&mut OsRng);
×
NEW
33
        let argon2 = Argon2::default();
×
NEW
34
        let password_hash = argon2
×
NEW
35
                .hash_password(password.as_bytes(), &salt)
×
NEW
36
                .map_err(|_| Error::new(Errcode::Internal, None).into_api_error())?;
×
37
        // TODO: Check if registration is currently in whitelist mode
38
        // TODO: Store user etc. in DB
39
        Ok(poem::error::Error::from_status(StatusCode::NOT_IMPLEMENTED).into_response())
×
40
}
×
STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2026 Coveralls, Inc