Пример #1
0
def email(request):
    authenticator = JSONAuthenticator()
    try:
        authenticator.validate(request)
    except AuthenticationException:
        return authenticator.error_response()
    return authenticator.response({"email":authenticator.user.email})    
Пример #2
0
def email(request):
    authenticator = JSONAuthenticator()
    print 'json auth'
    try:
        authenticator.validate(request)
    except AuthenticationException:
        return authenticator.error_response()
    return authenticator.response({"email":authenticator.user.email,'id':authenticator.user.id})    
Пример #3
0
def date_joined(request):
    scope = AccessRange.objects.get(key="date_joined")
    authenticator = JSONAuthenticator(scope=scope)
    try:
        authenticator.validate(request)
    except AuthenticationException:
        return authenticator.error_response()
    return authenticator.response({
        "date_joined":str(authenticator.user.date_joined)})
Пример #4
0
def last_login(request):
    scope = AccessRange.objects.get(key="last_login")
    authenticator = JSONAuthenticator(scope=scope)
    try:
        authenticator.validate(request)
    except AuthenticationException:
        return authenticator.error_response()
    data = {"date_joined":str(request.user.date_joined)}
    return authenticator.response({
        "last_login":str(authenticator.user.last_login)})
Пример #5
0
def email(request):
    print "in email" 
    authenticator = JSONAuthenticator()
    try:
        authenticator.validate(request)
    except AuthenticationException:
        return authenticator.error_response()
    response = authenticator.response({"email":authenticator.user.email})    
    print "returning ", response 
    return response
Пример #6
0
def email(request):
    print "in email"
    authenticator = JSONAuthenticator()
    try:
        authenticator.validate(request)
    except AuthenticationException:
        return authenticator.error_response()
    response = authenticator.response({"email": authenticator.user.email})
    print "returning ", response
    return response
Пример #7
0
def profile(request):
    authenticator = JSONAuthenticator()
    try:
        authenticator.validate(request)
    except AuthenticationException:
        return authenticator.error_response()
    return authenticator.response(
                {"email": authenticator.user.email,
                 "id": authenticator.user.id,
                 "name": authenticator.user.username,
                 "login": authenticator.user.username 
                })
Пример #8
0
def last_login(request):
    print "in last_login" 
    scope = AccessRange.objects.get(key="last_login")
    authenticator = JSONAuthenticator(scope=scope)
    try:
        authenticator.validate(request)
    except AuthenticationException:
        return authenticator.error_response()
    response = authenticator.response({
            "last_login":str(authenticator.user.last_login)})
    print "returning ", response
    return response
Пример #9
0
def last_login(request):
    print "in last_login"
    scope = AccessRange.objects.get(key="last_login")
    authenticator = JSONAuthenticator(scope=scope)
    try:
        authenticator.validate(request)
    except AuthenticationException:
        return authenticator.error_response()
    response = authenticator.response(
        {"last_login": str(authenticator.user.last_login)})
    print "returning ", response
    return response
Пример #10
0
def whoami(request):
    """Test authentication"""
    authenticator = JSONAuthenticator()
    try:
        authenticator.validate(request)
    except AuthenticationException:
        return authenticator.error_response()

    user = authenticator.access_token.user
    return authenticator.response({
        "user": user.username,
        "url": user.get_profile().get_absolute_url(),
        "image_url": user.get_profile().image_or_default()
    })
Пример #11
0
def whoami(request):
    """Test authentication"""
    authenticator = JSONAuthenticator()
    try:
        authenticator.validate(request)
    except AuthenticationException:
        return authenticator.error_response()

    user = authenticator.access_token.user
    return authenticator.response({
        "user":
        user.username,
        "url":
        user.get_profile().get_absolute_url(),
        "email":
        user.email,
        "image_url":
        user.get_profile().image_or_default()
    })
Пример #12
0
def userinfo(request):
    authenticator = JSONAuthenticator()  # XXX: Scope?
    try:
        authenticator.validate(request)
    except AuthenticationException:
        return authenticator.error_response()

    return authenticator.response({
        "email":
        authenticator.user.email,
        "username":
        authenticator.user.username,
        "first_name":
        authenticator.user.first_name,
        "last_name":
        authenticator.user.last_name,
        "is_staff":
        authenticator.user.is_staff,
        "is_active":
        authenticator.user.is_active,
        "is_superuser":
        authenticator.user.is_superuser
    })