From 2b042a671423c76c622c6c45a53e0edb7e4270e6 Mon Sep 17 00:00:00 2001 From: Mark Huang Date: Wed, 8 Nov 2006 22:53:30 +0000 Subject: [PATCH] - Auth does not need to be a subclass of dict - use dict filter for looking up accounts --- PLC/Auth.py | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/PLC/Auth.py b/PLC/Auth.py index 87d0446..72e9d91 100644 --- a/PLC/Auth.py +++ b/PLC/Auth.py @@ -4,7 +4,7 @@ # Mark Huang # Copyright (C) 2006 The Trustees of Princeton University # -# $Id: Auth.py,v 1.5 2006/10/27 15:32:29 mlhuang Exp $ +# $Id: Auth.py,v 1.6 2006/10/31 23:07:43 mlhuang Exp $ # import crypt @@ -18,7 +18,7 @@ from PLC.Persons import Persons from PLC.Nodes import Node, Nodes from PLC.Sessions import Session, Sessions -class Auth(Parameter, dict): +class Auth(Parameter): """ Base class for all API authentication methods, as well as a class that can be used to represent Mixed(SessionAuth(), PasswordAuth()), @@ -27,7 +27,6 @@ class Auth(Parameter, dict): def __init__(self, auth = {}): Parameter.__init__(self, auth, "API authentication structure") - dict.__init__(auth) def check(self, method, auth, *args): method.type_check("auth", auth, @@ -68,7 +67,7 @@ class SessionAuth(Auth): method.caller = node elif session['person_id'] is not None and session['expires'] > time.time(): - persons = Persons(method.api, [session['person_id']], enabled = True).values() + persons = Persons(method.api, {'person_id': session['person_id'], 'enabled': True}).values() if not persons: raise PLCAuthenticationFailure, "No such account" person = persons[0] @@ -217,7 +216,7 @@ class PasswordAuth(Auth): assert auth.has_key('Username') # Get record (must be enabled) - persons = Persons(method.api, [auth['Username']], enabled = True) + persons = Persons(method.api, {'email': auth['Username'], 'enabled': True}) if len(persons) != 1: raise PLCAuthenticationFailure, "No such account" -- 2.45.2