@@ -3,6 +3,7 @@ use crate::account_manager::{AccountManager, CreateAccountOpts};
33use crate :: apis:: com:: atproto:: server:: safe_resolve_did_doc;
44use crate :: auth_verifier:: UserDidAuthOptional ;
55use crate :: config:: ServerConfig ;
6+ use crate :: handle:: { normalize_and_validate_handle, HandleValidationContext , HandleValidationOpts } ;
67use crate :: models:: { ErrorCode , ErrorMessageResponse } ;
78use crate :: repo:: aws:: s3:: S3BlobStore ;
89use crate :: repo:: ActorStore ;
@@ -116,17 +117,19 @@ pub async fn server_create_account(
116117 Some ( access) if access. credentials . is_some ( ) => access. credentials . unwrap ( ) . iss ,
117118 _ => None ,
118119 } ;
119- let input = match validate_inputs_for_local_pds ( cfg, body. clone ( ) . into_inner ( ) , requester) . await
120- {
121- Ok ( res) => res,
122- Err ( e) => {
123- let internal_error = ErrorMessageResponse {
124- code : Some ( ErrorCode :: BadRequest ) ,
125- message : Some ( e. to_string ( ) ) ,
126- } ;
127- return Err ( status:: Custom ( Status :: BadRequest , Json ( internal_error) ) ) ;
128- }
129- } ;
120+ let input =
121+ match validate_inputs_for_local_pds ( cfg, id_resolver, body. clone ( ) . into_inner ( ) , requester)
122+ . await
123+ {
124+ Ok ( res) => res,
125+ Err ( e) => {
126+ let internal_error = ErrorMessageResponse {
127+ code : Some ( ErrorCode :: BadRequest ) ,
128+ message : Some ( e. to_string ( ) ) ,
129+ } ;
130+ return Err ( status:: Custom ( Status :: BadRequest , Json ( internal_error) ) ) ;
131+ }
132+ } ;
130133
131134 match inner_server_create_account ( input, sequencer, s3_config, id_resolver) . await {
132135 Ok ( response) => Ok ( Json ( response) ) ,
@@ -146,8 +149,9 @@ pub async fn server_create_account(
146149
147150pub async fn validate_inputs_for_local_pds (
148151 cfg : & State < ServerConfig > ,
152+ id_resolver : & State < SharedIdResolver > ,
149153 input : CreateAccountInput ,
150- _requester : Option < String > ,
154+ requester : Option < String > ,
151155) -> Result < CreateAccountInput > {
152156 let CreateAccountInput {
153157 email,
@@ -183,7 +187,16 @@ pub async fn validate_inputs_for_local_pds(
183187 if did. is_some ( ) {
184188 bail ! ( "Not yet allowing people to bring their own DID" ) ;
185189 } ;
186- // @TODO: Normalize handle as well
190+ let opts = HandleValidationOpts {
191+ handle : handle. clone ( ) ,
192+ did : requester. clone ( ) ,
193+ allow_reserved : None ,
194+ } ;
195+ let validation_ctx = HandleValidationContext {
196+ server_config : cfg,
197+ id_resolver,
198+ } ;
199+ let handle = normalize_and_validate_handle ( opts, validation_ctx) . await ?;
187200 if !super :: validate_handle ( & handle) {
188201 bail ! ( "Invalid handle" ) ;
189202 } ;
0 commit comments