privacyidea / keycloak-provider

:lock: OTP Two Factor Authentication Provider for Keycloak to run with privacyIDEA
Apache License 2.0
78 stars 21 forks source link

Problem on reprogramming the privacyIdea.ftl in Keycloakify Project #182

Open deincodeverbesserer93 opened 6 days ago

deincodeverbesserer93 commented 6 days ago

When i set privacyIdea.ftl in the keycloakify project v. 9. Then i have successfully set the otp authentication. But when i produce a error for Example when i set a wrong otp code. The following exception arrives in the console log.

Uncaught SyntaxError: Invalid or unexpected token (at authenticate?session_code=sb3GudNbj4e2PTSxuXnCdU8y5KBWQslDnj4QFh1RAm4&execution=e7ca0caf-e6fc-40d6-8a15-0ab5532bf165&client_id=account&tab_id=CtIlDAbPj8A&client_data=eyJydSI6Imh0dHA6Ly9sb2NhbGhvc3Q6ODg5MC9yZWFsbXMvTGluZG5lci9hY2NvdW50L2xvZ2luLXJlZGlyZWN0IiwicnQiOiJjb2RlIiwic3QiOiIwL2VmM2I2NTFkLTcyZTItNGVlOS05MTA2LTI5NjU1ZTVlZmZmYSJ9:693:44)

TypeError: Cannot read properties of undefined (reading 'url') at __vite__mapDeps (main.tsx:34:1) at main.tsx:14:39 at ng (react.production.min.js:18:161) at sh (react-dom.production.min.js:291:300) at oh (react-dom.production.min.js:280:389) at Jy (react-dom.production.min.js:280:320) at co (react-dom.production.min.js:280:180) at Zu (react-dom.production.min.js:271:88) at rh (react-dom.production.min.js:268:429) at O (scheduler.production.min.js:13:203)

When i click the first message. The message is correct but the browser could not handle this.

`if(fieldName === "global" ){

                                return "Authentication failed.

falsche OTP-Pin";`

nilsbehlen commented 6 days ago

So you put the ftl in keycloakify, which changed its content, and when it does not work, you ask here? ;) I do not recognize any content of the error message, because that stuff is not part of this project. If i had to guess, it is that url is undefined and that is not checked prior to using it.

deincodeverbesserer93 commented 5 days ago

Hi,

yes here. The Problem is the \n in the Authenticator class. Could you please remove. The react App of keycloakify do not unterstand response of the submit form.

nilsbehlen commented 5 days ago

Which \n? This project does not produce errors in the current version. If you are re-building it anyway, you could just change it in your files.

deincodeverbesserer93 commented 5 days ago

FTL could handle the response from form submit but React / Typescript breaks with the error in my first comment. The problem is here

nilsbehlen commented 5 days ago

I can not reproduce any problem with that: grafik

Also, the error message clearly states what the problem is: TypeError: Cannot read properties of undefined (reading 'url')

If things break because of the use of keycloakify, you will need to fix them on your own, and most importantly in your own project. If you can show how this projects breaks without changes on a keycloak, i am happy to fix issues.

deincodeverbesserer93 commented 4 days ago

your default Ftl works fine, but i need some more changes in html code not only css.

To reproduce you need to extend the keycloakify starter project with your privacyIdea.ftl

deincodeverbesserer93 commented 3 days ago

This is in the response of the form submit. And the first error Cannot read propertiers undefined (reading 'url')

Bildschirmfoto 2024-07-06 um 22 47 44

And this occurs when enter a wrong token to see what happens on error.

nilsbehlen commented 1 day ago

So the error message you are getting is not related the screenshot you show. I guess the problem in the screenshot is the linebreak.

Like i said, since the code of this repository works, there is no need to change. If you need help with the stuff you customized, you need to show the whole thing (i.e. the whole ftl).

deincodeverbesserer93 commented 1 day ago

yes the code in the repository works but only if use the default privacyIdea.ftl. With Keycloakify and a custom tsx file the error occurs, when i remove the '\n' in your repo than the form submit works in both projects