コード例 #1
0
ファイル: user.py プロジェクト: sgerlach/crits
    def create_user(cls, username, password, email=None, analyst=None):
        """
        Create (and save) a new user with the given username, password and
        email address.
        """

        now = datetime_now()

        # Normalize the address by lowercasing the domain part of the email
        # address.
        if email is not None:
            try:
                email_name, domain_part = email.strip().split('@', 1)
            except ValueError:
                pass
            else:
                email = '@'.join([email_name, domain_part.lower()])

        user = cls(username=username, email=email, date_joined=now)
        user.create_api_key("default", analyst, default=True)
        if password and user.set_password(password):
            user.save(username=analyst)
            return user
        elif CRITsConfig.remote_user:
            user.save(username="******")
            return user
        else:
            return None
コード例 #2
0
ファイル: documents.py プロジェクト: lig/picket2014
 def create_user(cls, email, display_name, password):
     """Create (and save) a new user with the given email address, display
     name and password.
     """
     now = datetime_now()
     email = cls.normalize_email(email)
     user = cls(email=email, display_name=display_name, date_joined=now)
     user.set_password(password)
     user.save()
     return user
コード例 #3
0
ファイル: user.py プロジェクト: TonyPythoneer/python-utils
 def set_password(self, raw_password):
     """Sets the user's password - always use this rather than directly
     assigning to :attr:`~mongoengine.django.auth.User.password` as the
     password is hashed before storage.
     """
     now = datetime_now()
     self.password = make_password(raw_password)
     self.changed_pwd_at = now
     self.save()
     return self
コード例 #4
0
ファイル: user.py プロジェクト: TonyPythoneer/python-utils
    def login(cls, username, password):
        """Create (and save) a new user with the given username, password and
        email address.
        """
        now = datetime_now()

        if username:
            user = cls.objects(username=username).first()
        else:
            return None

        if not user.check_password:
            return None

        user.last_login = now
        user.save()

        return user
コード例 #5
0
ファイル: user.py プロジェクト: TonyPythoneer/python-utils
    def create_user(cls, username, password, email=None):
        """Create (and save) a new user with the given username, password and
        email address.
        """
        now = datetime_now()

        # Normalize the address by lowercasing the domain part of the email
        # address.
        if email is not None:
            try:
                email_name, domain_part = email.strip().split('@', 1)
            except ValueError:
                pass
            else:
                email = '@'.join([email_name, domain_part.lower()])

        user = cls(username=username, email=email,
                   date_joined=now, changed_pwd_at=now)
        user.set_password(password)
        user.save()
        return user