Пример #1
0
    def reset_success(self, passwordform):
        passwords_data = self.schema.serialize(passwordform)
        email_or_username = passwords_data['email_or_username']

        # If input is a mail address we need to normalize it (ie lower case etc)
        if validate_email_format(email_or_username):
            email_or_username = normalize_email(email_or_username)
        elif email_or_username.startswith(u'0'):
            email_or_username = normalize_to_e_164(self.request, email_or_username)

        try:
            filter_dict = {'$or': []}
            for field in self.SEARCH_FIELDS:
                filter_dict['$or'].append({field: email_or_username})

            user = self.request.userdb.get_user_by_filter(filter_dict)
        except self.request.userdb.exceptions.UserDoesNotExist:
            log.debug("User {!r} does not exist".format(email_or_username))
            user = None

        if user is not None:
            nin = None
            nins = user.get_nins()
            if nins:
                nin = nins[-1]
            if nin is not None:
                reset_password_link = new_reset_password_code(self.request, user, mechanism='govmailbox')
                send_reset_password_gov_message(self.request, nin, user, reset_password_link)

        self.request.session['_reset_type'] = _('Myndighetspost')
        return HTTPFound(location=self.request.route_url('reset-password-sent'))
Пример #2
0
    def _search_user(self, text):
        """
        Find a user matching email, mobile or NIN.

        @param text: search string
        @return: user object
        """
        if validate_email_format(text):
            user = self.request.userdb_new.get_user_by_mail(normalize_email(text), raise_on_missing=True)
        elif text.startswith(u'0') or text.startswith(u'+'):
            text = normalize_to_e_164(self.request, text)
            user = self.request.userdb_new.get_user_by_phone(text)
        else:
            user = self.request.userdb_new.get_user_by_nin(text)

        log.debug("Found user {!r} using input {!s}.".format(user, text))
        retrieve_modified_ts(user, self.request.dashboard_userdb)
        return user
Пример #3
0
    def _search_user(self, text):
        """
        Find a user matching email, mobile or NIN.

        @param text: search string
        @return: user object
        """
        if validate_email_format(text):
            user = self.request.userdb_new.get_user_by_mail(
                normalize_email(text), raise_on_missing=True)
        elif text.startswith(u'0') or text.startswith(u'+'):
            text = normalize_to_e_164(self.request, text)
            user = self.request.userdb_new.get_user_by_phone(text)
        else:
            user = self.request.userdb_new.get_user_by_nin(text)

        log.debug("Found user {!r} using input {!s}.".format(user, text))
        retrieve_modified_ts(user, self.request.dashboard_userdb)
        return user
Пример #4
0
    def _search_user(self, text):
        """
        Find a user matching email, mobile or NIN.

        @param text: search string
        @return: user object
        """
        if validate_email_format(text):
            user = self.request.userdb.get_user_by_email(normalize_email(text))
        elif text.startswith(u'0') or text.startswith(u'+'):
            text = normalize_to_e_164(self.request, text)
            user = self.request.userdb.get_user_by_filter(
                {'mobile': {'$elemMatch': {'mobile': text, 'verified': True}}}
            )
        else:
            user = self.request.userdb.get_user_by_nin(text)

        user.retrieve_modified_ts(self.request.db.profiles)
        log.debug("Found user {!r} using input {!s}.".format(user, text))
        return user
Пример #5
0
 def __call__(self, value):
     if isinstance(value, basestring):
         return utils.normalize_email(value)
     return value