Skip to content

Commit

Permalink
changing response type of auth routes
Browse files Browse the repository at this point in the history
  • Loading branch information
mlinder10 committed Jul 3, 2024
1 parent a0a9f35 commit cd371ce
Showing 1 changed file with 9 additions and 2 deletions.
11 changes: 9 additions & 2 deletions routes/auth.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,13 @@ import (
"github.com/gin-gonic/gin"
)

type responseBody struct {
ID string `json:"id"`
Username string `json:"username"`
Email string `json:"email"`
Token string `json:"token"`
}

type loginBody struct {
Email string `json:"email"`
Password string `json:"password"`
Expand All @@ -32,7 +39,7 @@ func Login(c *gin.Context) {
return
}

c.JSON(http.StatusOK, user.Token)
c.JSON(http.StatusOK, responseBody{user.ID.String(), user.Username, user.Email, user.Token.String()})
}

type registerBody struct {
Expand Down Expand Up @@ -60,5 +67,5 @@ func Register(c *gin.Context) {
return
}

c.JSON(http.StatusOK, user.Token)
c.JSON(http.StatusCreated, responseBody{user.ID.String(), user.Username, user.Email, user.Token.String()})
}

0 comments on commit cd371ce

Please sign in to comment.