Esempio n. 1
0
def Registration(request):
    form = RegistrationForm(data=request.POST)
    if form.is_valid():
        form.save()
        users=User.objects.get(username=request.POST['username'])
        users.set_password(request.POST['password'])
        users.save()
        u=authenticate(username=request.POST['username'],password=request.POST['password'])
        if u is not None:
            if u.is_active:
                logare(request,u)
            else:
                return HttpResponse('bug')
        else:
            return HttpResponse('sec')
        return HttpResponse('ok')
    return HttpResponse(form.errors)
Esempio n. 2
0
def login(request):
    form=UserLogin(data=request.POST)
    if form.is_valid():
        logare(request,form.scoate_user())
        return HttpResponse('ok')
    return HttpResponse(form.errors)