from django.shortcuts import render, redirect
from .models import UserModel
from django.http import HttpResponse



# Create your views here.

def display(request):
    return render(request,'user_app/display.html')

def logout(request):
    request.session.flush()
    return redirect('user:login')

def login(request):
    if request.method=='POST':
        e=request.POST.get('email')
        p=request.POST.get('pass')
        user = UserModel.objects.filter(email=e,password=p)
        
        if(user.count()>0):
            for user in user:
                request.session['email']=user.email
                request.session['id']=user.id
                request.session['username'] = user.username
                return redirect('photo_app:index')

        else:
            return HttpResponse("wrong Crdentials")
    else:
        return render(request,'user_app/login.html')
     
38662b2250cc7d94af9fdaa1daba7fdc72e91be9
<mask token>


def logout(request):
    request.session.flush()
    return redirect('user:login')


<mask token>

<mask token>


def display(request):
    return render(request, 'user_app/display.html')


def logout(request):
    request.session.flush()
    return redirect('user:login')


<mask token>

<mask token>


def display(request):
    return render(request, 'user_app/display.html')


def logout(request):
    request.session.flush()
    return redirect('user:login')


def login(request):
    if request.method == 'POST':
        e = request.POST.get('email')
        p = request.POST.get('pass')
        user = UserModel.objects.filter(email=e, password=p)
        if user.count() > 0:
            for user in user:
                request.session['email'] = user.email
                request.session['id'] = user.id
                request.session['username'] = user.username
                return redirect('photo_app:index')
        else:
            return HttpResponse('wrong Crdentials')
    else:
        return render(request, 'user_app/login.html')

from django.shortcuts import render, redirect
from .models import UserModel
from django.http import HttpResponse


def display(request):
    return render(request, 'user_app/display.html')


def logout(request):
    request.session.flush()
    return redirect('user:login')


def login(request):
    if request.method == 'POST':
        e = request.POST.get('email')
        p = request.POST.get('pass')
        user = UserModel.objects.filter(email=e, password=p)
        if user.count() > 0:
            for user in user:
                request.session['email'] = user.email
                request.session['id'] = user.id
                request.session['username'] = user.username
                return redirect('photo_app:index')
        else:
            return HttpResponse('wrong Crdentials')
    else:
        return render(request, 'user_app/login.html')

from django.shortcuts import render, redirect
from .models import UserModel
from django.http import HttpResponse



# Create your views here.

def display(request):
    return render(request,'user_app/display.html')

def logout(request):
    request.session.flush()
    return redirect('user:login')

def login(request):
    if request.method=='POST':
        e=request.POST.get('email')
        p=request.POST.get('pass')
        user = UserModel.objects.filter(email=e,password=p)
        
        if(user.count()>0):
            for user in user:
                request.session['email']=user.email
                request.session['id']=user.id
                request.session['username'] = user.username
                return redirect('photo_app:index')

        else:
            return HttpResponse("wrong Crdentials")
    else:
        return render(request,'user_app/login.html')
     