Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Help Error! Unable to locate a user with that activation code. #600

Open
rifqmd opened this issue Aug 4, 2023 · 8 comments
Open

Help Error! Unable to locate a user with that activation code. #600

rifqmd opened this issue Aug 4, 2023 · 8 comments

Comments

@rifqmd
Copy link

rifqmd commented Aug 4, 2023

Php V8.2
Codeigniter V4.3

The SMTP email has been successfully sent to the email of the user who wants to activate the account, then click Activate account and will redirect to the login page, but the error appears on the login page. guess what the solution is, please
Screenshot 2023-08-04 at 2 40 06 PM

@manageruz
Copy link
Collaborator

Hi @rifqmd
Can you share with your auth.php config file?

@manageruz
Copy link
Collaborator

and please show me your Activate account url

@manageruz
Copy link
Collaborator

After email has been successfully sent, but before hitting the activate account URL, check your database that the new registered user has been successfully created and the activation hash value is present.

@rifqmd
Copy link
Author

rifqmd commented Aug 7, 2023

Alright, here's the auth.php config file

class Auth extends BaseConfig
{
    public $defaultUserGroup = 'user';

    public $landingRoute = '/';

    public $reservedRoutes = [
        'login'                   => 'login',
        'logout'                  => 'logout',
        'register'                => 'register',
        'activate-account'        => 'activate-account',
        'resend-activate-account' => 'resend-activate-account',
        'forgot'                  => 'forgot',
        'reset-password'          => 'reset-password',
    ];

    public $authenticationLibs = [
        'local' => 'Myth\Auth\Authentication\LocalAuthenticator',
    ];

    public $views = [
        // 'login'           => 'Myth\Auth\Views\login',
        // 'register'        => 'Myth\Auth\Views\register',
        // 'forgot'          => 'Myth\Auth\Views\forgot',
        'login'           => '\App\Views\pages\auth\login',
        'register'        => '\App\Views\pages\auth\register',
        'forgot'          => '\App\Views\pages\auth\forgetPassword',
        'reset'           => 'Myth\Auth\Views\reset',
        'emailForgot'     => 'Myth\Auth\Views\emails\forgot',
        'emailActivation' => 'Myth\Auth\Views\emails\activation',
    ];

    public $viewLayout = 'Myth\Auth\Views\layout';

    public $validFields = ['email', 'username'];

    public $personalFields = ['fullname'];

    public $maxSimilarity = 50;

    public $allowRegistration = false;

    public $requireActivation = 'Myth\Auth\Authentication\Activators\EmailActivator';
    
    public $activeResetter = 'Myth\Auth\Authentication\Resetters\EmailResetter';

    public $allowRemembering = false;

    public $rememberLength = 30 * DAY;

    public $silent = false;

    public $hashAlgorithm = PASSWORD_DEFAULT;

    public $hashMemoryCost = 2048; // PASSWORD_ARGON2_DEFAULT_MEMORY_COST;

    public $hashTimeCost = 4; // PASSWORD_ARGON2_DEFAULT_TIME_COST;

    public $hashThreads = 4; // PASSWORD_ARGON2_DEFAULT_THREADS;

    public $hashCost = 10;

    public $minimumPasswordLength = 8;

    public $passwordValidators = [
        'Myth\Auth\Authentication\Passwords\CompositionValidator',
        // 'Myth\Auth\Authentication\Passwords\NothingPersonalValidator',
        // 'Myth\Auth\Authentication\Passwords\DictionaryValidator',
        // 'Myth\Auth\Authentication\Passwords\PwnedValidator',
    ];

    public $userActivators = [
        'Myth\Auth\Authentication\Activators\EmailActivator' => [
            'fromEmail' => null,
            'fromName'  => null,
        ],
    ];

    public $userResetters = [
        'Myth\Auth\Authentication\Resetters\EmailResetter' => [
            'fromEmail' => null,
            'fromName'  => null,
        ],
    ];

    public $resetTime = 3600;
}

And this is the HTML that links to the activation URL

<p>Activate my account or simply copy and then paste the link below to your web browser, <?= site_url() ?>.</p>

<p>To activate your account use this URL:</p>

<p><a href="<?= url_to('activate-account') . '?token=' . $hash ?>">Activate account</a>.</p>

<p>In case our email has been delivered into your SPAM / Bulk / Trash, kindly click "Not Spam" button to make sure that every single email from us is not going to your SPAM / Bulk / Trash folder.</p>
<p>If you did not registered on this website, you can safely ignore this email.</p>

@rifqmd
Copy link
Author

rifqmd commented Aug 7, 2023

each account creation has successfully entered the database and if activated at the stage click the url from the link but the error is considered 'Unable to locate a user with that activation code.' and hash activation does not exist in the database

@manageruz
Copy link
Collaborator

and hash activation does not exist in the database

Ok. Then in the AuthController.php file after the code below (it's inside attemptRegister() method) dump the $user variable and show me it's values please:
$this->config->requireActivation === null ? $user->activate() : $user->generateActivateHash();

@rifqmd
Copy link
Author

rifqmd commented Aug 8, 2023

that part of the source code

// Save the user
$allowedPostFields = array_merge(['password'], $this->config->validFields, $this->config->personalFields);
$user              = new User($this->request->getPost($allowedPostFields));

$this->config->requireActivation === null ? $user->activate() : $user->generateActivateHash();

@manageruz
Copy link
Collaborator

after your above code just insert var_dump($user); die();

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants