plexrequests-meteor
plexrequests-meteor copied to clipboard
server/methods/authentication/plexAuthentication.js: checkPlexUser() method undefined variable plexUsername
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)
},
Sorry I just realized someone else documented the same "solution" in the other report (Internal Server Error 500).
Yeah, I'm reworking the user permissions and authentication code to not be so fragile. May take me a few days to get done so I'm the meantime I recommend requiring users fully authenticate.
On Fri, Dec 15, 2017, 11:40 PM gdavidp [email protected] wrote:
Sorry I just realized someone else documented the same "solution" in the other report (Internal Server Error 500).
— You are receiving this because you are subscribed to this thread. Reply to this email directly, view it on GitHub https://github.com/lokenx/plexrequests-meteor/issues/515#issuecomment-352162982, or mute the thread https://github.com/notifications/unsubscribe-auth/AQbPDVOGVCPzIznIf_mChvpacdhJcWkHks5tA1fogaJpZM4REPAt .