~azzar1/unity/add-show-desktop-key

« back to all changes in this revision

Viewing changes to www/auth/authenticate.py

  • Committer: drtomc
  • Date: 2008-02-20 09:41:48 UTC
  • Revision ID: svn-v3-trunk0:2b9c9e99-6f39-0410-b283-7f802c844ae2:trunk:522
Add quite a lot of stuff to get usrmgt happening.

login.py: A little bit of robustifying logic that logs you out if your account
    is still pending when you try to auth. Basically, this forces usrmgt-server
    to have another try.

authenticate.py: A small code rearrangement to produce the right behaviour
    (a generic login/passwd error) when an unknown user logs in (better than
    an internal server error :-) ).

usrmgt-server, makeuser.py: Lots of stuff to setup users. Quite a bit of stuff
    that should be db-driven is hard coded at the moment. (Only a week and a
    half till students will be hitting it, and we can't do everything!)

setup.py: Add an extra bit of svn related config.

users.sql,user.py,db.py: Add the svn_pass column to allow ivle to auth to the
    subversion server.

studpath.py: update a couple of comments to reflect a newer view of the world.

python-console: Add some timeout magic. Actually, I don't think this works,
    but it's well after bedtime, and I've still got to ride home from work.
    The morning will be soon enough.

Show diffs side-by-side

added added

removed removed

Lines of Context:
71
71
    # (This should not spawn a DB connection on each page reload, only when
72
72
    # there is no session object to begin with).
73
73
    dbconn = common.db.DB()
74
 
    user = dbconn.get_user(login)
 
74
 
75
75
    try:
 
76
        user = dbconn.get_user(login)
76
77
        for m in auth_modules:
77
78
            # May raise an AuthError - allow to propagate
78
79
            auth_result = m(dbconn, login, password, user)
86
87
                    # If user is not None, then it must return the same user
87
88
                    raise AuthError("Internal error: "
88
89
                        "Bad authentication module (changed user)")
89
 
                if user is None:
 
90
                elif user is None:
90
91
                    # We just got ourselves some user details from an external
91
92
                    # source. Put them in the DB.
92
93
                    # TODO: Write user to DB
97
98
                    "Bad authentication module (bad return type)")
98
99
        # No auths checked out; fail.
99
100
        raise AuthError()
 
101
    except common.db.DBException:
 
102
        # If our attempt to get the named user from the db fails,
 
103
        # then the login name is unknown.
 
104
        raise AuthError()
100
105
    finally:
101
106
        dbconn.close()
102
107