Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 4 additions & 4 deletions cmd/laas/docs/docs.go
Original file line number Diff line number Diff line change
Expand Up @@ -832,7 +832,7 @@ const docTemplate = `{
"200": {
"description": "JWT token",
"schema": {
"$ref": "#/definitions/models.TokenResonse"
"$ref": "#/definitions/models.TokenResponse"
}
},
"401": {
Expand Down Expand Up @@ -1837,9 +1837,9 @@ const docTemplate = `{
],
"responses": {
"200": {
"description": " JWT token",
"description": "JWT token",
"schema": {
"$ref": "#/definitions/models.TokenResonse"
"$ref": "#/definitions/models.TokenResponse"
}
},
"401": {
Expand Down Expand Up @@ -3306,7 +3306,7 @@ const docTemplate = `{
}
}
},
"models.TokenResonse": {
"models.TokenResponse": {
"type": "object",
"properties": {
"data": {
Expand Down
8 changes: 4 additions & 4 deletions cmd/laas/docs/swagger.json
Original file line number Diff line number Diff line change
Expand Up @@ -825,7 +825,7 @@
"200": {
"description": "JWT token",
"schema": {
"$ref": "#/definitions/models.TokenResonse"
"$ref": "#/definitions/models.TokenResponse"
}
},
"401": {
Expand Down Expand Up @@ -1830,9 +1830,9 @@
],
"responses": {
"200": {
"description": " JWT token",
"description": "JWT token",
"schema": {
"$ref": "#/definitions/models.TokenResonse"
"$ref": "#/definitions/models.TokenResponse"
}
},
"401": {
Expand Down Expand Up @@ -3299,7 +3299,7 @@
}
}
},
"models.TokenResonse": {
"models.TokenResponse": {
"type": "object",
"properties": {
"data": {
Expand Down
8 changes: 4 additions & 4 deletions cmd/laas/docs/swagger.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -722,7 +722,7 @@ definitions:
required:
- text
type: object
models.TokenResonse:
models.TokenResponse:
properties:
data:
$ref: '#/definitions/models.Tokens'
Expand Down Expand Up @@ -1369,7 +1369,7 @@ paths:
"200":
description: JWT token
schema:
$ref: '#/definitions/models.TokenResonse'
$ref: '#/definitions/models.TokenResponse'
"401":
description: Incorrect username or password
schema:
Expand Down Expand Up @@ -2017,9 +2017,9 @@ paths:
- application/json
responses:
"200":
description: ' JWT token'
description: JWT token
schema:
$ref: '#/definitions/models.TokenResonse'
$ref: '#/definitions/models.TokenResponse'
"401":
description: Invalid or expired refresh token
schema:
Expand Down
16 changes: 8 additions & 8 deletions pkg/auth/auth.go
Original file line number Diff line number Diff line change
Expand Up @@ -797,9 +797,9 @@ func GetUser(c *gin.Context) {
// @Tags Users
// @Accept json
// @Produce json
// @Param user body models.UserLogin true "Login credentials"
// @Success 200 {object} models.TokenResonse "JWT token"
// @Failure 401 {object} models.LicenseError "Incorrect username or password"
// @Param user body models.UserLogin true "Login credentials"
// @Success 200 {object} models.TokenResponse "JWT token"
// @Failure 401 {object} models.LicenseError "Incorrect username or password"
// @Router /login [post]
func Login(c *gin.Context) {
var input models.UserLogin
Expand Down Expand Up @@ -887,7 +887,7 @@ func Login(c *gin.Context) {
c.JSON(http.StatusInternalServerError, er)
return
}
res := models.TokenResonse{
res := models.TokenResponse{
Status: http.StatusOK,
Data: *token,
}
Expand Down Expand Up @@ -944,9 +944,9 @@ func GetUserProfile(c *gin.Context) {
// @Tags Users
// @Accept json
// @Produce json
// @Param user body models.RefreshToken true "Refresh token payload"
// @Success 200 {object} models.TokenResonse " JWT token"
// @Failure 401 {object} models.LicenseError "Invalid or expired refresh token"
// @Param user body models.RefreshToken true "Refresh token payload"
// @Success 200 {object} models.TokenResponse "JWT token"
// @Failure 401 {object} models.LicenseError "Invalid or expired refresh token"
// @Router /refresh-token [post]
func VerifyRefreshToken(c *gin.Context) {
logger.LogInfo("VerifyRefreshToken called")
Expand Down Expand Up @@ -1031,7 +1031,7 @@ func VerifyRefreshToken(c *gin.Context) {

logger.LogInfo("VerifyRefreshToken completed successfully", zap.String("userID", userID.String()))

c.JSON(http.StatusOK, models.TokenResonse{
c.JSON(http.StatusOK, models.TokenResponse{
Status: http.StatusOK,
Data: *tokens,
})
Expand Down
4 changes: 2 additions & 2 deletions pkg/models/types.go
Original file line number Diff line number Diff line change
Expand Up @@ -358,7 +358,7 @@ type RefreshToken struct {
RefreshToken string `json:"refresh_token" example:"your_refresh_token_here"`
}

// TokenResonse represents the response structure for token generation API.
type TokenResonse ApiResponse[Tokens]
// TokenResponse represents the response structure for token generation API.
type TokenResponse ApiResponse[Tokens]

// can add all other response structures in similar manner
4 changes: 2 additions & 2 deletions tests/auth_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -228,7 +228,7 @@ func TestLoginAndRefreshTokenExpiry(t *testing.T) {
w := makeRequest("POST", "/login", loginPayload, false)
assert.Equal(t, http.StatusOK, w.Code)

var res models.TokenResonse
var res models.TokenResponse
if err := json.Unmarshal(w.Body.Bytes(), &res); err != nil {
t.Fatalf("failed to unmarshal login response: %v", err)
}
Expand Down Expand Up @@ -291,7 +291,7 @@ func TestLoginAndRefreshTokenExpiry(t *testing.T) {
w := makeRequest("POST", "/refresh-token", refreshPayload, false)
assert.Equal(t, http.StatusOK, w.Code)

var res models.TokenResonse
var res models.TokenResponse
if err := json.Unmarshal(w.Body.Bytes(), &res); err != nil {
t.Fatalf("failed to unmarshal refresh response: %v", err)
}
Expand Down
8 changes: 4 additions & 4 deletions tests/users_comprehensive_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -200,7 +200,7 @@ func TestUpdateProfile(t *testing.T) {
}
loginW := makeRequest("POST", "/login", loginData, false)
if loginW.Code == http.StatusOK {
var loginRes models.TokenResonse
var loginRes models.TokenResponse
if err := json.Unmarshal(loginW.Body.Bytes(), &loginRes); err == nil {
AuthToken = loginRes.Data.AccessToken
resetPassword := models.ProfileUpdate{
Expand All @@ -212,7 +212,7 @@ func TestUpdateProfile(t *testing.T) {
loginData.Userpassword = "fossy"
loginW2 := makeRequest("POST", "/login", loginData, false)
if loginW2.Code == http.StatusOK {
var loginRes2 models.TokenResonse
var loginRes2 models.TokenResponse
if err := json.Unmarshal(loginW2.Body.Bytes(), &loginRes2); err == nil {
AuthToken = loginRes2.Data.AccessToken
}
Expand Down Expand Up @@ -290,7 +290,7 @@ func TestVerifyRefreshToken(t *testing.T) {
t.Skipf("Cannot login to get refresh token: status %d", loginW.Code)
}

var loginRes models.TokenResonse
var loginRes models.TokenResponse
if err := json.Unmarshal(loginW.Body.Bytes(), &loginRes); err != nil {
t.Fatalf("Failed to parse login response: %v", err)
}
Expand All @@ -307,7 +307,7 @@ func TestVerifyRefreshToken(t *testing.T) {
w := makeRequest("POST", "/refresh-token", refreshReq, false)
assert.Equal(t, http.StatusOK, w.Code)

var res models.TokenResonse
var res models.TokenResponse
if err := json.Unmarshal(w.Body.Bytes(), &res); err != nil {
t.Errorf("Error unmarshalling JSON: %v", err)
return
Expand Down
Loading