Changeset 204
- Timestamp:
- 08/10/08 04:56:53 (3 months ago)
- Files:
-
- trunk/antimatter/luke/myplugs/libtracker/auth.py (modified) (4 diffs)
- trunk/antimatter/luke/myplugs/libtracker/entry.py (modified) (1 diff)
- trunk/antimatter/luke/myplugs/libtracker/tracker.py (modified) (1 diff)
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
trunk/antimatter/luke/myplugs/libtracker/auth.py
r203 r204 7 7 from gozerbot.persistconfig import PersistConfig 8 8 9 from user import User 9 from myplugs.libtracker.user import User 10 11 from myplugs.libtracker.entry import pass_check, pass_set 10 12 11 13 authenticated = Persist(datadir + '/authenticated') … … 14 16 if not config.has_key('max_auth'): 15 17 config.define('max_auth',86400) 18 19 if not config.has_key('pass_auth'): 20 config.define('pass_auth', True) 16 21 17 22 if not authenticated.data: … … 45 50 return False 46 51 else: 52 47 53 username = reply.txt 54 if config.get('pass_auth'): 55 valid = pass_authenticate(bot, ievent, username) 56 if not valid: 57 ievent.reply("Bad username/password, authenticate again") 58 return False 48 59 49 60 bot.say(ievent.nick, "You have been authenticated for 1 day.") … … 51 62 52 63 return True 64 65 def pass_authenticate(bot, ievent, username): 66 bot.say(ievent.nick, "Password?") 67 reply = waitforuser(bot, ievent.userhost, 30) 68 if (reply == None): 69 ievent.reply("No Password") 70 return False 71 res = pass_check(username) 72 if not res.data == reply.txt: 73 return False 74 ievent.reply(repr(res.data)) 75 return True 76 77 def set_pass(bot, ievent): 78 bot.say(ievent.nick, "Username") 79 name = waitforuser(bot, ievent.userhost, 30) 80 name = name.txt 81 bot.say(ievent.nick, "New Password?") 82 passwd = waitforuser(bot, ievent.userhost, 30) 83 passwd = passwd.txt 84 result = pass_set(name, passwd) 85 if result.error: 86 bot.say(ievent.nick, result.error) 87 else: 88 bot.say(ievent.nick, "%s set to %s : %s" % (name, passwd, result.data)) 53 89 54 90 def check_auth(ievent): trunk/antimatter/luke/myplugs/libtracker/entry.py
r196 r204 24 24 result = restconn.delete(recordnum) 25 25 return result 26 27 def pass_set(user, password): 28 restconn = RestClient(baseurl + '/users') 29 result = restconn.add(name=user, passwd=password) 30 return result 31 32 def pass_check(user, password): 33 restconn = RestClient(baseurl + '/users') 34 result = restconn.get(user) 35 return result 36 37 trunk/antimatter/luke/myplugs/libtracker/tracker.py
r186 r204 21 21 auth.del_auth(ievent) 22 22 23 cmnds.add('auth', authenticate, 'USER') 24 cmnds.add('unauth', unauthenticate, 'USER') 23 def password_set(bot, ievent): 24 auth.set_pass(bot, ievent) 25 26 cmnds.add('lt-auth', authenticate, 'USER') 27 cmnds.add('lt-unauth', unauthenticate, 'USER') 28 cmnds.add('lt-pass', password_set, 'USER') 25 29 26 30 #Check for commands in timeparser.msgparse as well