How to Authenticate a Service-Now local User from a Custom made page by capturing the Username and Password from the Page created with two input fields ?

Satyasarat Pato
Tera Guru

I'm trying to authenticate a Service-Now local user from the page i have created from the Pages in Content Management with two inputs as username and password.

I'm finding trouble in how to authenticate the user from the page i created.

kindly help me in the Process.

3 REPLIES 3

srinivasthelu
Tera Guru

Hi Sarath,



I normally against implementing custom login pages. but if you wanted to know how the OOB Login page works. Below is installation exit responsible for OOB login authentication.



https://instance.service-now.com/sys_installation_exit.do?sys_id=7cfa46450a0a0aa90056aa3101b0bd7c&sy...



Thanks


Srinivas


Hi Srinivas,



Thanks for your time in replying.



I got the Dynamic Login page where i can edit according to my requirements and placing it as a dynamic content in my page where i'm using sites.


The problem is that now i need to redirect to a page which i have created in PAGES eg,. '/cms/Sarath.do' . I'm not able to identify the redirection in the following code



<?xml version="1.0" encoding="utf-8" ?>


<j:jelly trim="false" xmlns:j="jelly:core" xmlns:g="glide" xmlns:j2="null" xmlns:g2="null">


<g:evaluate>


        var loginAction = "login.do";


        var logoutAction = "logout.do";


        var tran = GlideTransaction.get();


        if (tran.isVirtual()) {


                loginAction = "../" + loginAction;


                logoutAction = "../" + logoutAction;


        }


        var pageLink = new GlideCMSPageLink().getPageLink(current_page.getID()).substring(3);


        var documentKey = RP.getParameterValue('sysparm_document_key');


        if (documentKey)


                pageLink += '?sysparm_document_key=' + documentKey;


        pageLink = GlideStringUtil.urlEncode(pageLink);




    </g:evaluate>




    <j:if test="${!gs.getSession().isLoggedIn()}">


    <div class="content_list_title">${gs.getMessage('Login')}</div>  


<form name="loginPage" id="loginPage" action="${loginAction}" method="post">


<g:inline template="output_messages.xml" />


  <table>


                               


                              <input type="hidden" name="sys_action" value="sysverb_login" />


                              <input type="hidden" name="sysparm_goto_url" value="logout_redirect.do?sysparm_url=${pageLink}" />


                              <input type="hidden" name="sysparm_login_url" value="logout_redirect.do?sysparm_url=${pageLink}" />




  <tr>


  <td><label for="user_name">${gs.getMessage('User name')}:</label></td>


  </tr>


  <tr>


  <td><input type="text" id="user_name" name="user_name" value="" autocomplete="off"/></td>


  </tr>


  <tr>


  <td><label for="user_password">${gs.getMessage('Password')}:</label></td>


  </tr>


  <tr>


  <td><input type="password" id="user_password" name="user_password"/></td>


  </tr>


  <j:if test="${gs.getProperty('glide.ui.forgetme') != 'true'}">


  <tr id="remembermeoption" style="display: notnone">


  <td>


  <script> function setCheckBox(e) { if (e.checked) { e.value = "true"; } else { e.value = "false"; } } </script>


  <input type="checkbox" id="remember_me" name="remember_me" value="true" checked="true" onClick="setCheckBox(this);"/>


                                                              <label for="remember_me">${gs.getMessage('Remember me')}</label>


  </td>


  </tr>


                              <tr>


                                              <td>


<button class="content_login" type="submit" > ${gs.getMessage('Login')} </button>


                                              </td>


                              </tr>


                           


  </j:if>


</table>


</form>


    </j:if>


    <j:if test="${gs.getSession().isLoggedIn()}">


    <form name="logoutPage" action="${logoutAction}">


<div class="content_list_title">


<a class="content_logout" onclick="logoutPage.submit()"> ${gs.getMessage('Logout')}:</a>$[SP]


${gs.getUserName()}


</div>                    


    </form>


      <div style="margin-bottom:5px;padding-left:5px" >


      ${gs.getMessage('Welcome!')}


          <j:if test="${gs.hasRole('admin')}">


                  <a class="content_logout" href="../navpage.do?direct=true"> ${gs.getMessage('[Frameset UI]')} </a>


            </j:if>


      </div>


    </j:if>


</j:jelly>



Kindly help me solve the problem for redirection while log in and log out from the above code.



Thanks in Advance !!



Regards,


Sarath


justin_drysdale
Mega Guru

I'd advise you to be careful if you are capturing login info.