token
This commit is contained in:
parent
5583bc2b60
commit
794b50e041
@ -20,6 +20,7 @@ app.config.update({
|
|||||||
oidc = OpenIDConnect(app)
|
oidc = OpenIDConnect(app)
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
def calculate_nutrition(food, weight):
|
def calculate_nutrition(food, weight):
|
||||||
try:
|
try:
|
||||||
conn = psycopg2.connect()
|
conn = psycopg2.connect()
|
||||||
@ -133,6 +134,12 @@ def add_nutrition():
|
|||||||
def nutrition():
|
def nutrition():
|
||||||
return render_template('nutrition.html')
|
return render_template('nutrition.html')
|
||||||
|
|
||||||
|
@app.route('/get_token')
|
||||||
|
@oidc.require_login
|
||||||
|
def get_token():
|
||||||
|
return jsonify(token=oidc.get_access_token())
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
app = ProxyFix(app, x_for=1, x_host=1)
|
app = ProxyFix(app, x_for=1, x_host=1)
|
||||||
|
@ -13,6 +13,17 @@
|
|||||||
document.getElementById('submit-button').disabled = !allFilled;
|
document.getElementById('submit-button').disabled = !allFilled;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function getBearerToken(callback) {
|
||||||
|
fetch('/get_token')
|
||||||
|
.then(response => response.json())
|
||||||
|
.then(data => {
|
||||||
|
callback(data.token);
|
||||||
|
})
|
||||||
|
.catch(error => {
|
||||||
|
console.error('Fehler beim Abrufen des Tokens:', error);
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
function addNutritionEntry() {
|
function addNutritionEntry() {
|
||||||
|
|
||||||
const form = document.getElementById('nutrition-form');
|
const form = document.getElementById('nutrition-form');
|
||||||
@ -20,6 +31,9 @@
|
|||||||
|
|
||||||
fetch('/add_nutrition', {
|
fetch('/add_nutrition', {
|
||||||
method: 'POST',
|
method: 'POST',
|
||||||
|
headers: {
|
||||||
|
'Authorization': 'Bearer ' + token
|
||||||
|
},
|
||||||
body: formData
|
body: formData
|
||||||
}).then(response => {
|
}).then(response => {
|
||||||
// Behandlung der Serverantwort
|
// Behandlung der Serverantwort
|
||||||
|
Loading…
x
Reference in New Issue
Block a user