mdjnelson / moodle-mod_customcert

Enables the creation of dynamically generated certificates with complete customisation via the web browser.
https://moodle.org/plugins/mod_customcert
GNU General Public License v3.0
89 stars 157 forks source link

When trying to verify with QR code, user is redirected to login page #545

Closed baris83 closed 6 months ago

baris83 commented 1 year ago

Hi, I realized that, on Moodle 4.1.1 setup, when trying to verify a certificate with QR code, user is redirected to login page. I've tried it with Boost and Classic themes. We have other sites which are Moodle 3.8 and 3.11 where we use custum certificates with no such issues.

There is also another user facing this problem https://moodle.org/mod/forum/discuss.php?d=444866

Settings: Allow anyone to verify a certificate : Yes Allow verification of all certificates : checked

Also tried to give Guest permissions to mod/customcert:verifycertificate mod/customcert:verifyallcertificates

But no success

davefoord commented 1 year ago

I am experiencing exactly the same issue, and have tested this on 2 separate Moodles

mdjnelson commented 1 year ago

Seems this is a 4.x issue. Thanks for reporting. Will work on it next week.

davefoord commented 1 year ago

Have you been able to make any progress with this?

mdjnelson commented 1 year ago

Looking at it today as I set some time today to work on this project.

mdjnelson commented 1 year ago

I have a Behat test for this exact scenario. I ran all the Behat scenarios for my plugin and there are a bunch of failures. I am going to have to see what is going on with more detail to get them all working.

davidmoralesrivera commented 1 year ago

Hello, i have the same problem, i tried this to avoid the redirect:

when the certificate is generated and i scan the qr code, i get this link

mydomain.com/mod/customcert/verify_certificate.php?contextid=1304&code=d4LnWGduFg&qrcode=1

but, if i remove "contextid=1304" for example:
mydomain.com/mod/customcert/verify_certificate.php?code=d4LnWGduFg&qrcode=1
 

the redirection stops, i dont know how to remove this parameter automatically

mdjnelson commented 1 year ago

This is what I expected was happening @davidmoralesrivera, thanks. All going well I will get a fix today.

ppachas commented 7 months ago

Hello,

To fix this issue, edit the file: /mod/customcert/element/qrcode/classes/element.php

Comment out line 161:

// 'contextid' => $issue->contextid,

Now the QR code generates the link without the "contextid" parameter and the user is no longer redirected to the login page.

This worked for me.

Greetings.

mdjnelson commented 6 months ago

Got a fix for this now. I kept thinking it was an issue on the verification page and was confused because Behat covered this but it's an issue with the QR code generating an incorrect url - doh.

mdjnelson commented 6 months ago

Ok, pushed fix to github. It is now in the 4.0, 4.1 and 4.2 branches. :)