mirror of
https://github.com/toeverything/AFFiNE.git
synced 2026-02-13 21:05:19 +00:00
feat(core): add subscribe link (#6610)
This commit is contained in:
@@ -106,9 +106,12 @@ export class AuthSession extends Entity {
|
||||
}
|
||||
}
|
||||
|
||||
async waitForRevalidation() {
|
||||
async waitForRevalidation(signal?: AbortSignal) {
|
||||
this.revalidate();
|
||||
await this.isRevalidating$.waitFor(isRevalidating => !isRevalidating);
|
||||
await this.isRevalidating$.waitFor(
|
||||
isRevalidating => !isRevalidating,
|
||||
signal
|
||||
);
|
||||
}
|
||||
|
||||
async removeAvatar() {
|
||||
|
||||
@@ -84,9 +84,12 @@ export class Subscription extends Entity {
|
||||
await this.waitForRevalidation();
|
||||
}
|
||||
|
||||
async waitForRevalidation() {
|
||||
async waitForRevalidation(signal?: AbortSignal) {
|
||||
this.revalidate();
|
||||
await this.isRevalidating$.waitFor(isRevalidating => !isRevalidating);
|
||||
await this.isRevalidating$.waitFor(
|
||||
isRevalidating => !isRevalidating,
|
||||
signal
|
||||
);
|
||||
}
|
||||
|
||||
revalidate = effect(
|
||||
|
||||
@@ -76,18 +76,18 @@ export class AuthService extends Service {
|
||||
async sendEmailMagicLink(
|
||||
email: string,
|
||||
verifyToken: string,
|
||||
challenge?: string
|
||||
challenge?: string,
|
||||
redirectUri?: string | null
|
||||
) {
|
||||
const searchParams = new URLSearchParams();
|
||||
if (challenge) {
|
||||
searchParams.set('challenge', challenge);
|
||||
}
|
||||
searchParams.set('token', verifyToken);
|
||||
const redirectUri = new URL(location.href);
|
||||
if (environment.isDesktop) {
|
||||
redirectUri.pathname = this.buildRedirectUri('/open-app/signin-redirect');
|
||||
}
|
||||
searchParams.set('redirect_uri', redirectUri.toString());
|
||||
const redirect = environment.isDesktop
|
||||
? this.buildRedirectUri('/open-app/signin-redirect')
|
||||
: redirectUri ?? location.href;
|
||||
searchParams.set('redirect_uri', redirect.toString());
|
||||
|
||||
const res = await this.fetchService.fetch(
|
||||
'/api/auth/sign-in?' + searchParams.toString(),
|
||||
@@ -104,7 +104,7 @@ export class AuthService extends Service {
|
||||
}
|
||||
}
|
||||
|
||||
async signInOauth(provider: OAuthProviderType) {
|
||||
async signInOauth(provider: OAuthProviderType, redirectUri?: string | null) {
|
||||
if (environment.isDesktop) {
|
||||
await apis?.ui.openExternal(
|
||||
`${
|
||||
@@ -117,7 +117,7 @@ export class AuthService extends Service {
|
||||
location.href = `${
|
||||
runtimeConfig.serverUrlPrefix
|
||||
}/oauth/login?provider=${provider}&redirect_uri=${encodeURIComponent(
|
||||
location.pathname
|
||||
redirectUri ?? location.pathname
|
||||
)}`;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user