Skip to content

Commit

Permalink
defined the view function of the login
Browse files Browse the repository at this point in the history
  • Loading branch information
Denisganga committed Jan 26, 2024
1 parent a8523aa commit fbaa1b5
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 2 deletions.
Binary file modified chatbot/__pycache__/views.cpython-311.pyc
Binary file not shown.
16 changes: 14 additions & 2 deletions chatbot/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
from django.contrib.auth.models import User


openai_api_key=''
openai_api_key='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'
openai.api_key =openai_api_key


Expand Down Expand Up @@ -35,7 +35,19 @@ def chatbot(request):


def login(request):
return render(request,'login.html')
if request.METHOD=='POST':
username=request.POST['username']
password=request.POST['password']
user=auth.authenticate(request,username=username,password=password)
if user is not None:
auth.login(request,user)
return redirect('chatbot')
else:
error_message='Invalid username or password'
return render(request,login.html,{'error_message':error_message})

else:
return render(request,'login.html')

def register(request):
if request.method=='POST':
Expand Down

0 comments on commit fbaa1b5

Please sign in to comment.