コード例 #1
0
def oauth_register(request, backend):
    '''
    注册和登录时都不应该是登录后的状态
    '''
    context = {'next': request.session.get('next', '')}
    if request.user.is_authenticated():
        return render_to_response('xuetangx/oauth/oauth_login_success.html', context)
    return auth(request, backend)
コード例 #2
0
def oauth_register(request, backend):
    """
    注册和登录时都不应该是登录后的状态
    """
    context = {"next": request.session.get("next", "")}
    if request.user.is_authenticated():
        return render_to_response("oauth/oauth_login_success.html", context)
    return auth(request, backend)
コード例 #3
0
def oauth_register(request, backend):
    '''
    注册和登录时都不应该是登录后的状态
    '''
    context = {'next': request.session.get('next', '')}
    if request.user.is_authenticated():
        return render_to_response('xuetangx/oauth/oauth_login_success.html',
                                  context)
    return auth(request, backend)
コード例 #4
0
ファイル: social.py プロジェクト: 2vitalik/starboxx
def social_auth_begin(request, backend):
    """ wrap social-auth function """
    try:
        if request.user.is_authenticated():
            messages.error(request, 'You are already signed in.')
            return redirect('profile')
        return auth(request, backend)
    except Exception as e:
        messages.error(request, e.message or e.msg)
        return redirect('signin')
コード例 #5
0
ファイル: views.py プロジェクト: BramaBrama/spicy.core
def signin_social(request, backend):
    real_ip = request.META.get('REMOTE_ADDR')
    if real_ip and BlacklistedIP.objects.filter(ip=real_ip).exists():
        return HttpResponseRedirect(reverse('profile:public:signup'))

    request.session.set_test_cookie()
    # Set redirect to previous URL unless it's already set in session.
    redirect_to = request.REQUEST.get(REDIRECT_FIELD_NAME,
                                      request.META.get('HTTP_REFERER', ''))
    if redirect_to and not request.session.get(REDIRECT_FIELD_NAME):
        request.session[REDIRECT_FIELD_NAME] = redirect_to
        request.session['newuser-next'] = redirect_to

    from social_auth import views as sa_views
    return sa_views.auth(request, backend)
コード例 #6
0
ファイル: account.py プロジェクト: JamesX88/tes
def steam_login(request):
    """
        This view is a wrapper to social_auths auth
        It is required, because social_auth just throws ValueError and gets user to 500 error
        after every unexpected action. This view handles exceptions in human friendly way.
        See https://convore.com/django-social-auth/best-way-to-handle-exceptions/
    """
    from social_auth.views import auth

    try:
        # if everything is ok, then original view gets returned, no problem
        return auth(request, 'steam')
    except ValueError, error:
        # in case of errors, let's show a special page that will explain what happened
        return HttpResponseRedirect(reverse('steam-is-down'))
コード例 #7
0
ファイル: views.py プロジェクト: spicycms/spicy.core
def signin_social(request, backend):
    real_ip = request.META.get('REMOTE_ADDR')
    if real_ip and BlacklistedIP.objects.filter(ip=real_ip).exists():
        return HttpResponseRedirect(reverse('profile:public:signup'))

    request.session.set_test_cookie()
    # Set redirect to previous URL unless it's already set in session.
    redirect_to = request.REQUEST.get(
        REDIRECT_FIELD_NAME, request.META.get('HTTP_REFERER', ''))
    if redirect_to and not request.session.get(REDIRECT_FIELD_NAME):
        request.session[REDIRECT_FIELD_NAME] = redirect_to
        request.session['newuser-next'] = redirect_to

    from social_auth import views as sa_views
    return sa_views.auth(request, backend)
コード例 #8
0
ファイル: views.py プロジェクト: DDI-development/kickme
def social_auth_login(request, backend):
    """
        This view is a wrapper to social_auths auth
        It is required, because social_auth just throws ValueError and gets user to 500 error
        after every unexpected action. This view handles exceptions in human friendly way.
        See https://convore.com/django-social-auth/best-way-to-handle-exceptions/
    """
    from social_auth.views import auth

    try:
        # if everything is ok, then original view gets returned, no problem
        return auth(request, backend)
    except ValueError, error:
        # in case of errors, let's show a special page that will explain what happened
        return render_to_response('users/login_error.html',
            locals(),
            context_instance=RequestContext(request))
コード例 #9
0
def social_auth_login(request, backend):
    """
        This view is a wrapper to social_auths auth
        It is required, because social_auth just throws ValueError and gets user to 500 error
        after every unexpected action. This view handles exceptions in human friendly way.
        See https://convore.com/django-social-auth/best-way-to-handle-exceptions/
    """
    from social_auth.views import auth

    try:
        # if everything is ok, then original view gets returned, no problem
        return auth(request, backend)
    except ValueError as error:
        # in case of errors, let's show a special page that will explain what happened
        return render_to_response('users/login_error.html',
                                  locals(),
                                  context_instance=RequestContext(request))
コード例 #10
0
def login_pinterest(request):
    if request.GET.get('next'):
        request.session['pinterest_next'] = request.GET.get('next')

    from social_auth.views import auth
    return auth(request, 'pinterest')
コード例 #11
0
def oauth_bind(request, backend):
    """
    绑定时需要时登录状态
    """
    return auth(request, backend)
コード例 #12
0
def login_facebook(request):
    if request.GET.get('next'):
        request.session['facebook_next'] = request.GET.get('next')

    from social_auth.views import auth
    return auth(request, 'facebook')
コード例 #13
0
def oauth_bind(request, backend):
    '''
    绑定时需要时登录状态
    '''
    return auth(request, backend)
コード例 #14
0
ファイル: views.py プロジェクト: Cruel/Anondex
def auth_register(request, backend):
    request.session['new_username'] = request.POST['username'] or SOCIAL_AUTH_DEFAULT_USERNAME
    return auth(request, backend)
コード例 #15
0
def login_twitter(request):
    if request.GET.get('next'):
        request.session['twitter_next'] = request.GET.get('next')

    from social_auth.views import auth
    return auth(request, 'twitter')
コード例 #16
0
ファイル: views.py プロジェクト: panuta/storypresso
def login_facebook(request):
    if request.GET.get('next'):
        request.session['facebook_next'] = request.GET.get('next')

    from social_auth.views import auth
    return auth(request, 'facebook')
コード例 #17
0
def oauth_bind(request, backend):
    '''
    绑定时需要时登录状态
    '''
    return auth(request, backend)
コード例 #18
0
def login_instagram(request):
    if request.GET.get('next'):
        request.session['instagram_next'] = request.GET.get('next')

    from social_auth.views import auth
    return auth(request, 'instagram')