Mercurial > public > src > rhodecode
comparison pylons_app/lib/auth.py @ 45:a886f5eba757
implemented admin page login
author | marcink |
---|---|
date | Wed, 07 Apr 2010 17:28:10 +0200 |
parents | d924b931b488 |
children | 9db7782727b3 |
comparison
equal
deleted
inserted
replaced
44:d924b931b488 | 45:a886f5eba757 |
---|---|
21 cur.execute("SELECT * FROM users WHERE username=?", (username,)) | 21 cur.execute("SELECT * FROM users WHERE username=?", (username,)) |
22 data = cur.fetchone() | 22 data = cur.fetchone() |
23 except sqlite3.OperationalError as e: | 23 except sqlite3.OperationalError as e: |
24 data = None | 24 data = None |
25 log.error(e) | 25 log.error(e) |
26 | |
27 if data: | 26 if data: |
28 if data[3]: | 27 if data[3]: |
29 if data[1] == username and data[2] == password_crypt: | 28 if data[1] == username and data[2] == password_crypt: |
30 log.info('user %s authenticated correctly', username) | 29 log.info('user %s authenticated correctly', username) |
31 | 30 if environ: |
32 http_accept = environ.get('HTTP_ACCEPT') | 31 http_accept = environ.get('HTTP_ACCEPT') |
33 | 32 |
34 if http_accept.startswith('application/mercurial') or \ | 33 if http_accept.startswith('application/mercurial') or \ |
35 environ['PATH_INFO'].find('raw-file') != -1: | 34 environ['PATH_INFO'].find('raw-file') != -1: |
36 cmd = environ['PATH_INFO'] | 35 cmd = environ['PATH_INFO'] |
37 for qry in environ['QUERY_STRING'].split('&'): | 36 for qry in environ['QUERY_STRING'].split('&'): |
38 if qry.startswith('cmd'): | 37 if qry.startswith('cmd'): |
39 cmd += "|" + qry | 38 cmd += "|" + qry |
40 | |
41 try: | |
42 cur.execute('''INSERT INTO | |
43 user_logs | |
44 VALUES(?,?,?,?)''', | |
45 (None, data[0], cmd, datetime.now())) | |
46 conn.commit() | |
47 except Exception as e: | |
48 conn.rollback() | |
49 log.error(e) | |
50 | |
51 | 39 |
40 try: | |
41 cur.execute('''INSERT INTO | |
42 user_logs | |
43 VALUES(?,?,?,?)''', | |
44 (None, data[0], cmd, datetime.now())) | |
45 conn.commit() | |
46 except Exception as e: | |
47 conn.rollback() | |
48 log.error(e) | |
49 | |
52 return True | 50 return True |
53 else: | 51 else: |
54 log.error('user %s is disabled', username) | 52 log.error('user %s is disabled', username) |
55 | 53 |
56 return False | 54 return False |