How to Reset Captcha with the API for a User

We Have a request in our JIRA service desk portal for users to reset thier Captcha when they have locked themselves out of the tool.   (this typically happens when account passwords have changed and automation has not been updated).  To day this is manual process that we are looking to automate.    

We would like to create a script for allowing users to reset thier capcha for JIRA, Confluence and Bitbucket.  does anyone know if this is possible via the API Calls?  I could not find the API calls on developer.atlassian.com

 

1 answer

This widget could not be displayed.

 

 

This may seem an odd question, but if you're going to let users disable their own CAPTCHA, why not just turn it off?

 

That said, I'm pretty sure that you can use the LoginManager for this.

 

import com.atlassian.jira.component.ComponentAccessor
import com.atlassian.jira.security.login.LoginManager

def loginManager = ComponentAccessor.getComponent(LoginManager)
loginManager.resetFailedLoginCount(user)

You'll need to set the user variable according to some logic -- obviously you don't want to get the logged in user! You could get the user via the userManager, like...

 

def user = ComponentAccessor.userManager.getUserByName("username")

How to set the username string will depend on the context you're working in (REST Endpoint, Workflow Function, etc.).

Since we use an identity provider, the user does not have access to the Atalssian login screens and need an alternative method to reset captcha. 

 

therefore, we want to create an automated script to reset captcha that a  unloack a user when a ticket is submittd. 

 

I tried the above code but its seems its throwing error.

 

This is what tried:

import com.atlassian.jira.component.ComponentAccessor
import com.atlassian.jira.security.login.LoginManager
def user = ComponentAccessor.userManager.getUserByName("wtuscan")
def loginManager = ComponentAccessor.getComponent(LoginManager)
loginManager.resetFailedLoginCount(user)

Result:

Error
No signature of method: com.atlassian.jira.security.login.LoginManagerImpl.resetFailedLoginCount() is applicable for argument types: (com.atlassian.jira.user.DelegatingApplicationUser) values: [wtuscan(wtuscan)] Possible solutions: resetFailedLoginCount(com.atlassian.crowd.embedded.api.User)


groovy.lang.MissingMethodException: No signature of method: com.atlassian.jira.security.login.LoginManagerImpl.resetFailedLoginCount() is applicable for argument types: (com.atlassian.jira.user.DelegatingApplicationUser) values: [wtuscan(wtuscan)]
Possible solutions: resetFailedLoginCount(com.atlassian.crowd.embedded.api.User)
 at Script18.run(Script18.groovy:5)

I am trying to figure this out as well, were you able to resolve these errors?

Hey guys, 

In which version of JIRA you are ? Jonny's answer is the right way in JIRa 7. 

From your error Abyakta ot seems you are in a JIRA v6.* 

regards, Thanos. 

yes i am trying in Jira 6

Suggest an answer

Log in or Sign up to answer
Atlassian Summit 2018

Meet the community IRL

Atlassian Summit is an excellent opportunity for in-person support, training, and networking.

Learn more
Community showcase
Published 7 hours ago in Bitbucket

Branch Management with Bitbucket

As a project manager, I have discovered that different developers want to bring their previous branching method with them when they join the team. Some developers are used to performing individual wo...

36 views 0 5
Read article

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