lokenx / lokenx/plexrequests-meteor
server/methods/authentication/plexAuthentication.js: checkPlexUser() method undefined variable plexUsername
Nobody has claimed this yet.
- Dominant language
- JavaScript
- Stars
- 521
- Forks
- 129
- PR merge metrics
- No merged PRs in 30d
Description
I am evaluating the use of Plex Requests for the first time today. And during the setup (and testing) I have been experiencing an issue with doing any form of login (with username but without password authentication, mainly because most of my users are "Managed Users".
The error in question:
I20171216-00:22:08.726(-5)? Exception while invoking method 'checkPlexUser' TypeError: Cannot call method 'toLowerCase' of undefined
I20171216-00:22:08.726(-5)? at [object Object].Meteor.methods.checkPlexUser (server/methods/authentication/plexAuthentication.js:70:1)
I20171216-00:22:08.726(-5)? at maybeAuditArgumentChecks (livedata_server.js:1698:12)
I20171216-00:22:08.727(-5)? at livedata_server.js:708:19
I20171216-00:22:08.727(-5)? at [object Object]._.extend.withValue (packages/meteor/dynamics_nodejs.js:56:1)
I20171216-00:22:08.727(-5)? at livedata_server.js:706:40
I20171216-00:22:08.727(-5)? at [object Object]._.extend.withValue (packages/meteor/dynamics_nodejs.js:56:1)
I20171216-00:22:08.728(-5)? at livedata_server.js:704:46
I20171216-00:22:08.728(-5)? at tryCallTwo (/root/.meteor/packages/promise/.0.5.1.1550ocw++os+web.browser+web.cordova/npm/node_modules/meteor-promise/node_modules/promise/lib/core.js:45:5)
I20171216-00:22:08.728(-5)? at doResolve (/root/.meteor/packages/promise/.0.5.1.1550ocw++os+web.browser+web.cordova/npm/node_modules/meteor-promise/node_modules/promise/lib/core.js:171:13)
I20171216-00:22:08.729(-5)? at new Promise (/root/.meteor/packages/promise/.0.5.1.1550ocw++os+web.browser+web.cordova/npm/node_modules/meteor-promise/node_modules/promise/lib/core.js:65:3)
Debugging it a little further, and understand this is my first experience with Meteor (1.2.1) and I not well versed in JavaScript, you can see the issue is here in the first if statement block, it defined plexUsername variable but only if authentication password settings are enabled and then errors with undefined variable on the return() call. As a hack I added the else and it seems to fix the issue...
'checkPlexUser': function (plexLogin, plexPassword) {
check(plexLogin, String)
check(plexPassword, String)
if (Settings.find({}).fetch()[0].plexAuthenticationPASSWORDS) {
// If passwords are required check full login
var userInfo = Meteor.call('plexLogin', plexLogin, plexPassword)
var plexUsername = userInfo.username
}
else {
var plexUsername = plexLogin
}
//Update users in permissions
Meteor.call('permissionsUpdateUsers')
//Get friendslist and bannedlist
var friendsList = Meteor.call('getPlexFriendlist')
var bannedList = Permissions.find({permBANNED: true}, {fields: {_id: 0, permUSER: 1, permBANNED: 1}}).fetch()
//Remove banned users
for (var i = 0; i < bannedList.length; i++) {
friendsList.splice(friendsList.indexOf(bannedList[i].permUSER), 1)
}
return (friendsList.indexOf(plexUsername.toLowerCase()) > -1)
},
Contributor guide
No contributing guide indexed for this repository
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Read server/methods/authentication/plexAuthentication.js and trace checkPlexUser(), especially the password-required and username-only branches before the toLowerCase() call. Verify the behavior for both authentication settings: the method should no longer fail with an undefined variable and should return the expected user-membership result.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- javascript
- Domain
- authentication
- Issue type
- Bug
- Difficulty
- 2/5
- Estimated time
- 1-3 hours
- Activity status
- Stale
- Clarity
- Clearly specified
- Newbie friendliness
- 50/100