Display custom message to user in Service Portal login page when account is locked out

Community Alums
Not applicable

I have customized installation exit to modify the error message for failed login attempt. It is working as expected in the main console, but service portal login still displays old message.

Main console:

find_real_file.png

Service Portal:

find_real_file.png

I have verified that the new installation exit is invoked for service portal login, but message is incorrect. I would like to display different messages based on account locked_out status. Please assist.

1 ACCEPTED SOLUTION

Community Alums
Not applicable

I was able to fix the issue by adding custom code to server script:

if(input.flag == "true") {
var gr = new GlideRecord("sys_user");
gr.addQuery('user_name', input.username);
gr.query();

if(gr.next()) {
if(gr.locked_out) {
data.customMsg = gs.getMessage("crt_account_locked");
//input.username = '';
}
else {
data.customMsg = gs.getMessage("login_invalid");
}
}
else {
data.customMsg = gs.getMessage("login_invalid");
}
return;
}

Modified the client script as per the screenshot shared by Naveen, but with little more customization:

else {
// wrong username or password
/*c.message = response.data.message;
c.password = "";
c.username = "";*/
c.data.flag = "true";
c.server.update().then(function() {
c.message = c.data.customMsg;
c.password = "";
c.data.username = "";
});
angular.element("#username").focus();
}

 

Finally add .data to ng-model of username in HTML: ng-model="c.data.username"

View solution in original post

8 REPLIES 8

Hello, have this problem now. I copied this but was wondering if there is anything I need to insert On my part, I copied the code exactly thanks

Hi Akshaya,

 

I am facing this same issue but the code you provided doesn't seem to work (but it looks like it should) - can you please assist? Where do you place the code in the widget, etc. may be helpful.


Thank you,

Annie

AD4
Mega Contributor

Hi Annie, 

Place the server script code at the end of your server script. Update the client controller as Akshaya outlined above and do not forget to update all areas in the body HTML template with "c.username" to "c.data.username". That should work, good luck 🙂 

Hi @Community Alums ,

This is working for /sp portal but its not working for /csm portal.

I have checked both portals are using same 'Login' widget still its not working for CSM portal.

Can you please guide me what should I do this to work for CSM portal too?