mirror of
https://github.com/toeverything/AFFiNE.git
synced 2026-07-18 02:26:21 +08:00
feat(server): use user model (#9710)
This commit is contained in:
@@ -18,7 +18,7 @@ import {
|
||||
UnknownOauthProvider,
|
||||
} from '../../base';
|
||||
import { AuthService, Public } from '../../core/auth';
|
||||
import { UserService } from '../../core/user';
|
||||
import { Models } from '../../models';
|
||||
import { OAuthProviderName } from './config';
|
||||
import { OAuthAccount, Tokens } from './providers/def';
|
||||
import { OAuthProviderFactory } from './register';
|
||||
@@ -29,7 +29,7 @@ export class OAuthController {
|
||||
constructor(
|
||||
private readonly auth: AuthService,
|
||||
private readonly oauth: OAuthService,
|
||||
private readonly user: UserService,
|
||||
private readonly models: Models,
|
||||
private readonly providerFactory: OAuthProviderFactory,
|
||||
private readonly db: PrismaClient
|
||||
) {}
|
||||
@@ -137,9 +137,7 @@ export class OAuthController {
|
||||
return connectedUser.user;
|
||||
}
|
||||
|
||||
const user = await this.user.fulfillUser(externalAccount.email, {
|
||||
emailVerifiedAt: new Date(),
|
||||
registered: true,
|
||||
const user = await this.models.user.fulfill(externalAccount.email, {
|
||||
avatarUrl: externalAccount.avatarUrl,
|
||||
});
|
||||
|
||||
|
||||
@@ -25,7 +25,7 @@ import {
|
||||
} from '../../base';
|
||||
import { CurrentUser } from '../../core/auth';
|
||||
import { FeatureManagementService } from '../../core/features';
|
||||
import { UserService } from '../../core/user';
|
||||
import { Models } from '../../models';
|
||||
import {
|
||||
CheckoutParams,
|
||||
Invoice,
|
||||
@@ -75,7 +75,7 @@ export class SubscriptionService implements OnApplicationBootstrap {
|
||||
private readonly stripe: Stripe,
|
||||
private readonly db: PrismaClient,
|
||||
private readonly feature: FeatureManagementService,
|
||||
private readonly user: UserService,
|
||||
private readonly models: Models,
|
||||
private readonly userManager: UserSubscriptionManager,
|
||||
private readonly workspaceManager: WorkspaceSubscriptionManager,
|
||||
private readonly mutex: Mutex
|
||||
@@ -435,7 +435,7 @@ export class SubscriptionService implements OnApplicationBootstrap {
|
||||
return null;
|
||||
}
|
||||
|
||||
const user = await this.user.findUserByEmail(customer.email);
|
||||
const user = await this.models.user.getPublicUserByEmail(customer.email);
|
||||
|
||||
if (!user) {
|
||||
return null;
|
||||
@@ -485,7 +485,9 @@ export class SubscriptionService implements OnApplicationBootstrap {
|
||||
return null;
|
||||
}
|
||||
|
||||
const user = await this.user.findUserByEmail(invoice.customer_email);
|
||||
const user = await this.models.user.getPublicUserByEmail(
|
||||
invoice.customer_email
|
||||
);
|
||||
|
||||
// TODO(@forehalo): the email may actually not appear to be AFFiNE user
|
||||
// There is coming feature that allow anonymous user with only email provided to buy selfhost licenses
|
||||
|
||||
Reference in New Issue
Block a user