Repository navigation
Is there a complete example? #11
Replies: 4 comments 1 reply
|
Hey, have you checked the examples over here? https://github.com/chillerlan/php-authenticator/tree/main/examples |
|
Yes, sorry it looks like the totp example is the entire PHP flow in one continuous segment of code. I thought that there would need to be multiple segments. Like creating a secret then creating the QR code/presenting the QR code, validating the QR code, writing the secret to permanent storage and then validating the codes using the secret on an ongoing basis. I guess I was just confused. I'll keep messing with it though. Thanks for the hard work. I ran into one problem with your QRCode lib. ``echo is the example given. I need to pass the QRCode to a template to display it to the user so I tried this: $qr = new QRCode->render($data); to store it in a passable variable and I get an error about unexpected -> Like I said eirher way I will just keep trying until it works. thanks. |
|
Yea, the flow is straightforward enough so i kept it in a single file - needless to say that creation of the secret and verification of a user's OTP code are separate flows. This bit of code is only valid as of PHP 8.4, which allows omitting the braces around a new instance creation (similar to Javascript). $qr = new QRCode->render($data);
$qr = new QRCode($qrOptions)->render($data);
// PHP < 8.4
$qr = (new QRCode)->render($data);
$qr = (new QRCode($qrOptions))->render($data);But you probably want to instance the $qrcode = new QRCode($qrOptions);
// ...
$image = $qrcode->render($data); |
|
okay, sorry for asking.
Thanks.
…On Thu, Feb 13, 2025, 3:28 AM smiley ***@***.***> wrote:
Yea, the flow is straightforward enough so i kept it in a single file -
needless to say that creation of the secret and verification of a user's
OTP code are separate flows.
This bit of code is only valid as of PHP 8.4, which allows omitting the
braces of a new instance creation.
$qr = new QRCode->render($data);
// PHP < 8.4 $qr = (new QRCode)->render($data);
But you probably want to instance the QRCode earlier anyway:
$qrcode = new QRCode($qrOptions);
// ...
$image = $qrcode->render($data);
—
Reply to this email directly, view it on GitHub
<#9 (comment)>,
or unsubscribe
<https://github.com/notifications/unsubscribe-auth/AD7FNQQOEPQP3O24D6TYMV32PRJUNAVCNFSM6AAAAABXAIACUOVHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMZDMNJVHA3DANJWGU>
.
You are receiving this because you authored the thread.Message ID:
***@***.***>
[image: codemasher]*codemasher* left a comment
(chillerlan/php-authenticator#9)
<#9 (comment)>
Yea, the flow is straightforward enough so i kept it in a single file -
needless to say that creation of the secret and verification of a user's
OTP code are separate flows.
This bit of code is only valid as of PHP 8.4, which allows omitting the
braces of a new instance creation.
$qr = new QRCode->render($data);
// PHP < 8.4 $qr = (new QRCode)->render($data);
But you probably want to instance the QRCode earlier anyway:
$qrcode = new QRCode($qrOptions);
// ...
$image = $qrcode->render($data);
—
Reply to this email directly, view it on GitHub
<#9 (comment)>,
or unsubscribe
<https://github.com/notifications/unsubscribe-auth/AD7FNQQOEPQP3O24D6TYMV32PRJUNAVCNFSM6AAAAABXAIACUOVHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMZDMNJVHA3DANJWGU>
.
You are receiving this because you authored the thread.Message ID:
***@***.***>
|
Uh oh!
There was an error while loading. Please reload this page.
I'm trying to use this library along with chillerlan\QRCode to implement 2fa.
I've been able to generate the uri and show the QR code but i'm a bit confused about what you're supposed to do from there.
Is there a complete example which includes capturing and validating the code from the user anywhere?
The docs appear to sort of skip over a little bit of the work that is required for this to be a complete solution.
If that is intentional it's okay I am just confused.
All reactions