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

Alias Username fetch on CheckCredential calls #2827

Open
wants to merge 4 commits into
base: master
Choose a base branch
from
Open
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
32 changes: 31 additions & 1 deletion src/cloud.js
Original file line number Diff line number Diff line change
Expand Up @@ -282,13 +282,15 @@ Cloud.prototype.checkCredentials = function (onSuccess, onError, response) {
if (user.username) {
myself.username = user.username;
myself.verified = user.verified;
myself.previous_username_admin = user.previous_username_admin;
}
if (onSuccess) {
onSuccess.call(
null,
user.username,
user.role,
response ? JSON.parse(response) : null
response ? JSON.parse(response) : null,
user.previous_username_admin
Copy link
Collaborator

Choose a reason for hiding this comment

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

It's hard to tell where the on success callback is defined, but this doesn't feel like it should come after the response body. IMO it should come before -- though ideally we use keyword args here.

);
}
},
Expand Down Expand Up @@ -327,6 +329,34 @@ Cloud.prototype.logout = function (onSuccess, onError) {
);
};

Cloud.prototype.logoutAlias = function (onSuccess, onError) {
var myself = this;
this.getCurrentUser(
function (user) {
if (user.username && user.previous_username_admin) {
myself.login(
user.previous_username_admin,
0, // password is irrelevant
Copy link
Collaborator

Choose a reason for hiding this comment

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

This should be null, to clearly indicate there's no password. If that causes a problem, then we should use ''.

Copy link
Author

Choose a reason for hiding this comment

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

0 was used during the alias login section of the website as well

I can try null or ' ' and see what happens

false, // ignored
Copy link
Collaborator

Choose a reason for hiding this comment

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

Doesn't this unset the users previous setting? If not can you add a more clear comment about why?

Copy link
Author

Choose a reason for hiding this comment

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

I'll make more clear in the comments that I saved the previous user setting of the alias and use that, so no matter what choice is ticked here it won't be used

function (username, role, previous_username_admin, response) {
alert(
response.message,
function () {
onSuccess.call();
sessionStorage.previous_username_admin = previous_username_admin;
sessionStorage.username = username;
sessionStorage.role = role;
}
);
},
onError
);
}
},
onError
);
}

Cloud.prototype.login = function (
username,
password,
Expand Down