Skip to content

Commit

Permalink
added new endpoint for login
Browse files Browse the repository at this point in the history
  • Loading branch information
GDcheeriosYT committed Jul 24, 2024
1 parent bde7940 commit cb228e8
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 4 deletions.
16 changes: 13 additions & 3 deletions main.py
Original file line number Diff line number Diff line change
Expand Up @@ -110,8 +110,8 @@ async def login(username, password):
return "incorrect info"


@app.route('/login', methods=['POST'])
def login_cookie():
@app.route('/api/account/login-form', methods=['POST'])
async def login_cookie():
username = request.form.get('nm')
password = request.form.get('pw')
login_result = asyncio.run(login(username, password))
Expand All @@ -125,6 +125,16 @@ def login_cookie():
return resp


@app.route("/api/account/login-json", methods=['POST'])
async def login_json():
username = request.json["username"]
password = request.json["psasword"]

login_result = asyncio.run(login(username, password))
if login_result != "incorrect info" and login_result is not None:
return login_result.jsonify()


@app.route("/account/signout")
async def signout():
resp = make_response(render_template('account/login.html'))
Expand Down Expand Up @@ -518,7 +528,7 @@ def update_client_status(data):

@socketio.on('match data get')
def get_livestatus(data):
emit('match data receive', asyncio.run(grabber(data, True)), ignore_queue=True)
emit('match data receive', asyncio.run(grabber(data, True)))


# </editor-fold>
Expand Down
2 changes: 1 addition & 1 deletion templates/account/login.html
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
<body>
{% block body %}
<h2 style="font-style: bold; color: red; text-align: center;">{{ warning }}</h2>
<form action = "/login" method = "POST">
<form action = "/api/account/login" method = "POST">
<p><h1>Enter username</h1></p>
<p><input type = 'text' name = 'nm'/></p>
<p><h1>Enter password</h1></p>
Expand Down

0 comments on commit cb228e8

Please sign in to comment.