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

aastha3
Giga Contributor

kumamano   deepakgarg Anyone of you can help me out .



Please let me know


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.


aastha3
Giga Contributor

Hi anurag92,



I have made changes as per your suggestions .


1. What changes I should do here ?


    var gr = new GlideRecord("sys_user");


    gr.addQuery('user_name',userName);


  gr.addNullQuery("last_login_time");



  gr.query();


  if (gr.next()) {



2. Also Please let me know how to set up a UI Page . I have never created a UI Page before.


      Below is the disclaimer page that should be in that UI Page.


find_real_file.png



3. Please it will be really helpful if you can provide how to create   UI Page , Codes .



Thanks


Hi Anurag,


The solution proposed by you worked for us but this is the case where you are using portal login through 'username' and 'password'.Can you please suggest what could be done in case of sso by identity provider