Forums

Articles
Create
cancel
Showing results for 
Search instead for 
Did you mean: 

Showing a message to the user upon authentication

Tore Gunnar Larsen May 16, 2019

I've attempted to use Scriptrunner to warn users when their e-mail is set to a dummy value.
To solve this problem I've created a Custom Script Listener that listens for UserAuthenticatedEvent and runs a script that has the following code:

import com.onresolve.scriptrunner.runner.util.UserMessageUtil
UserMessageUtil.success("This is a test message.")

But I never see any messages. Is there something I'm doing wrong or is there a better way of getting a message to a user that can't receive e-mails?

1 answer

0 votes
PD Sheehan
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
June 5, 2019

I think the necessary javascript resources that UserMessageUtil likely leverage are probably not available in the initial context after login. 

This Util class was intended to be called from workflows and issue related events. 

You could make a feature suggestion to adaptavist for them to expand the context where this component is exposed.

You could use scriptrunner script fragments  to insert a message in the header:

Location: atl.header  (or somewhere else ... you can play around with location context)
Key: something unique for you
menu text: nothing
weight: nothing
condition: 

import com.atlassian.jira.component.ComponentAccessor
def user = ComponentAccessor.getJiraAuthenticationContext().getLoggedInUser()
user.emailAddress == "yourDefaultEmail@domain.com"

script:

 writer.write('<div style="background-color: yellow">Your profile still has a dummy email address. Update it from the profile menu.</div>')

Suggest an answer

Log in or Sign up to answer