feat: signup return username
This commit is contained in:
parent
e64e770783
commit
a225d1fb60
3 changed files with 10 additions and 17 deletions
|
|
@ -116,9 +116,9 @@ type PostAuthSignInResponseObject interface {
|
||||||
}
|
}
|
||||||
|
|
||||||
type PostAuthSignIn200JSONResponse struct {
|
type PostAuthSignIn200JSONResponse struct {
|
||||||
Error *string `json:"error"`
|
Error *string `json:"error"`
|
||||||
Success *bool `json:"success,omitempty"`
|
UserId *string `json:"user_id"`
|
||||||
UserId *string `json:"user_id"`
|
UserName *string `json:"user_name"`
|
||||||
}
|
}
|
||||||
|
|
||||||
func (response PostAuthSignIn200JSONResponse) VisitPostAuthSignInResponse(w http.ResponseWriter) error {
|
func (response PostAuthSignIn200JSONResponse) VisitPostAuthSignInResponse(w http.ResponseWriter) error {
|
||||||
|
|
|
||||||
|
|
@ -56,29 +56,23 @@ paths:
|
||||||
type: string
|
type: string
|
||||||
format: password
|
format: password
|
||||||
responses:
|
responses:
|
||||||
|
# This one also sets two cookies: access_token and refresh_token
|
||||||
"200":
|
"200":
|
||||||
description: Sign-in result with JWT
|
description: Sign-in result with JWT
|
||||||
# headers:
|
|
||||||
# Set-Cookie:
|
|
||||||
# schema:
|
|
||||||
# type: array
|
|
||||||
# items:
|
|
||||||
# type: string
|
|
||||||
# explode: true
|
|
||||||
# style: simple
|
|
||||||
content:
|
content:
|
||||||
application/json:
|
application/json:
|
||||||
schema:
|
schema:
|
||||||
type: object
|
type: object
|
||||||
properties:
|
properties:
|
||||||
success:
|
|
||||||
type: boolean
|
|
||||||
error:
|
error:
|
||||||
type: string
|
type: string
|
||||||
nullable: true
|
nullable: true
|
||||||
user_id:
|
user_id:
|
||||||
type: string
|
type: string
|
||||||
nullable: true
|
nullable: true
|
||||||
|
user_name:
|
||||||
|
type: string
|
||||||
|
nullable: true
|
||||||
"401":
|
"401":
|
||||||
description: Access denied due to invalid credentials
|
description: Access denied due to invalid credentials
|
||||||
content:
|
content:
|
||||||
|
|
|
||||||
|
|
@ -78,7 +78,6 @@ func (s Server) PostAuthSignIn(ctx context.Context, req auth.PostAuthSignInReque
|
||||||
}
|
}
|
||||||
|
|
||||||
err := ""
|
err := ""
|
||||||
success := true
|
|
||||||
|
|
||||||
pass, ok := UserDb[req.Body.Nickname]
|
pass, ok := UserDb[req.Body.Nickname]
|
||||||
if !ok || pass != req.Body.Pass {
|
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
|
// Return access token; refresh token can be returned in response or HttpOnly cookie
|
||||||
result := auth.PostAuthSignIn200JSONResponse{
|
result := auth.PostAuthSignIn200JSONResponse{
|
||||||
Error: &err,
|
Error: &err,
|
||||||
Success: &success,
|
UserId: &req.Body.Nickname,
|
||||||
UserId: &req.Body.Nickname,
|
UserName: &req.Body.Nickname,
|
||||||
}
|
}
|
||||||
return result, nil
|
return result, nil
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue