First page for first time logged in users

aastha3
Giga Contributor

Hi All ,

I have to set a security disclaimer page only who logins for the first time . Beneath that page there will be 2 check boxes Accept and Decline .

1. When user will click Accept it should redirect to the Service Portal homepage.

2. If Decline it should again go back to login page.

Security disclaimer page should get set after login on Service portal page.

Version : Istanbul .

Please provide help how to achieve this .

Thanks

1 ACCEPTED SOLUTION

anurag92
Kilo Sage

Hey Aastha,



Let's take it stepwise:



You might find an installation exit called: Login



It basically checks the username and password and based on a match, home page redirection applies. I have modified the script as belows (change highlighted in bold):



gs.include("PrototypeServer");




var Login = Class.create();


Login.prototype = {


  initialize : function() {


  },




              process : function() {


                  // the request is passed in as a global


                  var userName = request.getParameter("user_name");


                  var userPassword = request.getParameter("user_password");




                  var user = GlideUser;


                  var authed = user.authenticate(userName, userPassword);


                  if (authed) {


    var gr = new GlideRecord("sys_user");


    gr.addQuery('user_name',userName);


  gr.addNullQuery("last_login_time");



  gr.query();


  if (gr.next()) {


   





    gs.setRedirect("https://yourinstance/customer_service");


   


    }


    return user.getUser(userName);


    }


                  this.loginFailed();




                  return "login.failed";


              },




              loginFailed : function() {


    if (GlideController.exists("glide.ldap.error.connection")) {


    var ldapConnError = GlideController.getGlobal("glide.ldap.error.connection");


    if ( GlideStringUtil.notNil(ldapConnError) )


            GlideSession.get().addErrorMessage(ldapConnError);


    } else {


                          var message = GlideSysMessage.format("login_invalid");


                          GlideSession.get().addErrorMessage(message);


    }



            }


}



Here, gs.setRedirect("https://yourinstance/customer_service") is redirecting user to customer_service content site, you can have your own customer page here. Once, you are able to redirect to customer_service site, you can try creating your UI page with Custom Buttons. These custom buttons will redirect based on your requirement.


View solution in original post

8 REPLIES 8

anurag92
Kilo Sage

1. Create a UI page with 2 Buttons, 1 redirects to Portal, another redirects back to login page.



2. Create a login rule, that checks is 'Last Login Time' is empty, then redirect to that UI page.


This is how I would do in Helsinki. Step 2 can be performed by login properties also.


aastha3
Giga Contributor

Hi anurag92 ,



1. How to create a UI Page ?How to redirect ? Can you please provide some screenshots so that I can understand it in a better way .


2. How to create this login rule ? Where ? Please help me out with code.



Also can you confirm if this is possible in Istanbul Version.



Thanks


RajNow
ServiceNow Employee
ServiceNow Employee

Hi, have you checked the documentation for login_redirect - Redirect to Service Portal after login This should also be doable on Istanbul.


aastha3
Giga Contributor

Yes saw this but getting confused for the second part regarding the script include.


Please provide me the solution according to my requirement .