mirror of
https://github.com/toeverything/AFFiNE.git
synced 2026-02-13 04:48:53 +00:00
fix(server): signup/signin logic (#4008)
This commit is contained in:
@@ -266,15 +266,16 @@ export const NextAuthOptionsProvider: FactoryProvider<NextAuthOptions> = {
|
||||
}
|
||||
return session;
|
||||
},
|
||||
signIn: async ({ profile }) => {
|
||||
signIn: async ({ profile, user }) => {
|
||||
if (!config.affine.beta || !config.node.prod) {
|
||||
return true;
|
||||
}
|
||||
if (profile?.email) {
|
||||
return await prisma.newFeaturesWaitingList
|
||||
const email = profile?.email ?? user.email;
|
||||
if (email) {
|
||||
return prisma.newFeaturesWaitingList
|
||||
.findUnique({
|
||||
where: {
|
||||
email: profile.email,
|
||||
email,
|
||||
type: NewFeaturesKind.EarlyAccess,
|
||||
},
|
||||
})
|
||||
|
||||
@@ -3,6 +3,7 @@ import {
|
||||
BadRequestException,
|
||||
Controller,
|
||||
Inject,
|
||||
Logger,
|
||||
Next,
|
||||
NotFoundException,
|
||||
Query,
|
||||
@@ -27,6 +28,8 @@ const BASE_URL = '/api/auth/';
|
||||
export class NextAuthController {
|
||||
private readonly callbackSession;
|
||||
|
||||
private readonly logger = new Logger('NextAuthController');
|
||||
|
||||
constructor(
|
||||
readonly config: Config,
|
||||
readonly prisma: PrismaService,
|
||||
@@ -120,7 +123,11 @@ export class NextAuthController {
|
||||
}
|
||||
|
||||
if (redirect?.endsWith('api/auth/error?error=AccessDenied')) {
|
||||
res.redirect('https://community.affine.pro/c/insider-general/');
|
||||
res.status(403);
|
||||
res.json({
|
||||
url: 'https://community.affine.pro/c/insider-general/',
|
||||
error: `You don't have early access permission`,
|
||||
});
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -129,7 +136,7 @@ export class NextAuthController {
|
||||
}
|
||||
|
||||
if (redirect) {
|
||||
console.log(providerId, action, req.headers);
|
||||
this.logger.debug(providerId, action, req.headers);
|
||||
if (providerId === 'credentials') {
|
||||
res.send(JSON.stringify({ ok: true, url: redirect }));
|
||||
} else if (
|
||||
|
||||
@@ -16,6 +16,7 @@ import { DocManager } from '../../doc';
|
||||
|
||||
@WebSocketGateway({
|
||||
cors: process.env.NODE_ENV !== 'production',
|
||||
transports: ['websocket'],
|
||||
})
|
||||
export class EventsGateway implements OnGatewayConnection, OnGatewayDisconnect {
|
||||
private connectionCount = 0;
|
||||
|
||||
Reference in New Issue
Block a user