Skip to content
Open
Changes from all commits
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
fix(getUserInfo): using userStatus.isPremium
  • Loading branch information
soraliu committed Nov 30, 2020
commit 6ab87becb59a9ee82ab512ea0da37e57a4bed2dc
11 changes: 7 additions & 4 deletions lib/plugins/leetcode.js
Original file line number Diff line number Diff line change
Expand Up @@ -408,7 +408,9 @@ plugin.getUserInfo = function(cb) {
'{',
' user {',
' username',
' isCurrentUserPremium',
' }',
' userStatus {',
' isPremium',
' }',
'}'
].join('\n'),
Expand All @@ -422,7 +424,8 @@ plugin.getUserInfo = function(cb) {
if (e) return cb(e);

const user = body.data.user;
return cb(null, user);
const userStatus = body.data.userStatus;
return cb(null, user, userStatus);
});
};

Expand Down Expand Up @@ -514,9 +517,9 @@ plugin.getUser = function(user, cb) {
log.warn('Failed to retrieve user favorites: ' + e);
}

plugin.getUserInfo(function(e, _user) {
plugin.getUserInfo(function(e, _user, _userStatus) {
if (!e) {
user.paid = _user.isCurrentUserPremium;
user.paid = _userStatus.isPremium
user.name = _user.username;
}
session.saveUser(user);
Expand Down