Skip to content
This repository has been archived by the owner on Jul 13, 2022. It is now read-only.

Commit

Permalink
Use POST for signing in and out instead of GET
Browse files Browse the repository at this point in the history
  • Loading branch information
msoucy committed Dec 16, 2021
1 parent fab688f commit 8861a83
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 7 deletions.
10 changes: 7 additions & 3 deletions signinapp/static/qr.js
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ function populateUsers(userdata) {

function updateUserData() {
const event = "training"
fetch(`/users/${event}`, { method: "GET" })
fetch(`/users/${event}`)
.then(data => data.json())
.then(json => {
populateUsers(json)
Expand All @@ -41,8 +41,12 @@ function onScanSuccess(decodedText, decodedResult) {
setTimeout(function () { html5QrcodeScanner.resume() }, 2000);
}
const event = "training"
const b32name = encodeURIComponent(decodedText)
fetch(`/scan/${event}/${b32name}`, { method: "GET" })

let formData = new FormData();
formData.append('name', decodedText);
formData.append('event', event);

fetch(`/scan`, { method: "POST", body: formData})
.then(data => data.json())
.then(json => {
toast(json['message'])
Expand Down
9 changes: 5 additions & 4 deletions signinapp/views.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
#!/usr/bin/env python

from flask import Flask, jsonify
from flask import jsonify, request
from flask.templating import render_template

from . import app
Expand All @@ -12,10 +12,11 @@
def index():
return render_template("index.html")

@app.route("/scan/<event>/<name>")
def scan(event, name):
@app.route("/scan", methods=['POST'])
def scan():
event = request.values['event']
name = request.values['name']
(human, sign) = model.scan(event, name)
print(f"'{name}' signed {sign} to event '{event}'")

return jsonify({
'stamp': sign,
Expand Down

0 comments on commit 8861a83

Please sign in to comment.