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

This widget could not be displayed.

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.

This widget could not be displayed.

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 Sign up to answer
Community showcase
Posted Tuesday in Jira

What modern development practices are at the heart of how your team delivers software?

Hey Community mates! Claire here from the Software Product Marketing team. We all know software development changes rapidly, and it's often tough to keep up. But from our research, we've found the h...

157 views 1 3
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