Forum Discussion

iftomkins's avatar
10 years ago

Creating a redirect for users without a login name, but user.login has a mystery default value

I'm trying to create a redirect on the page initialization page, which will run of the user does not have a login name. Our community is private, and to view it at all you have to be logged in via SSO. However, we don't force users to choose a login name until they click an action, such as "Reply".

 

For users who have not chosen a login name, the user.login value is not not null or blank, but instead it is defaulting to SunsetRunner, which is the value we've input in the Admin settings field Users > Profile defaults > For deleted member accounts, display this username (screenshot included below).

 

The code below shows my intent. It currently works but is not solid, because I do not know how the value "SunsetRunner" is getting pulled in. If the user's login is SunsetRunner, we know they have not chosen a username/login yet (or have a deleted account), so we can redirect them to the registration page.

 

How do I figure out if the user has chosen a username/login name yet? Can I do it by comparing the user.login value to something that's not a static string?

 

<#-- Profile page redirect -->
<#if (page.name?lower_case == "viewprofilepage") > 
         <#if user.login == ‘SunsetRunner’ >
             <#assign currUrl = http.request.url />
             ${http.response.setRedirectUrl("/t5/user/ssoregistrationpage?dest_url=" + currUrl)}
	 </#if>
</#if>

Screenshot 2015-07-09 11.26.41.png

  • ChiaraS's avatar
    ChiaraS
    10 years ago

    hi iftomkins

     

    you can try the following to target partially registered users:

     

    <#if user.anonymous == false && user.registration.complete == false >
    ...
    </#if>

3 Replies

  • iftomkins - As I was looking through it, I couldn't find any flag being set for the users who have not created the login name on the community. However, while checking the V2 API, I found that the SSO users who have not created a username yet does not get any data in the V2 response. I am not sure if this would work for your case because the username is already being set from the profile defaults as 'SunsetRunner', but it is worth checking anyways. Here is the V2 resource I am referring to.

     

    One of our communities also has the SSO, but I did not find the option for setting a default name for deleted user.

     

    Capture.PNG

     

    I tried the following V2 calls:

     

    SELECT registration_data.status FROM users WHERE id = '47' - This is the registered user with login name created in the community.

    SELECT registration_data.status FROM users WHERE id = '386' - This is the user who has SSO a/c but haven't yet created a username in community.

     

    the first call returns the status as "status" : "fully-registered"

     

    {
      "status" : "success",
      "message" : "",
      "http_code" : 200,
      "data" : {
        "type" : "users",
        "list_item_type" : "user",
        "size" : 1,
        "items" : [ {
          "type" : "user",
          "registration_data" : {
            "type" : "registration_data",
            "status" : "fully-registered"
          }
        } ]
      },
      "metadata" : { }
    }

    The second one:

     

    {
      "status" : "success",
      "message" : "",
      "http_code" : 200,
      "data" : {
        "type" : "users",
        "list_item_type" : "user",
        "size" : 0,
        "items" : [ ]
      },
      "metadata" : { }
    }

     

    If it is same in your case, I believe you have got the solution for this. I hope this helps.

  • ChiaraS's avatar
    ChiaraS
    Lithium Alumni (Retired)
    10 years ago

    hi iftomkins

     

    you can try the following to target partially registered users:

     

    <#if user.anonymous == false && user.registration.complete == false >
    ...
    </#if>