(
authMethod: AuthMethod,
options: { rememberMe: boolean },
)
| 216 | } |
| 217 | |
| 218 | export async function signInWithProvider( |
| 219 | authMethod: AuthMethod, |
| 220 | options: { rememberMe: boolean }, |
| 221 | ): Promise<AuthResult> { |
| 222 | if (!isAuthAvailable()) { |
| 223 | return { success: false, message: "Authentication uninitialized" }; |
| 224 | } |
| 225 | |
| 226 | const provider = getAuthProvider(authMethod); |
| 227 | if (provider === undefined) { |
| 228 | return { |
| 229 | success: false, |
| 230 | message: `Authentication ${authMethod} is missing a provider`, |
| 231 | }; |
| 232 | } |
| 233 | |
| 234 | const { error } = await tryCatch( |
| 235 | signInWithPopup(provider, options.rememberMe), |
| 236 | ); |
| 237 | |
| 238 | if (error !== null) { |
| 239 | return { success: false, message: error.message }; |
| 240 | } |
| 241 | return { success: true }; |
| 242 | } |
| 243 | |
| 244 | export async function addAuthProvider(authMethod: AuthMethod): Promise<void> { |
| 245 | if (!isAuthAvailable()) { |
no test coverage detected