<?php

namespace Frontend\Modules\Profiles\Actions;

/*
 * This file is part of Fork CMS.
 *
 * For the full copyright and license information, please view the license
 * file that was distributed with this source code.
 */

use Frontend\Core\Engine\Base\Block as FrontendBaseBlock;
use Frontend\Core\Engine\Navigation as FrontendNavigation;
use Frontend\Modules\Profiles\Engine\Authentication as FrontendProfilesAuthentication;
use Frontend\Modules\Profiles\Engine\Model as FrontendProfilesModel;
use Symfony\Component\HttpKernel\Exception\NotFoundHttpException;

/**
 * This is the activate-action.
 */
class Activate extends FrontendBaseBlock
{
    public function execute(): void
    {
        // get activation key
        $key = $this->url->getParameter(0);

        // load template
        $this->loadTemplate();

        // do we have an activation key?
        if (isset($key)) {
            // get profile id
            $profileId = FrontendProfilesModel::getIdBySetting('activation_key', $key);

            // have id?
            if ($profileId != null) {
                // update status
                FrontendProfilesModel::update($profileId, ['status' => 'active']);

                // delete activation key
                FrontendProfilesModel::deleteSetting($profileId, 'activation_key');

                // login profile
                FrontendProfilesAuthentication::login($profileId);

                // show success message
                $this->template->assign('activationSuccess', true);
            } else {
                // failure
                throw new NotFoundHttpException();
            }
        } else {
            throw new NotFoundHttpException();
        }
    }
}

<?php

namespace Frontend\Modules\Profiles\Actions;

/*
 * This file is part of Fork CMS.
 *
 * For the full copyright and license information, please view the license
 * file that was distributed with this source code.
 */

use Frontend\Core\Engine\Base\Block as FrontendBaseBlock;
use Frontend\Modules\Profiles\Engine\Authentication as FrontendProfilesAuthentication;
use Frontend\Modules\Profiles\Engine\Model as FrontendProfilesModel;
use Symfony\Component\HttpKernel\Exception\NotFoundHttpException;

class Activate extends FrontendBaseBlock
{
    public function execute(): void
    {
        $this->loadTemplate();
        $profileId = $this->getProfileId();
        $this->activateProfile($profileId);

        FrontendProfilesAuthentication::login($profileId);

        $this->template->assign('activationSuccess', true);
    }

    private function activateProfile(int $profileId): void
    {
        FrontendProfilesModel::update($profileId, ['status' => 'active']);
        FrontendProfilesModel::deleteSetting($profileId, 'activation_key');
    }

    private function getProfileId(): int
    {
        $profileId = FrontendProfilesModel::getIdBySetting('activation_key', $this->getActivationKey());

        if ($profileId === null) {
            throw new NotFoundHttpException();
        }

        return $profileId;
    }

    private function getActivationKey(): string
    {
        $activationKey = $this->url->getParameter(0);

        if ($activationKey === null) {
            throw new NotFoundHttpException();
        }

        return $activationKey;
    }
}

Clean up the profiles activation action
Clean up the profiles activation action
