mirror of
https://github.com/PR0M3TH3AN/bitvid.git
synced 2026-11-09 06:12:56 +00:00
Handle custom auth providers in saved profiles
This commit is contained in:
1 parent
1137a8ca78
commit
ea45488ee4
5 files changed
+256
-23
No files matched your search
@@ -1961,11 +1961,39 @@ class Application {
|
||||
setLoadingState(true);
|
||||
|
||||
try {
|
||||
const { pubkey } = await this.authService.requestLogin({
|
||||
const loginResult = await this.authService.requestLogin({
|
||||
allowAccountSelection: true,
|
||||
autoApply: false,
|
||||
});
|
||||
|
||||
const { pubkey, authType: loginAuthType, providerId } =
|
||||
typeof loginResult === "object" && loginResult
|
||||
? loginResult
|
||||
: { pubkey: loginResult };
|
||||
|
||||
const detailAuthType =
|
||||
typeof loginResult?.detail?.authType === "string"
|
||||
? loginResult.detail.authType
|
||||
: null;
|
||||
const detailProviderId =
|
||||
typeof loginResult?.detail?.providerId === "string"
|
||||
? loginResult.detail.providerId
|
||||
: null;
|
||||
|
||||
const resolvedAuthType = (() => {
|
||||
const candidates = [detailAuthType, loginAuthType, detailProviderId, providerId];
|
||||
for (const candidate of candidates) {
|
||||
if (typeof candidate !== "string") {
|
||||
continue;
|
||||
}
|
||||
const trimmed = candidate.trim();
|
||||
if (trimmed) {
|
||||
return trimmed;
|
||||
}
|
||||
}
|
||||
return "nip07";
|
||||
})();
|
||||
|
||||
const normalizedPubkey = this.normalizeHexPubkey(pubkey);
|
||||
if (!normalizedPubkey) {
|
||||
throw new Error(
|
||||
@@ -1999,7 +2027,7 @@ class Application {
|
||||
npub,
|
||||
name,
|
||||
picture,
|
||||
authType: "nip07",
|
||||
authType: resolvedAuthType,
|
||||
});
|
||||
|
||||
persistSavedProfiles({ persistActive: false });
|
||||
|
||||
Reference in new issue
Block a user