Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[FIX] Fix iframe login API response (issue #8145) #8146

Merged
merged 2 commits into from
Sep 18, 2017
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 8 additions & 8 deletions packages/rocketchat-iframe-login/iframe_client.js
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ class IframeLogin {

HTTP.call(this.apiMethod, this.apiUrl, options, (error, result) => {
console.log(error, result);
if (result && result.data && result.data.token) {
if (result && result.data && (result.data.token || result.data.loginToken)) {
this.loginWithToken(result.data, (error, result) => {
if (error) {
this.reactiveIframeUrl.set(iframeUrl);
Expand All @@ -82,27 +82,27 @@ class IframeLogin {
});
}

loginWithToken(token, callback) {
loginWithToken(tokenData, callback) {
if (!this.enabled) {
return;
}

if (Match.test(token, String)) {
token = {
token
if (Match.test(tokenData, String)) {
tokenData = {
tokenData
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This part should be:

tokenData = {
  token: tokenData
}

};
}

console.log('loginWithToken');

if (token.loginToken) {
return Meteor.loginWithToken(token.loginToken, callback);
if (tokenData.loginToken) {
return Meteor.loginWithToken(tokenData.loginToken, callback);
}

Accounts.callLoginMethod({
methodArguments: [{
iframe: true,
token: token.token
token: tokenData.token
}],
userCallback: callback
});
Expand Down