1
0
mirror of https://github.com/laurent22/joplin.git synced 2025-11-26 22:41:17 +02:00

All: Open the connection screen when a SAML session has expired

This commit is contained in:
Laurent Cozic
2025-10-29 13:41:32 +01:00
parent 42d8df3036
commit fc0014c0b5
3 changed files with 77 additions and 45 deletions

View File

@@ -52,6 +52,9 @@ export const authenticateWithCode = async (code: string) => {
//
// Based on the regular Joplin Server sync target.
export default class SyncTargetJoplinServerSAML extends SyncTargetJoplinServer {
private lastFileApiOptions_: FileApiOptions|null = null;
public static override id() {
return 11;
}
@@ -65,7 +68,16 @@ export default class SyncTargetJoplinServerSAML extends SyncTargetJoplinServer {
}
public override async isAuthenticated() {
return Setting.value('sync.11.id') !== '';
if (!Setting.value('sync.11.id')) return false;
// We check that the file API has been initialized at least once, otherwise the below check
// will always fail and it will be impossible to login.
if (this.lastFileApiOptions_) {
const check = await SyncTargetJoplinServer.checkConfig(null, null, await this.fileApi());
return check.ok;
}
return true;
}
public static override requiresPassword() {
@@ -111,11 +123,12 @@ export default class SyncTargetJoplinServerSAML extends SyncTargetJoplinServer {
}
protected override async initFileApi() {
return initFileApi(SyncTargetJoplinServerSAML.id(), this.logger(), {
this.lastFileApiOptions_ = {
path: () => Setting.value('sync.11.path'),
userContentPath: () => Setting.value('sync.11.userContentPath'),
username: () => '',
password: () => '',
});
};
return initFileApi(SyncTargetJoplinServerSAML.id(), this.logger(), this.lastFileApiOptions_);
}
}