@@ -35,7 +35,7 @@ pub struct SignInParams {
35
35
pub struct InvalidCredentials {
36
36
#[ schema( example = 404 ) ]
37
37
pub status : u16 ,
38
- #[ schema( example = "Invalid credentials " ) ]
38
+ #[ schema( example = "INVALID_CREDENTIALS " ) ]
39
39
pub message : String ,
40
40
}
41
41
@@ -45,9 +45,10 @@ pub struct InvalidCredentials {
45
45
tag = "Auth" ,
46
46
path = "/auth/sign_in" ,
47
47
responses(
48
- ( status = 200 , description = "Token Response" , body = AuthTokens ) ,
49
- ( status = 404 , description = "Invalid Credentials" , body = InvalidCredentials ) ,
50
- ( status = 500 , description = "Internal Server Error" , body = InternalErrorSchema ) ,
48
+ ( status = 200 , description = "Token response" , body = AuthTokens ) ,
49
+ ( status = 404 , description = "Invalid credentials" , body = InvalidCredentials ) ,
50
+ ( status = 422 , description = "Request body validation errors" , body = ValidationErrorSchema ) ,
51
+ ( status = 500 , description = "Internal server error" , body = InternalErrorSchema ) ,
51
52
)
52
53
) ]
53
54
pub async fn sign_in (
@@ -65,18 +66,16 @@ pub async fn sign_in(
65
66
. filter ( users:: Column :: Email . eq ( sign_in_params. email ) )
66
67
. one ( & db)
67
68
. await
68
- . map_err ( |_err| {
69
- AppError :: new ( StatusCode :: INTERNAL_SERVER_ERROR , "INTERNAL_SERVER_ERROR" )
70
- } ) ?;
69
+ . map_err ( |_err| AppError :: new ( StatusCode :: NOT_FOUND , "INVALID_CREDENTIALS" ) ) ?;
71
70
72
71
if let Some ( user) = db_user {
73
72
if !verify_password ( sign_in_params. password , & user. encrypted_password ) ? {
74
- return Err ( AppError :: new ( StatusCode :: NOT_FOUND , "Invalid Credentials " ) ) ;
73
+ return Err ( AppError :: new ( StatusCode :: NOT_FOUND , "INVALID_CREDENTIALS " ) ) ;
75
74
}
76
75
let token = create_jwt ( user. id ) ?;
77
76
return Ok ( Json ( token) ) ;
78
77
}
79
- return Err ( AppError :: new ( StatusCode :: NOT_FOUND , "Invalid Credentials " ) ) ;
78
+ return Err ( AppError :: new ( StatusCode :: NOT_FOUND , "INVALID_CREDENTIALS " ) ) ;
80
79
}
81
80
82
81
#[ derive( Serialize , Deserialize , Validate , ToSchema ) ]
@@ -101,8 +100,8 @@ pub struct SignUpParams {
101
100
path = "/auth/sign_up" ,
102
101
responses(
103
102
( status = 201 , description = "User created with token response" , body = AuthTokens ) ,
104
- ( status = 422 , description = "Validation Errors " , body = ValidationErrorSchema ) ,
105
- ( status = 500 , description = "Internal Server Error " , body = InternalErrorSchema ) ,
103
+ ( status = 422 , description = "Request body validation errors " , body = ValidationErrorSchema ) ,
104
+ ( status = 500 , description = "Internal server error " , body = InternalErrorSchema ) ,
106
105
)
107
106
) ]
108
107
pub async fn sign_up (
@@ -188,9 +187,9 @@ pub struct CurrentUser {
188
187
tag = "Auth" ,
189
188
path = "/auth/me" ,
190
189
responses(
191
- ( status = 200 , description = "Current user" , body = CurrentUser ) ,
190
+ ( status = 200 , description = "Current user info " , body = CurrentUser ) ,
192
191
( status = 401 , description = "Unauthenticated" , body = UnauthorizedSchema ) ,
193
- ( status = 500 , description = "Internal Server Error " , body = InternalErrorSchema ) ,
192
+ ( status = 500 , description = "Internal server error " , body = InternalErrorSchema ) ,
194
193
) ,
195
194
security( ( "bearer_auth" = [ ] ) )
196
195
) ]
0 commit comments