Verify email confirmation token and activate the user account.
519283
def confirm_email_view(self, token):
        
        # Verify token
        data_items = self.token_manager.verify_token(
            token,
            self.USER_CONFIRM_EMAIL_EXPIRATION)

        # Retrieve user, user_email by ID
        user = None
        user_email = None
        if data_items:
            user, user_email = self.db_manager.get_user_and_user_email_by_id(data_items[0])

        if not user or not user_email:
            flash(_('Invalid confirmation token.'), 'error')
            return redirect(url_for('user.login'))

        # Set UserEmail.email_confirmed_at
        user_email.email_confirmed_at=datetime.utcnow()
        self.db_manager.save_user_and_user_email(user, user_email)
        self.db_manager.commit()

        # Send confirmed_email signal
        signals.user_confirmed_email.send(current_app._get_current_object(), user=user)

        # Flash a system message
        flash(_('Your email has been confirmed.'), 'success')

        # Auto-login after confirm or redirect to login page
        safe_next_url = self._get_safe_next_url('next', self.USER_AFTER_CONFIRM_ENDPOINT)
        if self.USER_AUTO_LOGIN_AFTER_CONFIRM:
            return self._do_login_user(user, safe_next_url)  # auto-login
        else:
            return redirect(url_for('user.login') + '?next=' + quote(safe_next_url))
280202
def execute(self, email):
        """"""
        print('Sign up user {0}'.format(email))
        self.email_sender.send(email, 'Welcome, "{}"'.format(email))
876317
def activate_user(self, user):
        
        if not user.active:
            user.active = True
            return True
        return False
1017405
def activate_view(self, request, user_id, token):
        
        try:
            user = self.user_model.objects.get(id=user_id, is_active=False)
        except self.user_model.DoesNotExist:
            raise Http404(_("Your URL may have expired."))

        if not RegistrationTokenGenerator().check_token(user, token):
            raise Http404(_("Your URL may have expired."))
        form = self.get_form(
            data=request.POST or None, files=request.FILES or None, instance=user
        )
        if form.is_valid():
            form.instance.is_active = True
            user = form.save()
            user.set_password(form.cleaned_data["password"])
            user.save()
            self.activate_organizations(user)
            user = authenticate(
                username=form.cleaned_data["username"],
                password=form.cleaned_data["password"],
            )
            login(request, user)
            return redirect(self.get_success_url())
        return render(request, self.registration_form_template, {"form": form})
1032945
public function verify($token)
    {
        $response = VerifyEmail::verify(Auth::user(), $token);

        switch ($response) {
            case VerifyEmail::EMAIL_VERIFIED:
                return redirect($this->redirectPath())->with('status', trans($response));

            default:
                return redirect()->back()
                            ->withErrors(['email' => trans($response)]);
        }
    }
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;
        }
    }
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
868911
def send_verification(self, attribute='email'):
        
        self.check_token()
        self.client.get_user_attribute_verification_code(
            AccessToken=self.access_token,
            AttributeName=attribute
        )
1296991
def _create_verify_email_token_url(self, base_url=None, view_class=None):
        
        view = view_class or views.auth.Login
        endpoint = getattr(view, "verify_email")
        action = "verify-email"
        expires_in = __options__.get("verify_email_token_ttl") or (60 * 24)
        action_token = self.create_action_token(action, expires_in)
        signed_data = self.sign_data(action, expires_in=expires_in)
        url = _url_for_email(endpoint,
                             base_url=base_url,
                             action_token=action_token,
                             signed_data=signed_data)
        return url
760181
def create_user(email, password, active, confirmed_at, send_email):
    
    if confirmed_at == 'now':
        confirmed_at = security.datetime_factory()
    user = user_manager.create(email=email, password=password, active=active,
                               confirmed_at=confirmed_at)
    if click.confirm(f'Are you sure you want to create {user!r}?'):
        security_service.register_user(user, allow_login=False, send_email=send_email)
        user_manager.save(user, commit=True)
        click.echo(f'Successfully created {user!r}')
    else:
        click.echo('Cancelled.')
750476
def get(self, request, key):
        """"""

        try:
            email_val = EmailAddressValidation.objects.get(validation_key=key)
        except EmailAddressValidation.DoesNotExist:
            messages.error(request, _('The email address you are trying to '
                                      'verify either has already been verified'
                                      ' or does not exist.'))
            return redirect('/')

        try:
            email = EmailAddress.objects.get(address=email_val.address)
        except EmailAddress.DoesNotExist:
            email = EmailAddress(address=email_val.address)

        if email.user and email.user.is_active:
            messages.error(request, _('The email address you are trying to '
                                      'verify is already an active email '
                                      'address.'))
            email_val.delete()
            return redirect('/')

        email.user = email_val.user
        email.save()
        email_val.delete()

        user = User.objects.get(username=email.user.username)
        user.is_active = True
        user.save()

        messages.success(request, _('Email address verified!'))
        return redirect('user_profile', username=email_val.user.username)
1334347
def verify_email_for_object(self, email, content_object, email_field_name='email'):
        

        confirmation_key = generate_random_token()

        try:
            confirmation = EmailConfirmation()
            confirmation.content_object = content_object
            confirmation.email_field_name = email_field_name
            confirmation.email = email
            confirmation.confirmation_key = confirmation_key
            confirmation.save()
        except IntegrityError:
            confirmation = EmailConfirmation.objects.get_for_object(content_object, email_field_name)
            confirmation.email = email
            confirmation.confirmation_key = confirmation_key
            confirmation.save(update_fields=['email', 'confirmation_key'])

        confirmation.send()

        return confirmation
326864
def login(self, email=None, password=None, app_id=None, api_key=None):
        
        session_token = self.api.user_get_session_token(
            app_id=app_id, email=email, password=password, api_key=api_key)

        # install session token back into api client
        self.api.session = session_token
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)
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;
    }
425262
def require_email_confirmation(self):
        
        self.email_confirmed = False
        self.email_link = self.generate_hash(50)
        now = datetime.datetime.utcnow()
        self.email_link_expires = now + datetime.timedelta(hours=24)
86228
def handle_verification_form(form):
    """"""
    form.process(formdata=request.form)

    if form.validate_on_submit():
        send_confirmation_instructions(current_user)
        # NOTE: Flash message.
        flash(_("Verification email sent."), category="success")