From 87eb6a6b12e66efd9f31ba461d5d60d7bba41b78 Mon Sep 17 00:00:00 2001 From: nihonium Date: Tue, 25 Nov 2025 04:13:52 +0300 Subject: [PATCH] feat: signup return username --- auth/auth.gen.go | 6 +++--- auth/openapi-auth.yaml | 14 ++++---------- modules/auth/handlers/handlers.go | 7 +++---- 3 files changed, 10 insertions(+), 17 deletions(-) diff --git a/auth/auth.gen.go b/auth/auth.gen.go index adb2b06..b24deb5 100644 --- a/auth/auth.gen.go +++ b/auth/auth.gen.go @@ -116,9 +116,9 @@ type PostAuthSignInResponseObject interface { } type PostAuthSignIn200JSONResponse struct { - Error *string `json:"error"` - Success *bool `json:"success,omitempty"` - UserId *string `json:"user_id"` + Error *string `json:"error"` + UserId *string `json:"user_id"` + UserName *string `json:"user_name"` } func (response PostAuthSignIn200JSONResponse) VisitPostAuthSignInResponse(w http.ResponseWriter) error { diff --git a/auth/openapi-auth.yaml b/auth/openapi-auth.yaml index 913c000..0fe308c 100644 --- a/auth/openapi-auth.yaml +++ b/auth/openapi-auth.yaml @@ -59,29 +59,23 @@ paths: type: string format: password responses: + # This one also sets two cookies: access_token and refresh_token "200": description: Sign-in result with JWT - # headers: - # Set-Cookie: - # schema: - # type: array - # items: - # type: string - # explode: true - # style: simple content: application/json: schema: type: object properties: - success: - type: boolean error: type: string nullable: true user_id: type: string nullable: true + user_name: + type: string + nullable: true "401": description: Access denied due to invalid credentials content: diff --git a/modules/auth/handlers/handlers.go b/modules/auth/handlers/handlers.go index 9b9b0d3..7f675aa 100644 --- a/modules/auth/handlers/handlers.go +++ b/modules/auth/handlers/handlers.go @@ -78,7 +78,6 @@ func (s Server) PostAuthSignIn(ctx context.Context, req auth.PostAuthSignInReque } err := "" - success := true pass, ok := UserDb[req.Body.Nickname] if !ok || pass != req.Body.Pass { @@ -96,9 +95,9 @@ func (s Server) PostAuthSignIn(ctx context.Context, req auth.PostAuthSignInReque // Return access token; refresh token can be returned in response or HttpOnly cookie result := auth.PostAuthSignIn200JSONResponse{ - Error: &err, - Success: &success, - UserId: &req.Body.Nickname, + Error: &err, + UserId: &req.Body.Nickname, + UserName: &req.Body.Nickname, } return result, nil }