mirror of
https://github.com/writefreely/writefreely
synced 2025-02-16 07:48:24 +00:00
Making changes per feedback
This commit is contained in:
parent
0aafd0c368
commit
b262fa144c
1 changed files with 9 additions and 19 deletions
|
@ -16,10 +16,10 @@ type genericOauthClient struct {
|
||||||
InspectLocation string
|
InspectLocation string
|
||||||
CallbackLocation string
|
CallbackLocation string
|
||||||
Scope string
|
Scope string
|
||||||
MapUserID string
|
MapUserID string
|
||||||
MapUsername string
|
MapUsername string
|
||||||
MapDisplayName string
|
MapDisplayName string
|
||||||
MapEmail string
|
MapEmail string
|
||||||
HttpClient HttpClient
|
HttpClient HttpClient
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -110,27 +110,17 @@ func (c genericOauthClient) inspectOauthAccessToken(ctx context.Context, accessT
|
||||||
|
|
||||||
// since we don't know what the JSON from the server will look like, we create a
|
// since we don't know what the JSON from the server will look like, we create a
|
||||||
// generic interface and then map manually to values set in the config
|
// generic interface and then map manually to values set in the config
|
||||||
var genericInterface interface{}
|
var genericInterface map[string]interface{}
|
||||||
if err := limitedJsonUnmarshal(resp.Body, infoRequestMaxLen, &genericInterface); err != nil {
|
if err := limitedJsonUnmarshal(resp.Body, infoRequestMaxLen, &genericInterface); err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
|
|
||||||
m := genericInterface.(map[string]interface{})
|
|
||||||
|
|
||||||
// map each relevant field in inspectResponse to the mapped field from the config
|
// map each relevant field in inspectResponse to the mapped field from the config
|
||||||
var inspectResponse InspectResponse
|
var inspectResponse InspectResponse
|
||||||
if (m[c.MapUserID] != nil) {
|
inspectResponse.UserID, _ = genericInterface[c.MapUserID].(string)
|
||||||
inspectResponse.UserID = m[c.MapUserID].(string)
|
inspectResponse.Username, _ = genericInterface[c.MapUsername].(string)
|
||||||
}
|
inspectResponse.DisplayName, _ = genericInterface[c.MapDisplayName].(string)
|
||||||
if (m[c.MapUsername] != nil) {
|
inspectResponse.Email, _ = genericInterface[c.MapEmail].(string)
|
||||||
inspectResponse.Username = m[c.MapUsername].(string)
|
|
||||||
}
|
|
||||||
if (m[c.MapDisplayName] != nil) {
|
|
||||||
inspectResponse.DisplayName = m[c.MapDisplayName].(string)
|
|
||||||
}
|
|
||||||
if (m[c.MapEmail] != nil) {
|
|
||||||
inspectResponse.Email = m[c.MapEmail].(string)
|
|
||||||
}
|
|
||||||
|
|
||||||
return &inspectResponse, nil
|
return &inspectResponse, nil
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Reference in a new issue