disallow referring self

This commit is contained in:
keyan 2024-04-06 13:46:18 -05:00
parent 3472670df5
commit 1f466970b3
1 changed files with 1 additions and 1 deletions

View File

@ -57,7 +57,7 @@ function getCallbacks (req) {
// this means users can update their referrer if they don't have one, which is fine
if (req.cookies.sn_referrer && user?.id) {
const referrer = await prisma.user.findUnique({ where: { name: req.cookies.sn_referrer } })
if (referrer) {
if (referrer && referrer.id !== Number(user.id)) {
await prisma.user.updateMany({ where: { id: user.id, referrerId: null }, data: { referrerId: referrer.id } })
notifyReferral(referrer.id)
}