Example #1
0
File: views.py Project: Ogochi/www2
def login(request):
    user = authenticate(username=request.POST['username'], password=request.POST['password'])
    if user is not None:
        login_to_session(request, user)
        loginSuccess = True
    else:
        loginError = True
    return render(request, 'accountManagement.html', locals())
Example #2
0
def login(request):
    user = authenticate(username=request.POST['username'],
                        password=request.POST['password'])
    if user is not None:
        login_to_session(request, user)
    else:
        error = True
    return render(request, 'flightTable/login.html', locals())
Example #3
0
File: views.py Project: Ogochi/www2
def register(request):
    if User.objects.all().filter(username=request.POST['username']).exists():
        registerError = True
    else:
        user = User.objects.create_user(
            username=request.POST['username'], password=request.POST['password'])
        login_to_session(request, user)
        registerSuccess = True
    return render(request, 'accountManagement.html', locals())
Example #4
0
def login(request):
    if request.method == "POST":
        user = authenticate(username=request.POST['username'],
                            password=request.POST['password'])
        if user is not None:
            login_to_session(request, user)
            return redirect('wall')
        else:
            error = True

    return render(request, 'login.html', locals())
Example #5
0
def register(request):
    if request.method == 'POST':
        form = RegistrationForm(request.POST)
        if form.is_valid():
            user = User.objects.create_user(username=request.POST['username'],
                                            password=request.POST['password'])
            login_to_session(request, user)
            return redirect('main')
    else:
        form = RegistrationForm()
    return render(request, 'flightTable/register.html', locals())
Example #6
0
def register(request):
    if request.method == "POST":
        username = slugify(request.POST['username'])
        user = authenticate(username=username,
                            password=request.POST['password'])
        form = RegistrationForm(request.POST)
        if form.is_valid():
            user = User.objects.create_user(username=username,
                                            password=request.POST['password'])
            login_to_session(request, user)

            payload = {'name': username, 'mail': request.POST['mail']}
            h = {"Content-Type": "application/json"}
            r = requests.put('http://users:80/user/' + username,
                             data=json.dumps(payload),
                             headers=h)
            return redirect('wall')

    return render(request, 'register.html', locals())