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'])
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
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
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
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
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