Alpha Video Training
Results 1 to 4 of 4

Thread: How do I get current user group in javascript client side in persistent login template

  1. #1
    Member
    Real Name
    Amit lohogaonkar
    Join Date
    Mar 2017
    Location
    NJ
    Posts
    428

    Default How do I get current user group in javascript client side in persistent login template

    Below sample code is working in persistent login mobile template on my android mobile(mobile app/not a web app) which is great! but I need additional condition to get current user security group on client side and then activate panel based on a group. How do I get current user group in javascript client side in persistent login template?(not server side)

    if(token != '' ) {
    //token is present and not blank
    //(we don't know if the token is valid or has not expired as the token cannot be decoded on the client-side)
    //(we will only find out if the token is valid when an ajax callback is made to the server)

    //since token was present you can take the user directly to the application panel [PANEL_APPLICATION].
    //must also add the token to the UX state object so that it gets sent back on all Ajax callbacks
    {dialog.object}.stateInfo['token'] = token;
    //alert(Context.Security.GetRoles()); here I want to get user group(player or coach) and then based on this I will activate panel(player embedded ux panel or coach embedded ux panel)

    {dialog.object}.panelSetActive('PANEL_APPLICATION',false);

    //TIP: If you want to implement a client-side login, you could take the user to the client-side login panel
    //rather than to the [PANEL_APPLICATION] panel. If the user then successfully authenticates at the client-side login panel
    //you would then set focus to the [PANEL_APPLICATION] Panel.
    } else {
    //token not found or is blank - user must log in
    {dialog.object}.panelSetActive('PANEL_LOGIN');

    }
    Last edited by amitloh; 07-05-2017 at 09:01 PM.

  2. #2
    Member
    Real Name
    Amit lohogaonkar
    Join Date
    Mar 2017
    Location
    NJ
    Posts
    428

    Default Re: How do I get current user group in javascript client side in persistent login template

    I found a workaround-
    I set serverside-
    e.control.Label1 = Context.Security.GetUserRoles()
    and then

    var mygroup={dialog.Object}.getValue('Label1');
    if(mygroup == 'Players')
    {dialog.object}.panelSetActive('PANEL_APPLICATION',false);

  3. #3
    "Certified" Alphaholic
    Real Name
    David Kates
    Join Date
    Apr 2008
    Location
    Unionville, ON
    Posts
    7,562

    Default Re: How do I get current user group in javascript client side in persistent login template

    You need to allow for a user to be a member of more than one group. If your user belongs to more than one group (e.g. Players and Admin) your logic will fail.

  4. #4
    Member
    Real Name
    Amit lohogaonkar
    Join Date
    Mar 2017
    Location
    NJ
    Posts
    428

    Default Re: How do I get current user group in javascript client side in persistent login template

    Thanks David! I almost missed this. For now It will work as user is only player or coach but I will add contains js condition later.
    Its amazing that with few lines of code now I have login, reset, forget, menu and persistent login in alpha.
    Now I am moving to core functions. Hope to have few lines in core too.

Similar Threads

  1. Client Side Group Break Sort
    By gregincolumbus in forum Mobile & Browser Applications
    Replies: 8
    Last Post: 03-08-2017, 07:08 PM
  2. Using SQL CTE data in a Client Side Template
    By mikeallenbrown in forum Mobile & Browser Applications
    Replies: 0
    Last Post: 09-28-2015, 11:34 AM
  3. Client Side Template and jSON help
    By mikeallenbrown in forum Mobile & Browser Applications
    Replies: 2
    Last Post: 08-25-2015, 02:22 PM
  4. Loop Through ALL Rows on Client Side (Not current page rows) afterSearch (Javascript)
    By aburningflame in forum Application Server Version 11 - Web/Browser Applications
    Replies: 1
    Last Post: 09-10-2013, 05:02 PM
  5. Add option to select user security group in create new user dialog template?
    By LukeS in forum Application Server Version 11 - Web/Browser Applications
    Replies: 0
    Last Post: 02-27-2012, 02:47 PM

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •