|
|
@@ -351,9 +351,8 @@ Slack.prototype.close = function() {
|
|
|
};
|
|
|
|
|
|
Slack.getUserId = function(code, redirectUri, cb) {
|
|
|
- Slack.getOauthToken(code, redirectUri, (token) => {
|
|
|
- if (token) {
|
|
|
- httpsRequest(SLACK_ENDPOINT+GETAPI.identityEmail +"?token="+token,
|
|
|
+ Slack.getOauthToken(code, redirectUri, (teamName, userId, token) => {
|
|
|
+ httpsRequest(SLACK_ENDPOINT+GETAPI.identityEmail +"?token="+token,
|
|
|
(status, resp) => {
|
|
|
if (status === 200 && resp.ok && resp.user && resp.user.email) {
|
|
|
cb(resp.user.id +'_' +resp.team.id);
|
|
|
@@ -361,17 +360,14 @@ Slack.getUserId = function(code, redirectUri, cb) {
|
|
|
cb(null);
|
|
|
}
|
|
|
});
|
|
|
- } else {
|
|
|
- cb(null);
|
|
|
- }
|
|
|
});
|
|
|
};
|
|
|
|
|
|
-Slack.getOauthToken = function(code, cb) {
|
|
|
+Slack.getOauthToken = function(code, redirectUri, cb) {
|
|
|
httpsRequest(SLACK_ENDPOINT+GETAPI.oauth
|
|
|
+"?client_id=" +config.services.Slack.clientId
|
|
|
+"&client_secret=" +config.services.Slack.clientSecret
|
|
|
- +"&redirect_uri=" +encodeURIComponent(config.rootUrl +"account/addservice/slack")
|
|
|
+ +"&redirect_uri=" +encodeURIComponent(redirectUri)
|
|
|
+"&code=" +code,
|
|
|
(status, resp) => {
|
|
|
if (status === 200 && resp.ok) {
|