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

« back to all changes in this revision

Viewing changes to ivle/db.py

  • Committer: me at id
  • Date: 2009-01-15 01:06:33 UTC
  • mto: This revision was merged to the branch mainline in revision 1090.
  • Revision ID: svn-v3-trunk0:2b9c9e99-6f39-0410-b283-7f802c844ae2:branches%2Fstorm:1144
ivle.auth.* now uses Storm, and not ivle.(db|user). This changes the interface
    somewhat (lots of things take a 'store' argument), so fix callers.

ivle.db: Remove user_authenticate; it's now a method of ivle.database.User.

Show diffs side-by-side

added added

removed removed

Lines of Context:
437
437
            return userdict     # Query string
438
438
        return userdict['loginid']
439
439
 
440
 
    def user_authenticate(self, login, password, dry=False):
441
 
        """Performs a password authentication on a user. Returns True if
442
 
        "passhash" is the correct passhash for the given login, False
443
 
        if the passhash does not match the password in the DB,
444
 
        and None if the passhash in the DB is NULL.
445
 
        Also returns False if the login does not exist (so if you want to
446
 
        differentiate these cases, use get_user and catch an exception).
447
 
        """
448
 
        query = ("SELECT passhash FROM login WHERE login = %s;"
449
 
            % _escape(login))
450
 
        if dry: return query
451
 
        result = self.db.query(query)
452
 
        if result.ntuples() == 1:
453
 
            # Valid username. Check password.
454
 
            passhash = result.getresult()[0][0]
455
 
            if passhash is None:
456
 
                return None
457
 
            return _passhash(password) == passhash
458
 
        else:
459
 
            return False
460
 
 
461
440
    # PROBLEM AND PROBLEM ATTEMPT FUNCTIONS #
462
441
 
463
442
    def get_problem_problemid(self, exercisename, dry=False):