예제 #1
0
def login(request):
    form = AuthenticationForm(request, data=request.data)
    if form.is_valid():
        auth.login(request, form.user_cache)
        return Response(AuthenticatedUserSerializer(form.user_cache).data)
    else:
        return Response(form.get_errors_dict(),
                        status=status.HTTP_400_BAD_REQUEST)
예제 #2
0
파일: auth.py 프로젝트: fengrussell/Misago
def login(request):
    form = AuthenticationForm(request, data=request.data)
    if form.is_valid():
        auth.login(request, form.user_cache)
        return Response(AuthenticatedUserSerializer(form.user_cache).data)
    else:
        return Response(form.get_errors_dict(),
                        status=status.HTTP_400_BAD_REQUEST)
예제 #3
0
def login(request):
    """
    POST /auth/ with CSRF, username and password
    will attempt to authenticate new user
    """
    form = AuthenticationForm(request, data=request.data)
    if form.is_valid():
        auth.login(request, form.user_cache)
        return Response(AuthenticatedUserSerializer(form.user_cache).data, )
    else:
        return Response(
            form.get_errors_dict(),
            status=status.HTTP_400_BAD_REQUEST,
        )
예제 #4
0
파일: auth.py 프로젝트: qhhonx/Misago
def login(request):
    form = AuthenticationForm(request)

    if request.method == 'POST':
        form = AuthenticationForm(request, data=request.POST)
        if form.is_valid():

            message = _("Welcome back, %(user)s! You have been "
                        "signed in successfully.")
            messages.success(request,
                             message % {'user': form.user_cache.username})
            auth.login(request, form.user_cache)
            return redirect(settings.LOGIN_REDIRECT_URL)

    return render(request, 'misago/login.html', {'form': form})
예제 #5
0
def login(request):
    form = AuthenticationForm(request)

    if request.method == 'POST':
        form = AuthenticationForm(request, data=request.POST)
        if form.is_valid():

            message = _("Welcome back, %(user)s! You have been "
                        "signed in successfully.")
            messages.success(
                request, message % {'user': form.user_cache.username})
            auth.login(request, form.user_cache)
            return redirect(settings.LOGIN_REDIRECT_URL)

    return render(request, 'misago/login.html', {'form': form})
예제 #6
0
def login(request):
    """
    POST /auth/ with CSRF, username and password
    will attempt to authenticate new user
    """
    form = AuthenticationForm(request, data=request.data)
    if form.is_valid():
        auth.login(request, form.user_cache)
        return Response(
            AuthenticatedUserSerializer(form.user_cache).data,
        )
    else:
        return Response(
            form.get_errors_dict(),
            status=status.HTTP_400_BAD_REQUEST,
        )