Beispiel #1
0
    def get_by_auth_password(cls, auth_id, password):
        """Returns a user object, validating password.

        :param auth_id:
            Authentication id. In this application, the email
        :param password:
            Password to be checked.
        :returns:
            A user object, if found and password matches.
        :raises:
            ``auth.InvalidAuthIdError`` or ``auth.InvalidPasswordError``.
        """
        myclient = pymongo.MongoClient(server_config.mongodbURL)
        mydb = myclient[server_config.mongodbDB]
        mycol = mydb["users"]

        user_result = mycol.find_one({"email": auth_id})

        if user_result is None:
            raise auth.InvalidAuthIdError()

        if not security.check_password_hash(password, user_result['password']):
            raise auth.InvalidPasswordError()

        return User(user_result['user_id'], auth_id,
                    user_result['friendly_name'], user_result['level'])
Beispiel #2
0
    def update_password(self, password, new_password):
        """Update the password for the user if the existing password matches."""
        if not security.check_password_hash(password, self.password):
            raise auth.InvalidPasswordError()

        self.password = security.generate_password_hash(new_password,
                                                        length=12)
        self.put()
Beispiel #3
0
    def get_by_auth_password(cls, auth_id, password):
        user = cls.get_by_auth_id(auth_id)
        if user == None:
            raise auth.InvalidAuthIdError()

        if not security.check_password_hash(password, user.password):
            raise auth.InvalidPasswordError()

        return user
Beispiel #4
0
  def get_by_auth_password(cls, email, password):
    user = cls.get_by_email(email)
    if not user:
      raise auth.InvalidAuthIdError("No user with email '%s'." % (email))

    if not security.check_password_hash(password, user.password_hash):
      raise auth.InvalidPasswordError("Bad password for user '%s'." % (email))

    return user
Beispiel #5
0
    def get_by_auth_password(cls, auth_id, password):
        """Returns user, validating password.

        :raises:
            ``auth.InvalidAuthIdError`` or ``auth.InvalidPasswordError``.
        """
        user = cls.get_by_auth_id(auth_id)
        if not user:
            raise auth.InvalidAuthIdError()

        if not security.check_password_hash(password, user.password):
            raise auth.InvalidPasswordError()

        return user
Beispiel #6
0
    def get_by_password(self, firstname, lastname, password):
        u"""
		
		@param str firstname 名前
		@param str lastname  苗字
		@param str password パスワード
		@return User
		@raises auth.InvalidAuthIdError() | auth.InvalidPasswordError()
		"""

        user = cls.query(firstname == firstname and lastname == lastname).get()

        if not user:
            raise auth.InvalidAuthIdError()
        if not security.check_password_hash(password, user.password):
            raise auth.InvalidPasswordError()

        return user
Beispiel #7
0
    def get_by_auth_password(cls, auth_id, password):
        """Returns a user object, validating password.

        :param auth_id:
            Authentication id.
        :param password:
            Password to be checked.
        :returns:
            A user object, if found and password matches.
        :raises:
            ``auth.InvalidAuthIdError`` or ``auth.InvalidPasswordError``.
        """
        user = cls.get_by_auth_id(auth_id)
        if not user:
            raise auth.InvalidAuthIdError()

        if not security.check_password_hash(password, user.password):
            raise auth.InvalidPasswordError()

        return user