How to implement a Jira plugin that limit account name allowed at SignUp?

I want to write a Jira plugin that force people to use a certain username pattern when they register their accounts in Jira.

This is happening inside the form is displayed at `/secure/Signup!default.jspa` and is based on `$JIRA_INSTALL/atlassian-jira/views/signup.jsp` view.

Still, I have no idea what to put inside the plugin in order to make it fail, and also I do not want to go the easy way and implement this in JavaScript on the client, not because of security, just because I want a solution that does not brake when you upgrade Jira.

Update: I found that DefaultUserService.java - still I'm not sure how to implement this in a plugin and preferably writing a minimal amount of code.

Probably what I need is to throw a CreateExeption from inside the plugin, but what to implement inside the plugin to throw this?

2 answers

1 accepted

Because I don't want to loose my customization each time I'm doing a Jira update, I ended up writing a jQuery check. I know, it is not safe but it is better than loosing changes on updates.

You have to overwrite the Signup WebAction as described in this tutorial: http://www.j-tricks.com/1/post/2010/10/extending-jira-actions.html

In this case it should be the following definition in your atlassian-plugin.xml:

<webwork1 key="new-signup" name="New Signup" class="java.lang.Object">
        <actions>
            <action name="com.foo.bar.NewSignup" alias="Signup">
                <view name="success">/views/signup-success.jsp</view>
                <view name="limitexceeded">/views/signup-limitexceeded.jsp</view>
                <view name="alreadyloggedin">/views/signup-alreadyloggedin.jsp</view>
                <view name="error">/views/signup.jsp</view>
                <view name="input">/views/signup.jsp</view>
                <view name="modebreach">/views/modebreach.jsp</view>
                <view name="systemerror">/views/signup-systemerror.jsp</view>
            </action>
        </actions>
    </webwork1>

Then you have to extend com.atlassian.jira.web.action.user.Signup and validate the username:

@Override
    protected void doValidation() {

        if (getUsername().matches("mypattern")){
            addError("username", getText("mytext"));
        }

        super.doValidation();
    }

Then the user sees a red error message at the username field.

Suggest an answer

Log in or Join to answer
Community showcase
Sarah Schuster
Posted Jan 29, 2018 in Jira

What are common themes you've seen across successful & failed Jira Software implementations?

Hey everyone! My name is Sarah Schuster, and I'm a Customer Success Manager in Atlassian specializing in Jira Software Cloud. Over the next few weeks I will be posting discussion topics (8 total) to ...

2,759 views 11 18
Join discussion

Atlassian User Groups

Connect with like-minded Atlassian users at free events near you!

Find a group

Connect with like-minded Atlassian users at free events near you!

Find my local user group

Unfortunately there are no AUG chapters near you at the moment.

Start an AUG

You're one step closer to meeting fellow Atlassian users at your local meet up. Learn more about AUGs

Groups near you
Atlassian Team Tour

Join us on the Team Tour

We're bringing product updates and pro tips on teamwork to ten cities around the world.

Save your spot