Forums

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

Ask question the first time a user login on JIRA

Michael Danielsson
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 Champions.
May 16, 2018

Hi

How do I do to trigger a dialog the first time a user login?

I would like to be able to ask a few questions and save the answers.

Regards,

  Michael D

1 answer

1 accepted

0 votes
Answer accepted
Alexey Matveev
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 Champions.
May 16, 2018

You would need to develop a plugin which would include a servlet-filter module

Michael Danielsson
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 Champions.
May 16, 2018

Can you explain some more what to do and give some example?

Alexey Matveev
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 Champions.
May 16, 2018

Servlet filters intercept calls to resource and can redirect calls to another resource. That is exactly what you need. You can read about servlet filters here:

http://www.oracle.com/technetwork/java/filters-137243.html

https://developer.atlassian.com/server/jira/platform/servlet-filter/

Michael Danielsson
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 Champions.
May 16, 2018

Thanks for pointing me in the right direction.
I have been able to create a servlet filter.
However I would appreciate if you can me me some more hints regarding how to only trigger this filter when a user is logging in for the first time and how to redirect to a page where I can ask the questions.

Alexey Matveev
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 Champions.
May 16, 2018

In the servlet filter you should check how many times the user has logged in. You can use LoginInfo class for it. You can find more info here:

https://community.atlassian.com/t5/Jira-questions/Script-Runner-Last-Login-Date/qaq-p/311789

below you can find out how you redirect to another page

https://stackoverflow.com/questions/5308801/how-to-redirect-in-a-servlet-filter

The redirect page must be your own servlet or webwork.

Michael Danielsson
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 Champions.
May 17, 2018

Thanks 

I have now been able to trigger the filter when I'm about to access a specific servlet,   <url-pattern>/plugins/servlet/myservlet</url-pattern>, and I can redirect to another servlet.

However I want to trigger the redirection only when the user login and its the first login for that user. After the information collection the user shall be redirected to the place where he was going in the first place.
The problem is not to get information from LoginInfo. It is to get the filter to trigger only when a user login and after collection of data redirect to the original url.

Alexey Matveev
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 Champions.
May 17, 2018

when you define the servlet-filter tag, you provide the class, which is called. In this class you define if it is the first time to login or not.

 <servlet-filter name="Hello World Servlet" key="helloWorld" class="com.example.myplugins.helloworld.HelloWorldFilter" location="before-dispatch" weight="200">
        <description>Says Hello World, Australia or your name.</description>
        <url-pattern>/helloworld</url-pattern>
        <init-param>
            <param-name>defaultName</param-name>
            <param-value>Australia</param-value>
        </init-param>
        <dispatcher>REQUEST</dispatcher>
        <dispatcher>FORWARD</dispatcher>
    </servlet-filter>

in this example the class would be com.example.myplugins.helloworld.HelloWorldFilter

in the url-pattern you need to provide a pattern for the url, which is called after you push the login button.

Alexey Matveev
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 Champions.
May 17, 2018

Also if you have Jira source code , you can have a look at the source code of the jira-onboarding-assets-plugin. A different approach is used there.

Michael Danielsson
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 Champions.
May 17, 2018

To trigger the Hello World Servlet you need to enter an url like plugins/servlet/helloworld
What I would like is to find something to put as url-pattern and that will trigger when the user login. Then I can check if it is the first login.

Alexey Matveev
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 Champions.
May 17, 2018

Go to the login page. Open developer tools in your browser. Enter username, password and push the Log In button. In the developer tools you will see the url.

Michael Danielsson
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 Champions.
May 17, 2018

I have looked into the jira code but I can't understand it.

 

If I put /login.jsp as url-pattern I can catch it.

However I would like to catch it after login so I know the the user has logged in and if the user login from the dashboard I can't catch it.

Alexey Matveev
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 Champions.
May 17, 2018

You should catch the response from the page, not the request. You can read more here:

https://www.leveluplunch.com/java/tutorials/034-modify-html-response-using-filter/

Michael Danielsson
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 Champions.
May 18, 2018

Thanks for all your help. I have not managed to get what I want but I will try again.

I still haven't been able to figure out how to trigger the filter after the user has logged in.

Suggest an answer

Log in or Sign up to answer