Software Freedom Law Center

Changeset 148

Show
Ignore:
Timestamp:
06/11/08 16:38:51 (2 months ago)
Author:
landon
Message:

Filled out more authentication functions

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • trunk/antimatter/luke/myplugs/libtracker/auth.py

    r147 r148  
    88    """ Not authentication, just checks that the name exists 
    99    Input: Bot, Ircevent 
    10     Output: User (or None if authentication failed) 
     10    Output: bool 
    1111    """ 
    12     bot.say(ievent.nick,"Username?",how='msg') 
    13     #rlog(99,"Debug","Testing for auth reload") 
    14     username = waitforuser(bot, ievent.userhost, 30) 
    15     if (username == None): 
    16         bot.say(ievent.nick,"You have failed to provide a username, do you want to try again? (y/n)") 
    17         response = waitforuser(bot, ievent.userhost, 10) 
    18         if (not response == None): 
    19             if (response.txt == "y"): 
    20                 username = authenticate_name(bot, ievent) 
     12    user = check_auth(ievent) 
     13    if (not user == None): 
     14        bot.say(ievent.nick, "You're still authenticated") 
     15        #TODO: Tell how long until authentication ends 
     16        return True 
     17    bot.say(ievent.nick, "Username?") 
     18    reply = waitforuser(bot, ievent.userhost, 30) 
     19    if (reply == None): 
     20        bot.say(ievent.nick, "You have failed to provide a username, do you want to try again? (y/n)") 
     21        reply = waitforuser(bot, ievent.userhost, 10) 
     22        if (not reply == None): 
     23            if (reply.txt == "y"): 
     24                if (not authenticate_name(bot, ievent)): 
     25                    return False 
     26            else: 
     27                return False 
    2128    else: 
    22         username = username.txt 
     29        username = reply.txt 
    2330 
    24     user = User(username) 
    25     return user 
     31    set_auth(ievent, User(username)) 
     32 
     33    return True 
    2634 
    2735def check_auth(ievent): 
    2836    """ Checks to see if the user is already authenticated 
    2937    Input: Ircevent 
    30     Output: User 
     38    Output: User (or None if the user is not authenticated) 
    3139    """ 
    32     pass 
     40    try: 
     41        user = authenticated[ievent.userhost] 
     42    except KeyError: 
     43        user = None 
    3344 
    34 def set_auth(ievent): 
     45def set_auth(ievent, user): 
    3546    """ Puts the userhost into the authentication dictionary 
    36     Input: Ircevent 
    37     Output: bool 
     47    Input: Ircevent, User 
    3848    """ 
    39     pass 
     49    authenticated[ievent.userhost] = user 

SFLC Main Page

[frdm] Support SFLC