def activate_user(self, activation_key, request=None):
        # Make sure the key we're trying conforms to the pattern of a
        # SHA1 hash; if it doesn't, no point trying to look it up in
        # the database.
        if SHA1_RE.search(activation_key):
            try:
                profile = self.get(activation_key=activation_key)
            except self.model.DoesNotExist:
                profile = None
                statsd.incr('user.activate-error.does-not-exist')
                reason = 'key not found'
            if profile:
                if not profile.activation_key_expired():
                    user = profile.user
                    user.is_active = True
                    user.save()

                    # We don't need the RegistrationProfile anymore, delete it.
                    profile.delete()

                    # If user registered as contributor, send them the
                    # welcome email.
                    if user.groups.filter(name=CONTRIBUTOR_GROUP):
                        self._send_email(
                            confirmation_profile=profile,
                            url=None,
                            subject=_('Welcome to SUMO!'),
                            text_template='users/email/contributor.ltxt',
                            html_template='users/email/contributor.html',
                            send_to=user.email,
                            contributor=user)

                    return user
                else:
                    statsd.incr('user.activate-error.expired')
                    reason = 'key expired'
        else:
            statsd.incr('user.activate-error.invalid-key')
            reason = 'invalid key'

        log.warning(u'User activation failure ({r}): {k}'.format(
            r=reason, k=activation_key))

        return False
Validate an activation key and activate the corresponding
dataset/ETHPy150Open mozilla/kitsune/kitsune/users/models.py/RegistrationManager.activate_user