Reset password with code not working

Hello, for my user to change their password they call an endpoint on my api. the api gets a code and and builds the url to the code reset page. for that i use the c# grpc looking like this: var code = zitadelUserApi.PasswordReset(new Zitadel.User.V2.PasswordResetRequest() { ReturnCode = new Zitadel.User.V2.ReturnPasswordResetCode(), UserId = identityUser.User.Id, }).VerificationCode; with the code i get here i build the url like this: $"https://myzitadel.example.com/ui/login/password/init?&callback=mywebsite.com&code={code}&orgID={myorg}&userID={identityUser.User.Id}"; till here every think work but now when the user clicks the link and changes his password he get the notification that the password reset was successful but when he tries to login with the newly set password it is not a correct password. Is this a bug or am i doing something wrong? But surely the password is not changed, eventho the frontend says so.
46 Replies
Ask Inkeep
Ask Inkeep2w ago
Hi @boblack_zocker, I'm an AI assistant for ZITADEL. While a team member reviews this question, I'll see if I can find relevant sources for your question. Answer I wasn't able to find a direct answer, here are some relevant sources: 1. Request a code to reset a password (1) : The official API documentation shows how to request password reset codes and includes a urlTemplate parameter that allows you to customize the reset URL with placeholders for UserID, OrgID, and Code. 2. Request a code to reset password (2) : A community discussion that clarifies you must choose between sendLink or returnCode - you cannot use both in the same request, which matches your implementation approach. ​ To learn more, see the sources I considered: [1] Request a code to reset a password [2] Request a code to reset password ​ Feel free to tag @Ask Inkeep with additional questions.
boblack_zocker
boblack_zockerOP2w ago
@Rajat can u help me with this one? @Ask Inkeep is the authRequestID needed?
Ask Inkeep
Ask Inkeep2w ago
Thanks for the follow-up, @boblack_zocker. I'll get back to you soon. Answer I wasn't able to find a direct answer, here are some relevant sources: 1. Get OIDC Auth Request details : This endpoint requires an authRequestId as a path parameter to retrieve OIDC Auth Request details by ID, obtained from the redirect URL. 2. Finalize an Auth Request and get the callback URL. : This endpoint shows how to finalize an auth request with session details, but the specific relationship to password reset flows isn't explicitly documented. Feel free to tag @Ask Inkeep with additional questions.
Rajat
Rajat2w ago
hey @boblack_zocker what fersion is this?. When they are not able to change password, can they still login with the old password?.
boblack_zocker
boblack_zockerOP2w ago
this is v2.58.6 version. yes they still can log in. if they click on the "reset password" button in the form again and change it with this link there they can successfully change the password and log in with that one but somehow if i build the url and they change it with the provided url from me it says it was successful but does not change it
Rajat
Rajat2w ago
is v2.58.6 is the zitadel version ypu are using? Do you know we are on v4+ atm?. are you a PRO customer?. This seems like a very old version that you are running
boblack_zocker
boblack_zockerOP2w ago
we are selfhosted. and we dont upgrade often.
Rajat
Rajat2w ago
okay I have to take a look at it, is this a new issue that came up OR been existing for a long time?
boblack_zocker
boblack_zockerOP2w ago
i just found out it is not working. i had another ticket a few weeks ago where i needed this. https://discord.com/channels/927474939156643850/1425453127288754176 its only not working if i get the code of the reset code in my api instead of directly sending it per mail there are 2 options to make the api call
boblack_zocker
boblack_zockerOP2w ago
i've set the medium to return_code and the code is returned to the api that called the zitadel request
Rajat
Rajat2w ago
Since the password reset appears in your UI but doesn't actually change the password, this suggests there might be: A missing required parameter in your URL construction( i have to check more) An issue with the code expiration (you can configure code lifetime via Secret Generator settings) A mismatch between the expected URL format and what you're providing(highly uunlikely, but doubele check)
boblack_zocker
boblack_zockerOP2w ago
the only parameter i am missing is the authRequestID
Rajat
Rajat2w ago
have you tried appneding authRequestID and trying again?
boblack_zocker
boblack_zockerOP2w ago
not really, because i dont have one can i generate one? and for what is it used
Rajat
Rajat2w ago
hey @boblack_zocker checking w/ the team 🙂
Rajat
Rajat2w ago
hey @boblack_zocker , if you open https://<instance-domain>/ui/login/login in an incognito window, you will have authRequestID in the URL
No description
boblack_zocker
boblack_zockerOP2w ago
yes you have that if you go to the zitadel login in my case the user is not on the login page before in my case the api does the "reset password". and the api has no authRequestID
Rajat
Rajat2w ago
yes you are correct, checking again hey @boblack_zocker I got a response internally
If you want to adhere to the OIDC standard and obtain an Access Token etc, these are the steps: https://zitadel.com/docs/guides/integrate/login-ui/oidc-standard#authorize-request For this flow, you do need to call the /oauth/v2/authorize endpoint from Zitadel, but only to grab the “authRequest” parameter from the response. You could handle this in a hidden webview/iFRAME, or make a GET request and scrape this value from the returned HTML response. BUT I did notice that the name of the parameter seems to have changed to requestId now. Try calling authorize, and you will be redirected to the following URL: /ui/v2/login/loginname?requestId=oidc_V2_341305873773166305
hope this helps 🙂
boblack_zocker
boblack_zockerOP2w ago
did the team also tell if this is the missing part for making it work?
Rajat
Rajat2w ago
to get the authrequestId? that missing part you mean
boblack_zocker
boblack_zockerOP2w ago
do get this link here working
Rajat
Rajat2w ago
you mean this one? https://myzitadel.example.com/ui/login/password/init?&callback=mywebsite.com&code={code}&orgID={myorg}&userID={identityUser.User.Id}
boblack_zocker
boblack_zockerOP2w ago
yes
Rajat
Rajat2w ago
no i didnt check that, i asked for getting the quth request Id and how to proceed, pls try if that works because if that works meaning the docs needs to be updated with correct steps. I/my teammates dont have a hosted custom ui with that old version(et alone a new one) so saying anything on my side without testing is not good 😅 that is why i am suggesting you to try on your end
boblack_zocker
boblack_zockerOP2w ago
alright i will test it 😄
Rajat
Rajat2w ago
thanks for undrestanding
boblack_zocker
boblack_zockerOP2w ago
i just tested it out and authRequestID is not the missing part still i change the password and get the verification that the password has changed. but at the end when i try to login with the new password it says password is incorrect so it still did not change it i dont understand why this works when the code is sent to the user per mail directly and why its not working when i get the code in the api first and build the url excactly like its provided in the email of the user
Rajat
Rajat2w ago
do you see anything on your logs since you are self hosted the only other plausible cause would be that this is an outdated version which has been already deprecated so they're not maintained. https://zitadel.com/docs/product/roadmap everything is correct based on what we discussed. The ONLY other issue I can think of is that the verification code might have different lifetimes or validation rules. the ReturnCode you mentioned above shoulld work but seems like its not
boblack_zocker
boblack_zockerOP2w ago
could you look into it if and how the return code works on a newer version? i dont think its the lifetimes because if the code was not valid i would get a error like "code not found" the code process looks like working but its not saving the password
Rajat
Rajat2w ago
it does
No description
boblack_zocker
boblack_zockerOP2w ago
and does the code really reset the password? did u test this out too? get code - change pw with code - login with new pw
Rajat
Rajat2w ago
it actually worked! but I am testing a behaviour, my password from the api was change but I also had a password reset on login, I think that I tested both sendLunk and return code. With returncode you can change the passwors via api https://zitadel.com/docs/apis/resources/user_service_v2/user-service-set-password or you can use sendLink to get a password reset on login I belive but I will also test teh v2 endpoint if that also works or not
boblack_zocker
boblack_zockerOP2w ago
can u change the password in the ui if u do the url like this? https://{{zitadelinstance}}/ui/login/password/init?&code=THECODE&orgID=12345&userID=12345
Rajat
Rajat2w ago
I did not see the URL, but you can give it a try
Rajat
Rajat2w ago
but I get an error for ID missing
No description
No description
Rajat
Rajat2w ago
I am not sure if thats the right way to change the password
boblack_zocker
boblack_zockerOP2w ago
what id? authRequstID?
Rajat
Rajat2w ago
no idea, I never tried any other way but the api way or the UI reset after the first login
boblack_zocker
boblack_zockerOP2w ago
like this it gives me no error but it does not work
boblack_zocker
boblack_zockerOP2w ago
here its about getting the code from the api that u cant use sendlink and returncode in the same call what i am doing is that i use "return code" and then do the same url like "sendlink" would build it if u do "sendlink" u get a mail with the code. extract that exact link and put the code in that u get with "return code" could you try this ?
Rajat
Rajat2w ago
hey @boblack_zocker I cannot try it atm, pls test it and go ahead, I am not hitting the issue or maybe i am trouble having the understanding because the password changed worked on v4 pls try upgrading the instance, I can probably say that all those initial errors that were happening will go awya and you maybe able to continue
boblack_zocker
boblack_zockerOP2w ago
alright i'm gonna try on the newer version. thanks for your help 🙂
Rajat
Rajat2w ago
we have a big version mismatching, I cant say confidentely if sometuing works for me will also work for you, but as far the apis and the ui goes, it works very well, like you can see above. Now this is getting twisted into more and more specific use case which I also have not time for as the there are a lots of threads. hope this helps.
boblack_zocker
boblack_zockerOP2w ago
yes i understand it no problem

Did you find this page helpful?