Create
cancel
Showing results for 
Search instead for 
Did you mean: 
Sign up Log in

It's not the same without you

Join the community to find out what other Atlassian users are discussing, debating and creating.

Atlassian Community Hero Image Collage

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 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
TAGS
Community showcase
Published in Jira Service Desk

The Complete Guide to Atlassian for ITSM

Hi Atlassian Community! This is Teresa from the Atlassian team. My colleague Paul Buffington @Buff and I are excited to share a brand new ITSM resource we’ve created – "The Complete Guide to At...

2,211 views 14 22
Read article

Community Events

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

Find an event

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

Unfortunately there are no Community Events near you at the moment.

Host an event

You're one step closer to meeting fellow Atlassian users at your local event. Learn more about Community Events

Events near you