File tree Expand file tree Collapse file tree 1 file changed +8
-3
lines changed
Expand file tree Collapse file tree 1 file changed +8
-3
lines changed Original file line number Diff line number Diff line change @@ -34,7 +34,7 @@ use validator::Validate;
3434use crate :: {
3535 error:: Error ,
3636 routes:: auth:: VERIFICATION_EXPIRATION_DAYS ,
37- utils:: { self , get_connection, web_block_unpacked } ,
37+ utils:: { self , get_connection} ,
3838 AppState ,
3939} ;
4040
@@ -138,7 +138,7 @@ pub async fn register(
138138 let user_mail = data. email . to_lowercase ( ) ;
139139 let mail_cpy = user_mail. clone ( ) ;
140140
141- web_block_unpacked ( move || {
141+ match web :: block ( move || {
142142 use db_connector:: schema:: users:: dsl:: * ;
143143
144144 match users
@@ -153,7 +153,12 @@ pub async fn register(
153153
154154 Ok ( ( ) )
155155 } )
156- . await ?;
156+ . await {
157+ Ok ( Ok ( _) ) => ( ) ,
158+ Ok ( Err ( Error :: UserAlreadyExists ) ) => return Ok ( HttpResponse :: Created ( ) ) ,
159+ Ok ( Err ( _) ) => return Err ( Error :: InternalError . into ( ) ) ,
160+ Err ( _) => return Err ( Error :: InternalError . into ( ) ) ,
161+ }
157162
158163 let key_hash = match hash_key ( & data. login_key ) {
159164 Ok ( hash) => hash,
You can’t perform that action at this time.
0 commit comments