Add oauthID to the user interface instead of session

pull/14149/head
Palak Bhojani 2019-06-26 11:29:40 -07:00
parent 1c3b92dacb
commit b67ea62562
3 changed files with 6 additions and 26 deletions

View File

@ -188,17 +188,9 @@ func (h *UserHandler) handleGetMe(w http.ResponseWriter, r *http.Request) {
return return
} }
switch s := a.(type) { if err := encodeResponse(ctx, w, http.StatusOK, newUserResponse(user)); err != nil {
case *influxdb.Session: EncodeError(ctx, err, w)
if err := encodeResponse(ctx, w, http.StatusOK, newUserResponseFromSession(user, s)); err != nil { return
EncodeError(ctx, err, w)
return
}
case *influxdb.Authorization:
if err := encodeResponse(ctx, w, http.StatusOK, newUserResponse(user)); err != nil {
EncodeError(ctx, err, w)
return
}
} }
} }
@ -333,18 +325,6 @@ func newUserResponse(u *influxdb.User) *userResponse {
} }
} }
type userResponseFromSession struct {
*userResponse
OAuthID string `json:"oauthID,omitempty"`
}
func newUserResponseFromSession(u *influxdb.User, s *influxdb.Session) *userResponseFromSession {
return &userResponseFromSession{
userResponse: newUserResponse(u),
OAuthID: s.OAuthID,
}
}
// handleGetUsers is the HTTP handler for the GET /api/v2/users route. // handleGetUsers is the HTTP handler for the GET /api/v2/users route.
func (h *UserHandler) handleGetUsers(w http.ResponseWriter, r *http.Request) { func (h *UserHandler) handleGetUsers(w http.ResponseWriter, r *http.Request) {
ctx := r.Context() ctx := r.Context()

View File

@ -40,7 +40,6 @@ type Session struct {
ExpiresAt time.Time `json:"expiresAt"` ExpiresAt time.Time `json:"expiresAt"`
UserID ID `json:"userID,omitempty"` UserID ID `json:"userID,omitempty"`
Permissions []Permission `json:"permissions,omitempty"` Permissions []Permission `json:"permissions,omitempty"`
OAuthID string `json:"oauthID,omitempty"`
} }
// Expired returns an error if the session is expired. // Expired returns an error if the session is expired.

View File

@ -6,8 +6,9 @@ import (
// User is a user. 🎉 // User is a user. 🎉
type User struct { type User struct {
ID ID `json:"id,omitempty"` ID ID `json:"id,omitempty"`
Name string `json:"name"` Name string `json:"name"`
OAuthID string `json:"oauthID,omitempty"`
} }
// Ops for user errors and op log. // Ops for user errors and op log.