Merge pull request #14149 from influxdata/return-oauth-id-for-user

feat(me): return oauth id with user object
pull/14211/head
lukevmorris 2019-06-26 15:08:39 -07:00 committed by GitHub
commit 350f72c296
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 8 additions and 11 deletions

View File

@ -6088,6 +6088,8 @@ components:
id:
readOnly: true
type: string
oauthID:
type: string
name:
type: string
status:

View File

@ -180,21 +180,15 @@ func (h *UserHandler) handleGetMe(w http.ResponseWriter, r *http.Request) {
return
}
var id influxdb.ID
switch s := a.(type) {
case *influxdb.Session:
id = s.UserID
case *influxdb.Authorization:
id = s.UserID
}
id := a.GetUserID()
user, err := h.UserService.FindUserByID(ctx, id)
b, err := h.UserService.FindUserByID(ctx, id)
if err != nil {
EncodeError(ctx, err, w)
return
}
if err := encodeResponse(ctx, w, http.StatusOK, newUserResponse(b)); err != nil {
if err := encodeResponse(ctx, w, http.StatusOK, newUserResponse(user)); err != nil {
EncodeError(ctx, err, w)
return
}

View File

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