Skip to content

Commit e58b9bd

Browse files
authored
Merge pull request #809 from LIT-Protocol/feat/add-callback-to-discord-provider
feat(DiscordProvider): add optional callback to signIn method in Disc…
2 parents 159972a + ca9fbb0 commit e58b9bd

File tree

1 file changed

+9
-3
lines changed

1 file changed

+9
-3
lines changed

packages/lit-auth-client/src/lib/providers/DiscordProvider.ts

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -37,13 +37,19 @@ export default class DiscordProvider extends BaseProvider {
3737
/**
3838
* Redirect user to the Lit's Discord login page
3939
*
40+
* @param {Function} [callback] - Optional callback to handle login URL
4041
* @returns {Promise<void>} - Redirects user to Lit login page
4142
*/
42-
public async signIn(): Promise<void> {
43+
public async signIn(callback?: (url: string) => void): Promise<void> {
4344
// Get login url
4445
const loginUrl = await prepareLoginUrl('discord', this.redirectUri);
45-
// Redirect to login url
46-
window.location.assign(loginUrl);
46+
47+
// If callback is provided, use it. Otherwise, redirect to login url
48+
if (callback) {
49+
callback(loginUrl);
50+
} else {
51+
window.location.assign(loginUrl);
52+
}
4753
}
4854

4955
/**

0 commit comments

Comments
 (0)