fix: strip Stalwart master-user '%' suffix from displayed account
This commit is contained in:
+12
-4
@@ -1266,14 +1266,22 @@ export const useAuthStore = create<AuthState>()(
|
|||||||
if (restore.ok) {
|
if (restore.ok) {
|
||||||
const data = await restore.json();
|
const data = await restore.json();
|
||||||
if (data?.serverUrl && data?.username && data?.password) {
|
if (data?.serverUrl && data?.username && data?.password) {
|
||||||
|
// Stalwart master-user impersonation uses "target%master" as
|
||||||
|
// the auth username. The full string must be preserved for
|
||||||
|
// JMAP auth, but the user-facing display (avatar, switcher,
|
||||||
|
// sign-out copy) should only show the target mailbox.
|
||||||
|
const fullUsername: string = data.username;
|
||||||
|
const displayMailbox = fullUsername.includes('%')
|
||||||
|
? fullUsername.split('%', 1)[0]
|
||||||
|
: fullUsername;
|
||||||
accountStore.addAccount({
|
accountStore.addAccount({
|
||||||
label: data.username,
|
label: displayMailbox,
|
||||||
serverUrl: data.serverUrl,
|
serverUrl: data.serverUrl,
|
||||||
username: data.username,
|
username: fullUsername,
|
||||||
authMode: 'basic',
|
authMode: 'basic',
|
||||||
rememberMe: true,
|
rememberMe: true,
|
||||||
displayName: data.username,
|
displayName: displayMailbox,
|
||||||
email: data.username,
|
email: displayMailbox,
|
||||||
lastLoginAt: Date.now(),
|
lastLoginAt: Date.now(),
|
||||||
isConnected: false,
|
isConnected: false,
|
||||||
hasError: false,
|
hasError: false,
|
||||||
|
|||||||
Reference in New Issue
Block a user