Skip to content

Commit

Permalink
fix: x-authorization-token header
Browse files Browse the repository at this point in the history
  • Loading branch information
VaalaCat committed Jun 7, 2023
1 parent bbf4c89 commit bf2a174
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 5 deletions.
5 changes: 3 additions & 2 deletions common/const.go
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@ const (
)

const (
UIDKey = "uid"
AuthorizationKey = "authorization"
UIDKey = "uid"
AuthorizationKey = "authorization"
AuthorizationHeaderKey = "X-Authorization-Token"
)
2 changes: 2 additions & 0 deletions services/auth/login.go
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,8 @@ func LoginEndpoint(c *gin.Context) {
}

authz.SetToken(c, token)

c.Header(common.AuthorizationHeaderKey, token)
common.RespOK(c, common.RespMsgOK, defs.LoginResponse{
Status: common.RespCodeOK,
Token: token})
Expand Down
7 changes: 4 additions & 3 deletions www/src/api/http.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,10 @@ instance.interceptors.request.use((request) => {
return request
})

axios.interceptors.response.use((response) => {
if (response.headers?.['X-Authorization-Token'] && !localStorage['token']) {
localStorage['token'] = response.headers['X-Authorization-Token']
instance.interceptors.response.use((response) => {
console.log(response.headers?.["x-authorization-token"])
if (response.headers?.["x-authorization-token"]) {
localStorage['token'] = response.headers['x-authorization-token']
}
return response
})
Expand Down

0 comments on commit bf2a174

Please sign in to comment.