Welcome to the DNN Community Forums, your preferred source of online community support for all things related to DNN.
In order to participate you must be a registered DNNizen

HomeHomeDNN Open Source...DNN Open Source...Module ForumsModule ForumsForumForumgetting user information from JS (CLIENT-SIDE)getting user information from JS (CLIENT-SIDE)
Previous
 
Next
New Post
1/12/2018 1:36 PM
 

Good morning,

We are building a module for a client to run in an instance of that depends deeply on how the user is logged (email / rrss) and if it is first login / etc...
also the session expiration time (if it is still valid) and if it needs to reinitialise the session
and we need to do, as much as possible on client side with JS (instance works mostly as SPA, and has a WebApp) 

Looking in client side, we see as available resources for our purpose:

Login Cookie, where is set the expiration time (SESSION in case of RRSS)

HTML values of <input name="__dnnVariable" ...>

dnn.js with  dnn.getVar("dnn_current_userid")

the thing is:

the cookie is set to HTTPonly, so not access from JS 
can this cookie be set, so, it is accesible from JS ??, is there any configuration for that?

HTML values, not always consisten, sometimes loads with " and sometimes with `
is this inconsistency a bug?, or does it have some reasoning?
(when value is using  the value is indeed not a valid JSON, but the dnn.js has a built function that makes:
     
a.value = a.value.substring(1).replace(/`/g, '"')  )

dnn.js is actually not being loaded on client instance, client not sure why, but in his instance seems unnecesary
is there a documentation for this file? / is that supposed to be used by module developers or is it an internal thing of DNN?
should be possible, as it is the case, for this file to be optional ?

UserName
is there a CLIENT-SIDE function or feature that respond with the UserName and other user properties ?

 

of course we can build our own CS server side code, but we would like to be aligned as much as possible with DNN best practices.

are we in the right track ?

 

 

 
New Post
1/19/2018 8:30 PM
 
I've gone through the built-in Dnn client-side scripts and I could not locate anything that would give you the information you're looking for. However, I do have an alternate method you could try. Pass the UserInfo object to the client side. Here's my code:

view.ascx:
-------------------------------------------------------------------------------------------------------------------------------
    data-module-id="<%= ModuleId %>"
    data-tab-id="<%= TabId %>"
    data-module-name="<%= ModuleContext.Configuration.DesktopModule.ModuleName %>"
    data-user-info='<%=UserInfo.ToJson() %>'>

-------------------------------------------------------------------------------------------------------------------------------

This gives you access to the current user's entire profile. You could create your own class object with just the properties you want but this is about as simple as it gets.
Edit: you need to add this header to the top of the file for ToJson() to work. <%@ Import Namespace="DotNetNuke.Common.Utilities" %>
 
Previous
 
Next
HomeHomeDNN Open Source...DNN Open Source...Module ForumsModule ForumsForumForumgetting user information from JS (CLIENT-SIDE)getting user information from JS (CLIENT-SIDE)


These Forums are dedicated to discussion of DNN Platform and Evoq Solutions.

For the benefit of the community and to protect the integrity of the ecosystem, please observe the following posting guidelines:

  1. No Advertising. This includes promotion of commercial and non-commercial products or services which are not directly related to DNN.
  2. No vendor trolling / poaching. If someone posts about a vendor issue, allow the vendor or other customers to respond. Any post that looks like trolling / poaching will be removed.
  3. Discussion or promotion of DNN Platform product releases under a different brand name are strictly prohibited.
  4. No Flaming or Trolling.
  5. No Profanity, Racism, or Prejudice.
  6. Site Moderators have the final word on approving / removing a thread or post or comment.
  7. English language posting only, please.

Content Layout

Subscribe to DNN Digest

Subscribe to DNN Digest

DNN Digest is our monthly email newsletter. It highlights news and content from around the DNN ecosystem, such as new modules and themes, messages from leadership, blog posts and notable tweets. Keep your finger on the pulse of the ecosystem by subscribing.  


Copyright 2018 by DNN Corp Terms of Use Privacy
What is Liquid Content?
Find Out
What is Liquid Content?
Find Out
What is Liquid Content?
Find Out