Activates an user

@param string $email E-mailaddress of the user.
@param string $activationKey Activation key of the user.
@return bool
976505
public function activateUser($email, $activationKey)
    {
        if ($this->validateActivationKey($email, $activationKey)) {
            $user = $this->findByEmailAndActivationKey($email, $activationKey)->first();

            if ($user->active == 0) {
                $user->active = 1;
                $user->activation_key = null;
                if ($this->save($user)) {
                    return true;
                }
            }
        }

        return false;
    }
229233
def account_activation(data = {})
      @data = {
          user: nil,
          client_ip: '0.0.0.0'
      }.merge(data || {})
      raise unless data[:user]
      mail to: data[:user].email, subject: 'Account activation'
    end
1155720
public function activationResend()
    {
        //Checks if signup is enabled and if accounts will be enabled by the
        //  user via email
        if (!getConfig('users.signup') && getConfig('users.activation') === 1) {
            $this->Flash->error(I18N_DISABLED);

            return $this->redirect(['_name' => 'homepage']);
        }

        $entity = $this->Users->newEntity($this->request->getData(), ['validate' => 'DoNotRequirePresence']);

        if ($this->request->is('post')) {
            //Checks for reCAPTCHA, if requested
            if (!getConfig('security.recaptcha') || $this->Recaptcha->verify()) {
                if (!$entity->getErrors()) {
                    $user = $this->Users->findPendingByEmail($this->request->getData('email'))->first();

                    if ($user) {
                        $this->sendActivationMail($user);
                        $this->Flash->success(__d('me_cms', 'We send you an email to activate your account'));

                        return $this->redirect(['_name' => 'login']);
                    }

                    if ($this->request->getData('email')) {
                        Log::error(sprintf(
                            '%s - Resend activation request with invalid email `%s`',
                            $this->request->clientIp(),
                            $this->request->getData('email')
                        ), 'users');
                    }

                    $this->Flash->error(__d('me_cms', 'No valid account was found'));
                }
            } else {
                $this->Flash->error(__d('me_cms', 'You must fill in the {0} control correctly', 'reCAPTCHA'));
            }
        }

        $this->set('user', $entity);
        $this->viewBuilder()->setLayout('login');
    }
195319
public function register(array $credentials, $activate)
    {
        try
        {
            if ( $this->validator->with($credentials)->passes() )
            {
                $this->users->register($credentials,$activate);
                return true;
            }
        }
        catch (LoginRequiredException $e)
        {
            $this->validator->add('LoginRequiredException',$e->getMessage());
        }
        catch (PasswordRequiredException $e)
        {
            $this->validator->add('PasswordRequiredException',$e->getMessage());
        }
        catch (UserExistsException $e)
        {
            $this->validator->add('UserExistsException',$e->getMessage());
        }

        return false;
    }
430043
protected function activateUser($uuid, $activationToken)
    {
        // Check the uuid
        if (!$this->userManager->hasUserForUuid($uuid)) {
            return array('result' => false, 'message' => $this->translate('Account with the given UUID does not exist.', '\\Zepi\\Web\\AccessControl'));
        }
        
        // Compare the activation token
        $user = $this->userManager->getUserForUuid($uuid);
        if ($user->getMetaData('activationToken') !== $activationToken) {
            return array('result' => false, 'message' => $this->translate('The given activation token is not valid.', '\\Zepi\\Web\\AccessControl'));
        }
        
        // Remove the disabled access level
        $this->accessControlManager->revokePermission($uuid, get_class($user), '\\Global\\Disabled');
        $this->accessControlManager->grantPermission($uuid, get_class($user), '\\Global\\Active', 'Activation');
        
        return array('result' => true, 'message' => $this->translate('Your account was activated successfully.', '\\Zepi\\Web\\AccessControl'));
    }
162683
public function sendActivationMail($user)
    {
        if ($user->activated || !$this->shouldSend($user)) {
            return;
        }
        $userToken = $this->createActivation($user);
        //$userToken = User::find($user->id);
        $user->notify(new ConfirmEmailNotification($userToken));
    }
1141453
protected function registerUser($email, $googleUserId)
    {
        $className = $this->userService->getUserClass();
        /** @var BaseUser $user */
        $user = (new $className());
        $user->setEmail($email)
            ->setGoogleUserId($googleUserId)
            ->setPlainPassword(base64_encode(random_bytes(20)));
        $this->userService->registerUser($user, UserService::SOURCE_TYPE_GOOGLE);

        return $user;
    }
152025
def register_by_email(self, email, sender=None, request=None, **kwargs):
        
        try:
            user = self.user_model.objects.get(email=email)
        except self.user_model.DoesNotExist:
            user = self.user_model.objects.create(
                username=self.get_username(),
                email=email,
                password=self.user_model.objects.make_random_password(),
            )
            user.is_active = False
            user.save()
        self.send_activation(user, sender, **kwargs)
        return user
871101
public function activate($id)
    {
        $this->loadModel('User.Users');
        $user = $this->Users->get($id, ['fields' => ['id', 'name', 'email']]);

        if ($this->Users->updateAll(['status' => 1], ['id' => $user->id])) {
            NotificationManager::activated($user)->send();
            $this->Flash->success(__d('user', 'User {0} was successfully activated!', $user->name));
        } else {
            $this->Flash->danger(__d('user', 'User could not be activated, please try again.'));
        }

        $this->title(__d('user', 'Unblock User Account'));
        $this->redirect($this->referer());
    }
732391
public function onUserActivationPost(UserActivationEvent $e) 
    {
        $password = $e->getParam('password');
        $email = $e->getParam('to');
        $siteUrl = $e->getParam('siteurl');
        $loginUri = $this->getModuleOptions()->getLoginUri();

        // something got really wrong if we get here...
        if(null === $email || null === $password) { 
        	return;
        }
        
        $transport = $this->getServiceLocator()->get('mailer.mail.transport.smtp');
        $message = $this->getServiceLocator()->get('mailer.mail.message.useractivation');
        $message->configure(array(
            'to' => $email,
            'siteurl' => $siteUrl,
            'loginurl' => $siteUrl . $loginUri, 
            'password' => $password,
        	'cdnurl' => $this->getModuleOptions()->getCdnUrl(),
            'siteName' => $this->getModuleOptions()->getSiteName()
        ));
        $transport->send($message);
    }
255933
public function validateemailAction() {
        $this->view->title = __('activate email page title');
        $auth = Garp_Auth::getInstance();
        $authVars = $auth->getConfigValues();
        $request = $this->getRequest();
        $activationCode = $request->getParam('c');
        $activationEmail = $request->getParam('e');
        $emailValidColumn = $authVars['validateemail']['email_valid_column'];

        if (!$activationEmail || !$activationCode) {
            throw new Zend_Controller_Action_Exception('Invalid request.', 404);
        }

        $userModel = new Model_User();
        // always collect fresh data for this one
        $userModel->setCacheQueries(false);
        $activationCodeClause = 'MD5(CONCAT(' .
                $userModel->getAdapter()->quoteIdentifier(
                    $authVars['validateemail']['token_column']
                ) . ',' .
                'MD5(email),' .
                'MD5(' . $userModel->getAdapter()->quote($authVars['salt']) . '),' .
                'MD5(id)' .
            ')) = ?'
        ;
        $select = $userModel->select()
            // check if a user matches up to the given code
            ->where($activationCodeClause, $activationCode)
            // check if the given email address is part of the same user record
            ->where('MD5(email) = ?', $activationEmail);

        $user = $userModel->fetchRow($select);
        if (!$user) {
            $this->view->error = __('invalid email activation code');
        } else {
            $user->{$emailValidColumn} = 1;
            if (!$user->save()) {
                $this->view->error = __('activate email error');
            } elseif ($auth->isLoggedIn()) {
                // If the user is currently logged in, update the cookie
                $method = $auth->getStore()->method;
                $userData = $auth->getUserData();
                // Sanity check: is the user that has just validated his email address
                // the currently logged in user?
                if ($userData['id'] == $user->id) {
                    $userData[$emailValidColumn] = 1;
                    $auth->store($userData, $method);
                }
            }
            $this->view->user = $user;
        }
    }
1264994
public function afterRegister($event, $user)
    {
        $sendMail = key_exists('sendMail', $event->data) ? $event->data['sendMail'] : true;
        if ($sendMail) {
            if (Configure::read('CM.ActivationOnRegister')) {
                $this->activation($user);
            }
        }
    }
272005
public function createTempAccount($login, $email = null) {
		$login = LoginHelper::pregMatchLogin($login);
		$body = compact(['login', 'email']);

        Helper::validateForm(RegistrationForm::class, $body, RegistrationForm::SCENARIO_REQUEST);
	
		$this->checkLoginExistsInTps($login);
	
		$activation_code = $this->repository->generateActivationCode();

		\App::$domain->account->temp->create(compact('login', 'email', 'activation_code'));
	
		$this->sendSmsWithActivationCode($login, $activation_code);
	}
1019836
public function findTokenByEmail($email)
    {
        $user = $this->users->where('email', $email)->first();

        if (! is_null($user)) {
            return $user->getActivationToken();
        }

        return null;
    }
895993
public function activateAction($activationHash)
    {
        $userManger = $this->get('beaast.core.manager.user');

        $config = $this->getParameter('beaast.core.user.activation');

        /**
         * @var User $user
         */
        $user = $userManger->findOneBy(['activationHash' => $activationHash]);

        if ($user) {
            $user->setActive(true);
            $user->setActivationHash(null);
            $userManger->save($user);
            $this->addFlash('success', $config['success_message']);

            return $this->redirect($this->generateUrl($config['success_route']));
        }
        $this->addFlash('danger', $config['error_message']);

        return $this->redirect($this->generateUrl($config['error_route']));
    }
727857
def activate(self, request, activation_key):
          
        if SHA1_RE.search(activation_key):
            try:
                profile = RegistrationProfile.objects.get(activation_key=activation_key)
            except RegistrationProfile.DoesNotExist:
                return False
                
            user = profile.user
            user.is_active = True
            user.save()
            profile.activation_key = RegistrationProfile.ACTIVATED
            profile.save()
            return user
        return False
864317
def activate(request, activation_key=None):
    
    utils.activate_user(activation_key)
    # if not activated
    success_url = utils.get_settings('REGISTRATION_API_ACTIVATION_SUCCESS_URL')
    if success_url is not None:
        return HttpResponseRedirect(success_url)