diff --git a/docs/docs.go b/docs/docs.go index ac3cd4e5..435015a7 100644 --- a/docs/docs.go +++ b/docs/docs.go @@ -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" }, diff --git a/docs/swagger.json b/docs/swagger.json index bcfa5e86..a8c2b653 100644 --- a/docs/swagger.json +++ b/docs/swagger.json @@ -1946,9 +1946,15 @@ "access_token": { "type": "string" }, + "display_name": { + "type": "string" + }, "expires_at": { "type": "string" }, + "role": { + "type": "string" + }, "token_type": { "type": "string" }, diff --git a/docs/swagger.yaml b/docs/swagger.yaml index 692432b5..97b7dd77 100644 --- a/docs/swagger.yaml +++ b/docs/swagger.yaml @@ -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: diff --git a/internal/handlers/auth.go b/internal/handlers/auth.go index 851108c2..de389181 100644 --- a/internal/handlers/auth.go +++ b/internal/handlers/auth.go @@ -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, }) } diff --git a/packages/web/src/pages/login/index.vue b/packages/web/src/pages/login/index.vue index 7c7656be..3f39bb7c 100644 --- a/packages/web/src/pages/login/index.vue +++ b/packages/web/src/pages/login/index.vue @@ -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'