Forum


HomeHomePremiumPremiumDevelopmentDevelopmentWhat differs when a user is not logged in?What differs when a user is not logged in?
Previous
 
Next
New Post
8/28/2015 5:00 AM
 

I noticed some strange behavior today and I was curious what would cause it. When I'm developing sometimes I have to AFK for a while which logs me out. What I noticed was that my javascript files appear to stop communicating like they do when I am logged in. Although I'm working with an angular app I feel like it has something to do with file permissions. I have my app defined in one file and a controller linked to that app in another. It all works properly if all my code is contained in a single js file but doesn't work at all when moved to separate ones and no user is logged in. I checked and all the files are properly passed to the user they simply don't function properly.

Any thoughts? Thanks.

 
New Post
8/31/2015 4:27 AM
 

Michael,

The only issues I have heard regarding javascript behaving differently when logged in or out usually was an issue with knockout.  That is because the developer might have tested while logged in and knockout script tag is on the page for the admin ribbon and didn't realize knockout reference may not exist when not logged in.

I haven't heard of file permissions causing js issues.  If you are looking at the resources in Firebug as a logged out user, can you directly access the angular script files?  If not, are you getting a 401 or something when they are serverd up to the client?

 
New Post
8/31/2015 8:24 AM
 

Thanks for the reply. Here's what my module's files look like:

Then inside cobApp.js and cobControllers.js:

These function perfectly while logged in as you can see in an example of what my page looks like:

This is a radio check that opens/hides my form options and it's working while logged in but once the user logs out:

The app breaks cause my controller is undefined. Using the chrome web developer tools I can find all my js files being passed to the client. I cleared the cache and a hard reload of the page to make sure everything was been passed.

All my code is being passed properly. This is what the preview looks like:

It's just odd to me that not being logged in causes these problems. It's not a real issue right now but it might be if I build modules for registration or log ins or something where the user isn't logged.

https://docs.angularjs.org/error/ng/areq?p0=CoBCtrl&p1=not%20a%20function,%20got%20undefined

https://docs.angularjs.org/error/$injector/nomod?p0=cobApp

Maybe it's something I'm doing wrong or am unaware about. Let me know any thoughts you might have. Thanks!

 
New Post
9/1/2015 7:05 AM
 

I believe I've found the root cause. I have a few javascript files we've packaged and installed to our dnn environments. One is a packaged version of angular bootstrap ui and the other is a module for setting up dnn api calls so that code doesn't have to be re-written for every module that needs it. Now there's two main issues that caused problems. The first is the order that I register the files in my code behind. Here's the incorrect way to do it:

You might be thinking 'what could possibly be wrong with this?' Well it's not obvious (at all) even when you look into the scripts themselves. My app definition adds my dnn api module as a dependency. However it's my controller script that implements it. I can't be sure exactly why this happens but since scripts that implement dependencies aren't loaded first they don't function properly. Simply load those first like so:

And the problem magically goes away.

The second problem that I have not been able to find a way around is with my api module. When the user is not logged in that file or its functionality does not exist. This causes the controller to not function or become undefined or unavailable. I was talking to co-worker and from what I gathered that module doesn't exist? From what he said $.ServicesFramework doesn't exist when you're not logged in and that causes the module to fail causing my scripts to crash. Haven't found a work around for this yet.

Thanks.

 
Previous
 
Next
HomeHomePremiumPremiumDevelopmentDevelopmentWhat differs when a user is not logged in?What differs when a user is not logged in?



Try FREE
30 days money back guaranteed