Changeset 1729

Show
Ignore:
Timestamp:
12/22/06 05:55:49 (2 years ago)
Author:
wkornew
Message:

DbAuthPlugin:

Fixed typo.
Changed SQL style to match Trac.
Removed "Cancel" buttons from interface.

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • dbauthplugin/simple/dbauth/auth.py

    r1491 r1729  
    5252    password_changeable = BoolOption('dbauth', 'password_changeable', 'false', 
    5353        """Allow user to change his password.""") 
    54     algorithm = Option('dbauth', 'algorithm', 'md5', 
     54    algorithm = Option('dbauth', 'algorithm', 'sha', 
    5555        """Choose which hash algorithm to use. Possible options: 
    5656        md5, sha""") 
     
    9898                yield 'metanav', 'password', \ 
    9999                    Markup('<a href="%s">Password</a>' \ 
    100                             % escape(self.env.href.password())) 
     100                            % escape(req.href.password())) 
    101101            yield 'metanav', 'logout', Markup('<b><a href="%s">Logout</a></b>' \ 
    102                   % escape(self.env.href.logout())) 
     102                  % escape(req.href.logout())) 
    103103        else: 
    104104            yield 'metanav', 'login', Markup('<b><a href="%s">Login</a></b>' \ 
    105                   % escape(self.env.href.login())) 
     105                  % escape(req.href.login())) 
    106106 
    107107    # IRequestHandler methods 
     
    119119                referer = req.args.get('referer') 
    120120                if not referer or len(referer) == 0: 
    121                     referer = selv.env.href() 
     121                    referer = req.href() 
    122122                if self._check_login(uid, pwd): 
    123123                    self._do_login(req, uid) 
     
    141141        if not referer or referer.endswith('/login') or \ 
    142142                referer.endswith('/settings') or len(referer) == 0: 
    143             referer = self.env.href() 
     143            referer = req.href() 
    144144 
    145145        if req.path_info.startswith('/login'): 
     
    174174        db = get_db(self.env) 
    175175        cursor = db.cursor() 
    176         sql = 'SELECT %s FROM %s WHERE %s = %%s' % \ 
     176        sql = "SELECT %s FROM %s WHERE LOWER(%s) = LOWER(%%s)" % \ 
    177177              (self.users['password'], self.users['table'], 
    178178               self.users['username']) 
     
    191191        db = self.env.get_db_cnx() 
    192192        cursor = db.cursor() 
    193         cursor.execute('INSERT INTO auth_cookie ' \ 
    194                        '(cookie ,name ,ipnr ,time) ' \ 
    195                        'VALUES (%s, %s, %s, %s)'
     193        cursor.execute("INSERT INTO auth_cookie " 
     194                       "(cookie ,name ,ipnr ,time) " 
     195                       "VALUES (%s, %s, %s, %s)"
    196196                       (cookie, remote_user, req.remote_addr, 
    197197                        int(time.time()))) 
     
    199199 
    200200        req.outcookie['db_auth'] = cookie 
    201         req.outcookie['db_auth']['path'] = self.env.href() 
     201        req.outcookie['db_auth']['path'] = req.href() 
    202202        req.outcookie['db_auth']['expires'] = 100000000 
    203203 
     
    215215        db = self.env.get_db_cnx() 
    216216        cursor = db.cursor() 
    217         cursor.execute('DELETE FROM auth_cookie ' \ 
    218                        'WHERE name = %s OR time < %s'
     217        cursor.execute("DELETE FROM auth_cookie " 
     218                       "WHERE LOWER(name) = LOWER(%s) OR time < %s"
    219219                       (req.authname, int(time.time()) - self.session_lifetime)) 
    220220        db.commit() 
     
    225225        "expires" property to a date in the past.""" 
    226226        req.outcookie['db_auth'] = '' 
    227         req.outcookie['db_auth']['path'] = self.env.href() 
     227        req.outcookie['db_auth']['path'] = req.href() 
    228228        req.outcookie['db_auth']['expires'] = -10000 
    229229 
     
    234234        db = self.env.get_db_cnx() 
    235235        cursor = db.cursor() 
    236         cursor.execute('SELECT name, time FROM auth_cookie ' \ 
    237                        'WHERE cookie = %s'
     236        cursor.execute("SELECT name, time FROM auth_cookie " 
     237                       "WHERE cookie = %s"
    238238                       (cookie,)) 
    239239        row = cursor.fetchone() 
    240240        if not row or row[1] < int(time.time()) - self.session_lifetime: 
    241241            # the cookie has become invalid 
    242             cursor.execute('DELETE FROM auth_cookie ' \ 
    243                            'WHERE time < %s'
     242            cursor.execute("DELETE FROM auth_cookie " 
     243                           "WHERE time < %s"
    244244                           (int(time.time()) - self.session_lifetime,)) 
    245245            db.commit() 
     
    248248        elif row[1] < int(time.time()) - 60 * 60: 
    249249            # refresh session 
    250             cursor.execute('UPDATE auth_cookie ' \ 
    251                            'SET time = %s, ipnr = %s ' \ 
    252                            'WHERE cookie = %s'
     250            cursor.execute("UPDATE auth_cookie " 
     251                           "SET time = %s, ipnr = %s " 
     252                           "WHERE cookie = %s"
    253253                           (int(time.time()), req.remote_addr, cookie)) 
    254254            db.commit() 
    255255            req.outcookie['db_auth'] = cookie 
    256             req.outcookie['db_auth']['path'] = self.env.href() 
     256            req.outcookie['db_auth']['path'] = req.href() 
    257257            req.outcookie['db_auth']['expires'] = 100000000 
    258258            # Don't forget to check whether we have a new email address. 
     
    267267        db = get_db(self.env) 
    268268        cursor = db.cursor() 
    269         sql = 'SELECT %s FROM %s WHERE %s = %%s' % \ 
     269        sql = "SELECT %s FROM %s WHERE %s = %%s" % \ 
    270270              (email_field, self.users['table'], 
    271271               self.users['username']) 
     
    277277        db = self.env.get_db_cnx() 
    278278        cursor = db.cursor() 
    279         cursor.execute('DELETE FROM session_attribute ' \ 
    280                        'WHERE name="email" AND sid=%s AND authenticated=1'
     279        cursor.execute("DELETE FROM session_attribute " 
     280                       "WHERE name='email' AND sid=%s AND authenticated=1"
    281281                       (user,)) 
    282         cursor.execute('INSERT INTO session_attribute ' \ 
    283                        '(sid, authenticated, name, value) ' \ 
    284                        'VALUES (%s, 1, "email", %s)'
     282        cursor.execute("INSERT INTO session_attribute " 
     283                       "(sid, authenticated, name, value) " 
     284                       "VALUES (%s, 1, 'email', %s)"
    285285                       (user, email)) 
    286286        db.commit() 
     
    295295        db = get_db(self.env) 
    296296        cursor = db.cursor() 
    297         sql = 'UPDATE %s SET %s = %%s WHERE %s = %%s' % \ 
     297        sql = "UPDATE %s SET %s = %%s WHERE LOWER(%s) = LOWER(%%s)" % \ 
    298298              (self.users['table'], self.users['password'], 
    299299               self.users['username']) 
  • dbauthplugin/simple/dbauth/templates/login.cs

    r1488 r1729  
    2222    <input type="hidden" name="referer" value="<?cs var:referer ?>"> 
    2323    <input type="submit" name="login" value="Login" /> 
    24     <input type="submit" name="cancel" value="Cancel" /> 
    2524  </div> 
    2625</form> 
  • dbauthplugin/simple/dbauth/templates/password.cs

    r1040 r1729  
    2323  <div class="buttons"> 
    2424    <input type="submit" name="password" value="Change" /> 
    25     <input type="submit" name="cancel" value="Cancel" /> 
    2625  </div> 
    2726</form>