(authMethod: AuthMethod)
| 242 | } |
| 243 | |
| 244 | export async function addAuthProvider(authMethod: AuthMethod): Promise<void> { |
| 245 | if (!isAuthAvailable()) { |
| 246 | showErrorNotification("Authentication uninitialized", { durationMs: 3000 }); |
| 247 | return; |
| 248 | } |
| 249 | const provider = getAuthProvider(authMethod); |
| 250 | if (provider === undefined) { |
| 251 | showErrorNotification(`Authentication ${authMethod} is missing a provider`); |
| 252 | return; |
| 253 | } |
| 254 | const providerName = getAuthMethodDisplay(authMethod); |
| 255 | |
| 256 | showLoaderBar(); |
| 257 | const user = getAuthenticatedUser(); |
| 258 | if (!user) return; |
| 259 | try { |
| 260 | await linkWithPopup(user, provider); |
| 261 | hideLoaderBar(); |
| 262 | showSuccessNotification(`${providerName} authentication added`); |
| 263 | authEvent.dispatch({ type: "authConfigUpdated" }); |
| 264 | } catch (error) { |
| 265 | hideLoaderBar(); |
| 266 | showErrorNotification(`Failed to add ${providerName} authentication`, { |
| 267 | error, |
| 268 | }); |
| 269 | } |
| 270 | } |
| 271 | |
| 272 | export async function removeAuthProvider( |
| 273 | authMethod: AuthMethod, |
no test coverage detected