예제 #1
0
def registered_login(request, username, password):
    """
    Logins in a user with the specified username and password. If the login succedes, a user object will be available in request.user. 
    
    Params:
        request:    HTTPRequest object
        username:   A string representing a username
        password:   A string represnting a password
    
    Throws:
        RegisteredUser.DoesNotExist:    If the specified username could not be found
        InvalidPasswordException:       If the password provides is invalid
    """
    user = RegisteredUser.objects.get(name=username);
        
    if user.verify_password(password):
        login = LoginToken(uid = user.uid, is_anonymous = False);
        login.full_clean();
        login.save();
        request.session["lt"] = login.id;
    else:
        raise InvalidPasswordException("Invalid Password for " + user.name);
예제 #2
0
def anonymous_login(request):
    login = LoginToken(is_anonymous = True);
    login.full_clean();
    login.save();
    request.session["lt"] = login.id;