Add ntfy.sh
This commit is contained in:
@@ -10,6 +10,7 @@ import {
|
||||
} from '../../app/constants.js';
|
||||
import {prisma} from '../../database/prisma.js';
|
||||
import {jwt} from '../../middleware/auth.js';
|
||||
import {NtfyService} from '../../services/NtfyService.js';
|
||||
import {UserService} from '../../services/UserService.js';
|
||||
import {CatchAsync} from '../../utils/asyncHandler.js';
|
||||
|
||||
@@ -53,6 +54,7 @@ export class Google {
|
||||
);
|
||||
|
||||
let user = await UserService.email(email);
|
||||
let isNewUser = false;
|
||||
|
||||
if (!user) {
|
||||
user = await prisma.user.create({
|
||||
@@ -61,12 +63,18 @@ export class Google {
|
||||
type: 'GOOGLE_OAUTH',
|
||||
},
|
||||
});
|
||||
isNewUser = true;
|
||||
}
|
||||
|
||||
if (user.type !== 'GOOGLE_OAUTH') {
|
||||
return res.redirect(DASHBOARD_URI + '/auth/login?message=You used another form of authentication');
|
||||
}
|
||||
|
||||
// Send notification if this is a new user
|
||||
if (isNewUser) {
|
||||
await NtfyService.notifyUserOAuthSignup(user.email, user.id, 'Google');
|
||||
}
|
||||
|
||||
const token = jwt.sign(user.id);
|
||||
const cookie = UserService.cookieOptions();
|
||||
|
||||
|
||||
Reference in New Issue
Block a user