NewSpring / Rock-Plugins

NewSpring plugins for Rock RMS
http://www.rockrms.com/
3 stars 5 forks source link

Fix client machine name lookup #42

Closed dcs619 closed 9 years ago

ghost commented 10 years ago

My theory is the problem is here:

if ( !CurrentKioskId.HasValue || UserBackedUp || CurrentGroupTypeIds == null ) { // #DEBUG, may be the local machine var kiosk = new DeviceService( new RockContext() ).Queryable().Where( d => d.Name == Environment.MachineName ).FirstOrDefault(); if ( kiosk != null ) { CurrentKioskId = kiosk.Id; BindGroupTypes(); } else { maWarning.Show( "This device has not been set up for check-in.", ModalAlertType.Warning ); lbOk.Visible = false; return; } }

Unless the kiosk has been run before, CurrentGroupTypeIds is always null so we are always falling into this if statement. Then the device is looked up by name (why???) and it always matches the cswebserver device so we are allowed to run attended checkin (because it think we are debugging locally?). If I change the name of the webserver device I get the maWarning.Show as expected because my device name is now cen-benwiley and doesn't match cen-webserver. So that's the problem... and I'm not sure how it's supposed to work so I don't know what to change

richarddubay commented 10 years ago

Right. So first things first, that DEBUG section should probably be removed, leaving just the error. If we don't have CurrentGroupTypeIds from a previous checkin, or we don't get a CurrentKioskId returned from the AttemptKioskMatchByIpOrName() function, then we want it to error.

Now, because of that, we really want the IpOrName function to return the CurrentKioskId (which it's not doing). For some reason it seems to be returning null (at least for me), so the CurrentKioskId never gets set. The GetByIpAddress function is part of the Rock core, so you can't really step through it in the plugin.

What I was going to do was to open up the Rock project, and step through the exact same portion of code (the AttemptKioskMatchByIpOrName function - which is on their Admin page) while running their version of checkin to see if it would return something different than what I was getting in our plugin. They are doing the exact same thing, so I really don't expect different results. But in particular paying special attention to what they were doing in the GetByIpAddress function.

What it comes down to is there might be a different/better way to get the IP address of the kiosk/computer which will give us the results that we're looking for. None of us are sure at this point what that is, So...you know, research. :)

dcs619 commented 9 years ago

Issue fixed.