Compare commits

..

2 Commits

Author SHA1 Message Date
e7f0f81d85 4.46.4
All checks were successful
Build-Release-Image / Build-Image (linux/amd64) (push) Successful in 2m53s
Build-Release-Image / Build-Image (linux/arm64) (push) Successful in 3m13s
Build-Release-Image / Merge-Images (push) Successful in 12s
Build-Release-Image / Create-Release (push) Successful in 9s
Build-Release-Image / Notify (push) Successful in 2s
2024-07-13 12:00:06 +01:00
e82190f227 4.46.3
All checks were successful
Build-Release-Image / Build-Image (linux/amd64) (push) Successful in 2m51s
Build-Release-Image / Build-Image (linux/arm64) (push) Successful in 3m20s
Build-Release-Image / Merge-Images (push) Successful in 13s
Build-Release-Image / Create-Release (push) Successful in 9s
Build-Release-Image / Notify (push) Successful in 4s
2024-07-12 12:00:06 +01:00
4 changed files with 34 additions and 28 deletions

View File

@ -5,7 +5,6 @@ import arrow
from flask import Blueprint, request, jsonify, g
from flask_login import current_user
from app import constants
from app.db import Session
from app.models import ApiKey
@ -19,9 +18,10 @@ def authorize_request() -> Optional[Tuple[str, int]]:
api_key = ApiKey.get_by(code=api_code)
if not api_key:
if current_user.is_authenticated and request.headers.get(
constants.HEADER_ALLOW_API_COOKIES
):
if current_user.is_authenticated:
# if current_user.is_authenticated and request.headers.get(
# constants.HEADER_ALLOW_API_COOKIES
# ):
g.user = current_user
else:
return jsonify(error="Wrong api key"), 401

View File

@ -1,7 +1,13 @@
from app.onboarding.base import onboarding_bp
from flask import render_template
from flask import render_template, url_for, redirect
@onboarding_bp.route("/", methods=["GET"])
def index():
return render_template("onboarding/index.html")
# Do the redirect to ensure cookies are set because they are SameSite=lax/strict
return redirect(url_for("onboarding.setup"))
@onboarding_bp.route("/setup", methods=["GET"])
def setup():
return render_template("onboarding/setup.html")

View File

@ -51,14 +51,19 @@ $(".enable-disable-alias").change(async function () {
await disableAlias(aliasId, alias);
});
function getHeaders() {
return {
"Content-Type": "application/json",
"X-Sl-Allowcookies": 'allow',
}
}
async function disableAlias(aliasId, alias) {
let oldValue;
try {
let res = await fetch(`/api/aliases/${aliasId}/toggle`, {
method: "POST",
headers: {
"Content-Type": "application/json",
}
headers: getHeaders()
});
if (res.ok) {
@ -94,9 +99,7 @@ $(".enable-disable-pgp").change(async function (e) {
try {
let res = await fetch(`/api/aliases/${aliasId}`, {
method: "PUT",
headers: {
"Content-Type": "application/json",
},
headers: getHeaders(),
body: JSON.stringify({
disable_pgp: oldValue,
}),
@ -129,9 +132,7 @@ $(".pin-alias").change(async function () {
try {
let res = await fetch(`/api/aliases/${aliasId}`, {
method: "PUT",
headers: {
"Content-Type": "application/json",
},
headers: getHeaders(),
body: JSON.stringify({
pinned: newValue,
}),
@ -161,9 +162,7 @@ async function handleNoteChange(aliasId, aliasEmail) {
try {
let res = await fetch(`/api/aliases/${aliasId}`, {
method: "PUT",
headers: {
"Content-Type": "application/json",
},
headers: getHeaders(),
body: JSON.stringify({
note: note,
}),
@ -200,9 +199,7 @@ async function handleMailboxChange(aliasId, aliasEmail) {
try {
let res = await fetch(`/api/aliases/${aliasId}`, {
method: "PUT",
headers: {
"Content-Type": "application/json",
},
headers: getHeaders(),
body: JSON.stringify({
mailbox_ids: mailbox_ids,
}),
@ -225,9 +222,7 @@ async function handleDisplayNameChange(aliasId, aliasEmail) {
try {
let res = await fetch(`/api/aliases/${aliasId}`, {
method: "PUT",
headers: {
"Content-Type": "application/json",
},
headers: getHeaders(),
body: JSON.stringify({
name: name,
}),

View File

@ -19,7 +19,10 @@
<div class="mt-8 text-center">
{% if current_user != None and current_user.is_authenticated %}
<h2 class="text-black-50" style="font-size:2rem">Performing the extension setup...</h2>
<h2 class="text-black-50" style="font-size:2rem">
Automatically performing extension setup.
If the setup doesn't start in a couple seconds click <a onclick="sendSetupMessage()" class="text-primary">here</a>
</h2>
{% else %}
<a class="mx-6 p-4 text-decoration-none"
style="background:black;
@ -41,6 +44,10 @@
{% if current_user != None and current_user.is_authenticated %}
<script type="text/javascript">
function sendSetupMessage(){
const data = { tag: "PERFORM_EXTENSION_SETUP" };
window.postMessage(data, "/");
}
let counterIterations = 5;
let extensionSetupIntervalId = setInterval(function() {
counterIterations--;
@ -48,9 +55,7 @@
clearInterval(extensionSetupIntervalId);
return;
}
const data = { tag: "PERFORM_EXTENSION_SETUP" };
window.postMessage(data, "/");
sendSetupMessage()
}, 300); // Send it many times, in case the extension had not registered the listener yet
</script>
{% endif %}