コード例 #1
0
ファイル: auth.py プロジェクト: ILikePizza555/Tarnhelm
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
ファイル: auth.py プロジェクト: ILikePizza555/Tarnhelm
def anonymous_login(request):
    login = LoginToken(is_anonymous = True);
    login.full_clean();
    login.save();
    request.session["lt"] = login.id;