Skip to content

Commit

Permalink
feat: add struct login response
Browse files Browse the repository at this point in the history
  • Loading branch information
Diego Moraes committed Oct 13, 2023
1 parent 63882a6 commit 8742e3a
Showing 1 changed file with 11 additions and 1 deletion.
12 changes: 11 additions & 1 deletion api/auth.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,11 @@ type loginRequest struct {
Password string `json:"password" binging:"required"`
}

type loginResponse struct {
UserID int32 `json:"user_id"`
Token string `json:"token"`
}

type Claims struct {
Username string `json:"username"`
jwt.RegisteredClaims
Expand Down Expand Up @@ -69,5 +74,10 @@ func (server *Server) login(ctx *gin.Context) {
return
}

ctx.JSON(http.StatusOK, generatedTokenToString)
res := &loginResponse{
UserID: user.ID,
Token: generatedTokenToString,
}

ctx.JSON(http.StatusOK, res)
}

0 comments on commit 8742e3a

Please sign in to comment.