public function activateAction($username, $activation)
{
if (empty($username) || empty($activation) || !($user = User::where(['username' => $username, 'activation' => $activation, 'login IS NULL'])->first())) {
App::abort(400, __('Invalid key.'));
}
$verifying = false;
if ($this->module->config('require_verification') && !$user->get('verified')) {
$user->set('verified', true);
$verifying = true;
}
if ($this->module->config('registration') === 'approval' && $user->status === User::STATUS_BLOCKED && $verifying) {
$user->activation = App::get('auth.random')->generateString(32);
$this->sendApproveMail($user);
$message = __('Your email has been verified. Once an administrator approves your account, you will be notified by email.');
} else {
$user->status = User::STATUS_ACTIVE;
$user->activation = '';
$this->sendWelcomeEmail($user);
$message = $verifying ? __('Your account has been activated.') : __('The user\'s account has been activated and the user has been notified about it.');
}
$user->save();
App::message()->success($message);
return App::redirect('@user/login');
}