Giter Club home page Giter Club logo

Comments (9)

albertcd avatar albertcd commented on July 21, 2024 1

I solved the access to ucp.php changing the line 64 of src/phpMyFAQ/User/TwoFactor.php to:

return is_null($user->getUserData('secret')) ? '' : $user->getUserData('secret');

from phpmyfaq.

modelrailroader avatar modelrailroader commented on July 21, 2024

I just saw that this issue concerns "my" function and checked it:
Probably, you just have to change line 54 in ucp.php to
if (is_null($secret)) {

This is because the default value for secret in the db is set to null in the update script. @thorsten
But I can't test it currently...

from phpmyfaq.

albertcd avatar albertcd commented on July 21, 2024

Today, after logout, i cannot login anymore.
I tried to reset password, and with new password neither.

I tried change the line
try {
to
if (is_null($secret)) {

but cannot login to phpMyFAQ.

Thanks u

from phpmyfaq.

modelrailroader avatar modelrailroader commented on July 21, 2024

@albertcd Did you enabled 2FA? What is shown if you log in to your phpMyFAQ instance? Any error messages, maybe if you turn on DEBUG?

from phpmyfaq.

modelrailroader avatar modelrailroader commented on July 21, 2024

Today, after logout, i cannot login anymore. I tried to reset password, and with new password neither.

I tried change the line try { to if (is_null($secret)) {

but cannot login to phpMyFAQ.

Thanks u

That's wrong, it's my fault, I'm sorry. With your version of the database, you have to change line 53 in ucp.php to the line above, so:
if ($secret === '') { to if (is_null($secret)) {

This should fix viewing ucp.php.
But this can't be the solution why you can't log in, so please answer my last questions too

from phpmyfaq.

albertcd avatar albertcd commented on July 21, 2024

Today, after logout, i cannot login anymore. I tried to reset password, and with new password neither.
I tried change the line try { to if (is_null($secret)) {
but cannot login to phpMyFAQ.
Thanks u

That's wrong, it's my fault, I'm sorry. With your version of the database, you have to change line 53 in ucp.php to the line above, so: if ($secret === '') { to if (is_null($secret)) {

This should fix viewing ucp.php. But this can't be the solution why you can't log in, so please answer my last questions too

I changed the line 52, now i have this lines:

$tfa = new TwoFactor($faqConfig);
$secret = $tfa->getSecret(CurrentUser::getFromSession($faqConfig));
if (is_null($secret)) {
     try {
            $secret = $tfa->generateSecret();

Now i can logging into phpMyFAQ (i don't understand why now is working, and this morning say "Bad user/password") and when i access to ucp, i get this error:

Uncaught exception: 'TypeError'

Message: 'phpMyFAQ\User\TwoFactor::getSecret(): Return value must be of type string, null returned'

Stack trace:

#0 /var/www/vhosts/domain.com/kb.domain.com/ucp.php(52): phpMyFAQ\User\TwoFactor->getSecret()
#1 /var/www/vhosts/domain.com/kb.domain.com/index.php(793): require('...')
#2 {main}
Thrown in '/var/www/vhosts/domain.com/kb.domain.com/src/phpMyFAQ/User/TwoFactor.php' on line 64

from phpmyfaq.

modelrailroader avatar modelrailroader commented on July 21, 2024

In general, I understand, why this error comes up, but I'm wondering why my test worked properly a few minutes ago...

Anyway, I'll propose you a change tomorrow, now I'm off work.

from phpmyfaq.

modelrailroader avatar modelrailroader commented on July 21, 2024

Yeah, you can do it like that, but alternatively, you should be able to change this line
public function getSecret(CurrentUser $user): string
to
public function getSecret(CurrentUser $user): string|null
in Twofactor.php as well.

from phpmyfaq.

thorsten avatar thorsten commented on July 21, 2024

Fixed with #2521

from phpmyfaq.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.