Skip to content

Commit

Permalink
uniqProfile
Browse files Browse the repository at this point in the history
  • Loading branch information
GO-viper7 committed Sep 24, 2022
1 parent 64df518 commit 2b7d561
Show file tree
Hide file tree
Showing 2 changed files with 29 additions and 14 deletions.
13 changes: 11 additions & 2 deletions routes/discord.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
const express = require('express');
const router = express.Router();
const DiscordOauth2 = require("discord-oauth2");
const profileSchema = require('../schemas/profile-schema');
const oauth = new DiscordOauth2();
require("dotenv").config();
const jwt = require('jsonwebtoken')
Expand All @@ -22,9 +23,17 @@ router.get('/discord', async (req, res) => {
redirectUri: `${process.env.websiteURL}/discord`,
})
res.cookies.set("key", jwt.sign(data.access_token, process.env.jwtSecret))
setTimeout(() => {
let user = await oauth.getUser(data.access_token)
profileSchema.countDocuments({userId: user.id}, async (err, count) => {
if (count == 0) {
await new profileSchema({
userId: user.id,
}).save()
}
})
setTimeout(() => {
res.redirect('/settings')
}, 1000)
}, 1000)
}
})

Expand Down
30 changes: 18 additions & 12 deletions views/shop.ejs
Original file line number Diff line number Diff line change
Expand Up @@ -622,7 +622,7 @@
document.getElementById("notifPanel").style.display = "none"
})
const backg = document.querySelector(".addon");
var uniqueCheck
var uniqueCheck, profCheck
let a = '<%- coins %>'
if (`<%- unique %>` != '') {
uniqueCheck = JSON.parse(`<%- unique %>`)
Expand Down Expand Up @@ -689,14 +689,13 @@
document.getElementById('alertS').style.display = "block"
document.getElementById('alertS').innerText = "Out Of Stock!"
setTimeout(() => {
window.location.href='/'
document.getElementById("panel"+t).style.display = "block";
backg.style.display = "block";
document.getElementById('alertS').style.display = "none"
}, 1000)
}
else if (Number(a) >= q) {
// if(cat != "Whitelists" && profCheck.name && profCheck.gender && profCheck.country && profCheck.zipCode && profCheck.houseNumber && profCheck.city && profCheck.streetName) {
//document.getElementById('suc').style.display="block";
if (1) {
if (profCheck.name && profCheck.gender && profCheck.country && profCheck.zipCode && profCheck.houseNumber && profCheck.city && profCheck.streetName) {
const glob = Number(`<%- prod.length %>`)
let products = JSON.parse(`<%- products %>`)
let prodFlag = 0
Expand All @@ -708,7 +707,9 @@
document.getElementById('alertS').style.display = "block"
document.getElementById('alertS').innerText = "Bulk purchase disabled!"
setTimeout(() => {
window.location.href='/'
document.getElementById("panel"+t).style.display = "block";
backg.style.display = "block";
document.getElementById('alertS').style.display = "none"
}, 1000)
prodFlag = 1
}
Expand Down Expand Up @@ -752,11 +753,14 @@
}
}
else {
//document.getElementById('prof').style.display="block";
document.getElementById("panel"+t).style.display = "none";
backg.style.display = "none";
document.getElementById('alertS').style.display = "block"
document.getElementById('alertS').innerText = "Profile Incomplete!"
setTimeout(() => {
window.location.href='/'
console.log("Profile not complete")
document.getElementById("panel"+t).style.display = "block";
backg.style.display = "block";
document.getElementById('alertS').style.display = "none"
}, 1000)
}
}
Expand All @@ -768,7 +772,9 @@
document.getElementById('alertS').style.display = "block"
document.getElementById('alertS').innerText = "Not Enough Coins!"
setTimeout(() => {
window.location.href='/'
document.getElementById("panel"+t).style.display = "block";
backg.style.display = "block";
document.getElementById('alertS').style.display = "none"
}, 1000)
}
}
Expand Down

0 comments on commit 2b7d561

Please sign in to comment.