mirror of
https://github.com/memohai/Memoh.git
synced 2026-04-27 07:16:19 +09:00
fix(auth): align user info fields and fix response parsing (#4)
This commit is contained in:
@@ -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"
|
||||
},
|
||||
|
||||
@@ -1946,9 +1946,15 @@
|
||||
"access_token": {
|
||||
"type": "string"
|
||||
},
|
||||
"display_name": {
|
||||
"type": "string"
|
||||
},
|
||||
"expires_at": {
|
||||
"type": "string"
|
||||
},
|
||||
"role": {
|
||||
"type": "string"
|
||||
},
|
||||
"token_type": {
|
||||
"type": "string"
|
||||
},
|
||||
|
||||
@@ -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:
|
||||
|
||||
@@ -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,
|
||||
})
|
||||
}
|
||||
|
||||
|
||||
@@ -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'
|
||||
|
||||
Reference in New Issue
Block a user