fix(auth): align user info fields and fix response parsing (#4)

This commit is contained in:
BBQ
2026-01-29 15:20:56 -08:00
committed by GitHub
parent e5f32bc7e0
commit d72e7b42f1
5 changed files with 24 additions and 4 deletions
+6
View File
@@ -1955,9 +1955,15 @@ const docTemplate = `{
"access_token": {
"type": "string"
},
"display_name": {
"type": "string"
},
"expires_at": {
"type": "string"
},
"role": {
"type": "string"
},
"token_type": {
"type": "string"
},
+6
View File
@@ -1946,9 +1946,15 @@
"access_token": {
"type": "string"
},
"display_name": {
"type": "string"
},
"expires_at": {
"type": "string"
},
"role": {
"type": "string"
},
"token_type": {
"type": "string"
},
+4
View File
@@ -142,8 +142,12 @@ definitions:
properties:
access_token:
type: string
display_name:
type: string
expires_at:
type: string
role:
type: string
token_type:
type: string
user_id:
+4
View File
@@ -34,6 +34,8 @@ type LoginResponse struct {
TokenType string `json:"token_type"`
ExpiresAt string `json:"expires_at"`
UserID string `json:"user_id"`
Role string `json:"role"`
DisplayName string `json:"display_name"`
Username string `json:"username"`
}
@@ -109,6 +111,8 @@ func (h *AuthHandler) Login(c echo.Context) error {
ExpiresAt: expiresAt.Format(time.RFC3339),
UserID: userID,
Username: user.Username,
Role: fmt.Sprintf("%v", user.Role),
DisplayName: user.DisplayName.String,
})
}
+4 -4
View File
@@ -140,10 +140,10 @@ const login = form.handleSubmit(async (values) => {
url: '/auth/login',
method: 'post',
data: { ...values }
},false)
const data = loginState?.data?.data
if (data?.token && data?.user) {
LoginHandle(data.user, data.token)
})
const data = loginState?.data
if (data?.access_token) {
LoginHandle({ id: data.user_id, username: data.username, role: data.role, displayName: data.display_name }, data.access_token)
}
router.replace({
name:'Main'