mirror of
https://github.com/meteor/meteor.git
synced 2026-05-02 03:01:46 -04:00
accounts-weibo: make sure uid indeed parses to an integer
This commit is contained in:
@@ -2,6 +2,12 @@ Accounts.oauth.registerService('weibo', 2, function(query) {
|
||||
|
||||
var response = getTokenResponse(query);
|
||||
var uid = parseInt(response.uid, 10);
|
||||
|
||||
// different parts of weibo's api seem to expect numbers, or strings
|
||||
// for uid. let's make sure they're both the same.
|
||||
if (response.uid !== uid + "")
|
||||
throw new Error("Expected 'uid' to parse to an integer: " + JSON.stringify(response));
|
||||
|
||||
var identity = getIdentity(response.access_token, uid);
|
||||
|
||||
return {
|
||||
@@ -41,8 +47,8 @@ var getTokenResponse = function (query) {
|
||||
"HTTP Error " + result.statusCode + ": " + result.content);
|
||||
}
|
||||
|
||||
// result.headers["content-type"] is 'text/plain;charset=UTF-8', so the http
|
||||
// package doesn't automatically populate result.data
|
||||
// result.headers["content-type"] is 'text/plain;charset=UTF-8', so
|
||||
// the http package doesn't automatically populate result.data
|
||||
result.data = JSON.parse(result.content);
|
||||
|
||||
if (result.data.error) { // if the http response was a json object with an error attribute
|
||||
|
||||
Reference in New Issue
Block a user