diff --git a/backend/src/controller/auth.js b/backend/src/controller/auth.js index 420fef5..31e85ce 100644 --- a/backend/src/controller/auth.js +++ b/backend/src/controller/auth.js @@ -118,16 +118,18 @@ const signup = async (req, res) => { }, }); let newUser; - if ((isuser && isuser.isVarified)|| (isuser && !isuser.isVarified && isuser.email!=email)) { + // || (isuser && !isuser.isVarified && isuser.email!=email) + if ((isuser && isuser.isVarified)) { res.status(400).json({ res: "User Already Exists" }); return; - } else if (isuser && !isuser.isVarified && isuser.email==email) { + } else if (isuser) { newUser = await prisma.user.update({ where:{ username: isuser.username }, data:{ username, + email, password: hashPass, } }) @@ -163,7 +165,7 @@ const varifyOtp = async (req, res) => { } const { userID, otp, email } = req.body; if (userID == "" || otp == "") { - throw Error(" credetials cannot be empty"); + return res.status(401).json({ msg: "Invalid Otp" }); } else { const varData = await prisma.userVarify.findUnique({ where: { userID: userID }, @@ -226,7 +228,8 @@ const varifyOtp = async (req, res) => { }; const resendOtp = async (req, res) => { - // console.log(req.body); + console.log(req.body); + try { await sendEmailVarification(req.body, res); } catch (error) { diff --git a/backend/src/utils/generateUsernames.js b/backend/src/utils/generateUsernames.js index 5459cf3..8f81299 100644 --- a/backend/src/utils/generateUsernames.js +++ b/backend/src/utils/generateUsernames.js @@ -3,6 +3,8 @@ import prisma from "../../db/db.config.js"; function generateRandomUsername() { + console.log(Math.floor(Math.random() * usernames.length)); + const randomWord = usernames[Math.floor(Math.random() * usernames.length)]; const randomNumber = Math.floor(1000 + Math.random() * 9000); return `${randomWord}_${randomNumber}`; diff --git a/backend/src/utils/usernames.js b/backend/src/utils/usernames.js index a9c967d..ad2d959 100644 --- a/backend/src/utils/usernames.js +++ b/backend/src/utils/usernames.js @@ -1,247 +1,100 @@ const usernames= [ - "OwlsNight", - "EarlyBird", - "CoolCoder", - "CoderGirl", - "OwlEyes", - "CoolGamer", - "EarlyRiser", - "CoolCrafter", - "CoderLife", - "OwlWings", - "EarlyPeek", - "CoolVibes", - "CoderMagic", - "OwlWhisper", - "EarlyGlow", - "CoolChic", - "CoderSwag", - "OwlDreams", - "CoolMinded", - "JavaWizard", - "PythonPanda", - "AnimeFanatic", - "GamerGuru", - "MemeMaster", - "StarWarsNerd", - "HobbitFan", - "CodeSamurai", - "MangaManiac", - "PixelPioneer", - "RetroGamer", - "FunkyFeline", - "QuirkyQuokka", - "TechTitan", - "AstroNerd", - "EpicEngineer", - "MatrixMaven", - "NinjaCoder", - "DragonSlayer", - "GokuFan", - "NarutoNerd", - "OnePieceGuru", - "SpaceCadet", - "TechieTurtle", - "CyberWizard", - "BinaryBoss", - "EpicCoder", - "FunkyFrog", - "CodeCrafter", - "AstroAce", - "PixelProwler", - "MatrixMogul", - "CodeKing", - "AnimeAce", - "RetroRebel", - "DragonMaster", - "TechieTiger", - "MemeLord", - "CoderCrusader", - "AnimeHero", - "GamerGeek", - "AstroGamer", - "PixelProdigy", - "CodeKnight", - "NinjaWarrior", - "DragonQueen", - "FunkyMonkey", - "MatrixMaster", - "AstroAlien", - "DragonWarrior", - "PixelPhantom", - "MatrixMagician", - "RetroRaider", - "GokuGamer", - "MemeMaven", - "SpaceSage", - "DragonDiva", - "CodeWizard", - "AstroArtist", - "AnimeNinja", - "FunkyFox", - "GamerGoddess", - "PixelPaladin", - "MatrixMonarch", - "TechieToad", - "RetroRogue", - "NinjaMaster", - "SpaceScout", - "BinaryMaster", - "DragonKnight", - "CodeGuru", - "AstroAdventurer", - "AnimeChampion", - "FunkyFerret", - "GamerGenius", - "PixelProtector", - "MatrixMentor", - "TechieTyrant", - "ForestNinja", - "CyberForest", - "ProForest", - "MasterForest", - "LegendForest", - "ForestQueen", - "ForestKing", - "OceanNinja", - "CyberOcean", - "ProOcean", - "MasterOcean", - "LegendOcean", - "OceanQueen", - "OceanKing", - "MountainNinja", - "CyberMountain", - "ProMountain", - "MasterMountain", - "LegendMountain", - "MountainQueen", - "MountainKing", - "SkyNinja", - "CyberSky", - "ProSky", - "MasterSky", - "LegendSky", - "SkyQueen", - "SkyKing", - "EarthNinja", - "CyberEarth", - "ProEarth", - "MasterEarth", - "LegendEarth", - "EarthQueen", - "EarthKing", - "CodeNinja", - "CyberCode", - "ProCode", - "MasterCode", - "LegendCode", - "CodeQueen", - "CodeKing", - "PixelNinja", - "CyberPixel", - "ProPixel", - "MasterPixel", - "LegendPixel", - "PixelQueen", - "PixelKing", - "ByteNinja", - "CyberByte", - "ProByte", - "MasterByte", - "LegendByte", - "ByteQueen", - "ByteKing", - "NetworkNinja", - "CyberNetwork", - "ProNetwork", - "MasterNetwork", - "LegendNetwork", - "NetworkQueen", - "NetworkKing", - "DigitalNinja", - "CyberDigital", - "ProDigital", - "MasterDigital", - "LegendDigital", - "DigitalQueen", - "DigitalKing", - "LevelNinja", - "CyberLevel", - "ProLevel", - "MasterLevel", - "LegendLevel", - "LevelQueen", - "LevelKing", - "QuestNinja", - "CyberQuest", - "ProQuest", - "MasterQuest", - "LegendQuest", - "QuestQueen", - "QuestKing", - "AvatarNinja", - "CyberAvatar", - "ProAvatar", - "MasterAvatar", - "LegendAvatar", - "AvatarQueen", - "AvatarKing", - "ClanNinja", - "CyberClan", - "ProClan", - "MasterClan", - "LegendClan", - "ClanQueen", - "ClanKing", - "SolarWind", - "AquaStorm", - "IronKnight", - "CrystalHawk", - "GoldenSun", - "ThunderBolt", - "MysticMoon", - "FrostDragon", - "EmeraldWave", - "ShadowFury", - "BlazeStar", - "EchoSpirit", - "VortexRider", - "RagingLion", - "LunarEcho", - "AuroraGaze", - "TempestShade", - "CelestialFire", - "StellarDream", - "NebulaGuard", - "PhantomFrost", - "ZephyrSky", - "InfernoPulse", - "QuantumFlame", - "RadiantStorm", - "NovaStrike", - "EclipseKnight", - "NebulaSword", - "PhoenixGlow", - "ObsidianFlash", - "AuroraShine", - "BlizzardKnight", - "RadiantGlory", - "SolarBlaze", - "VortexFlame", - "ShadowEcho", - "TitanStorm", - "CelestialFury", - "LunarShade", - "NebulaStorm", - "StellarPulse", - "TempestFire", - "QuantumBurst", - "PhantomStrike", - "InfernoGuard", - "EchoWave", - "VortexGaze" + "CodeNinja", "PixelHunter", "TechWizard", "ByteWarrior", "CodeMancer", + "DataSamurai", "CryptoKnight", "ScriptHero", "AlgoMaster", "CloudRider", + "FitTitan", "DevTitan", "CyberMonk", "DataFighter", "PixelMage", + "CodeBlade", "LuffyLeader", "DebugWarrior", "BotSlayer", "NarutoNinja", + "NeoHacker", "ByteBreaker", "AlgoDragon", "CryptoLancer", "ScriptSage", + "FitLancer", "BitNinja", "TechShadow", "CodeLancer", "PixelKnight", + "ByteWizard", "DevSamurai", "ManagementMaster", "DataLancer", "GokuGlory", + "FitHunter", "CodeStorm", "DebugSlinger", "CyberRogue", "ZoroWarrior", + "AlgoRider", "ScriptMage", "CryptoWizard", "ByteHero", "CloudKnight", + "FitRider", "DataNinja", "PixelStorm", "CodeSamurai", "AlgoHunter", + "ByteMonk", "DebugSage", "BotWarrior", "NeoLancer", "CodeSlinger", + "ByteRogue", "CyberMaster", "AlgoMonk", "FitMage", "ScriptStorm", + "DataMage", "TechFury", "CloudDragon", "FitSlayer", "DevSlayer", + "PixelBreaker", "BitStorm", "CodeShadow", "DebugHunter", "AlgoKnight", + "ScriptLancer", "DataBlade", "BotNinja", "CryptoRider", "ByteWarlock", + "CodeFury", "CyberMage", "PixelWizard", "TechTitan", "AlgoSamurai", + "ScriptBreaker", "DataKnight", "DebugDragon", "BotMage", "NeoSlinger", + "CloudHero", "ByteRider", "CodeMonk", "CryptoSamurai", "ScriptSlayer", + "TechMaster", "AlgoBlade", "PixelSlinger", "DataStorm", "DebugWarlock", + "CodeSlayer", "BitKnight", "CloudSlayer", "ScriptFury", "FitStorm", + "AlgoWizard", "BotStorm", "PixelHunter", "ByteKnight", "DevWizard", + "DataStormer", "CloudBreaker", "LeviSlayer", "CodeMonarch", "AlgoSlinger", + "CryptoBreaker", "ByteSamurai", "DebugKnight", "BotShadow", "NeoStormer", + "CodeHunter", "CyberBlade", "FitMaster", "AlgoMaster", "ScriptKnight", + "PixelStormer", "DataFury", "BotRider", "CodeLancer", "ByteStormer", + "DebugMage", "CloudSamurai", "PixelBreaker", "TechSlayer", "AlgoFury", + "DataShadow", "CodeStormer", "ByteDragon", "ScriptRider", "CyberWarrior", + "DevMage", "PixelMonk", "CryptoHunter", "BotSlinger", "DebugBlade", + "AlgoSlayer", "ScriptWarlock", "FitWarrior", "CodeTitan", "ByteShadow", + "CyberDragon", "DataSlayer", "PixelRogue", "CodeWarlock", "AlgoBreaker", + "BotKnight", "ByteMage", "ScriptSlayer", "DebugRogue", "NeoSamurai", + "CryptoMonk", "AlgoHunter", "ByteSage", "DataKnight", "PixelRider", + "BotSlayer", "ScriptDragon", "AlgoMonarch", "CloudLancer", "CodeHunter", + "DebugMage", "ByteStormer", "CyberSlinger", "BotMaster", "ScriptFury", + "TechRider", "PixelMonarch", "AlgoSamurai", "CloudKnight", "CodeWarlock", + "ByteMaster", "CryptoMonarch", "BotFury", "DebugRider", "AlgoStorm", + "CloudMaster", "DataWarlock", "CodeSlinger", "ByteLancer", "PixelShadow", + "ScriptMonk", "DebugSlayer", "AlgoMaster", "CyberBreaker", "BotKnight", + "ByteTitan", "DataMage", "ScriptHunter", "CodeShadow", "CloudRogue", + "DebugMonk", "AlgoWarrior", "PixelMage", "ByteWarlock", "CyberHunter", + "BotStorm", "DataSlayer", "ScriptMaster", "NeoBreaker", "CodeKnight", + "ByteWarrior", "DebugMaster", "AlgoSage", "CyberDragon", "PixelSlayer", + "ScriptWarlock", "BotRogue", "CloudSage", "CodeSage", "ByteDragon", + "DataRogue", "DebugFury", "AlgoSlinger", "CryptoMonarch", "PixelSage", + "CodeMaster", "ByteBreaker", "TechMonarch", "CloudStorm", "BotMaster", + "DataRider", "AlgoSlayer", "PixelHunter", "ScriptTitan", "DebugMonarch", + "CloudSlayer", "CodeRogue", "ByteSlinger", "CyberSlayer", "DataWarrior", + "BotRider", "DebugTitan", "AlgoWarlock", "CryptoSlayer", "CodeMage", + "ByteSage", "TechMonk", "PixelWarrior", "BotHunter", "CloudRider", + "ScriptSamurai", "DebugBreaker", "AlgoWarrior", "CodeBreaker", + "ByteKnight", "DataStorm", "BotSamurai", "CyberWarrior", "DebugSlinger", + "AlgoStorm", "CryptoFury", "PixelBreaker", "CodeLancer", "ByteSlayer", + "CloudWarrior", "TechMonarch", "AlgoDragon", "BotMage", "DebugSlayer", + "ByteSlinger", "CyberBreaker", "ScriptHunter", "DataTitan", "PixelSamurai", + "CodeStormer", "ByteShadow", "CloudMage", "AlgoRogue", "DebugWarrior", + "CryptoSlinger", "BotShadow", "ByteDragon", "PixelStormer", "CodeMonk", + "DataWarlock", "ScriptSage", "CyberLancer", "AlgoMage", "ByteStorm", + "TechWarrior", "BotMonarch", "DebugFury", "PixelWarlock", "CodeWarrior", + "AlgoSlayer", "ByteKnight", "CryptoTitan", "CloudHunter", "BotSage", + "ScriptDragon", "DebugMaster", "AlgoStormer", "CodeKnight", "ByteFury", + "TechWarlock", "CyberStorm", "PixelMonk", "BotTitan", "DataMage", + "ScriptSlinger", "DebugStorm", "CloudSlayer", "ByteWarlock", "AlgoMonarch", + "CodeTitan", "PixelKnight", "CryptoWarlock", "OwlsNight", "EarlyBird", + "CoolCoder", "CoderGirl", "OwlEyes", "CoolGamer", "EarlyRiser", + "CoolCrafter", "CoderLife", "OwlWings", "EarlyPeek", "CoolVibes", + "CoderMagic", "OwlWhisper", "EarlyGlow", "CoolChic", "CoderSwag", + "OwlDreams", "CoolMinded", "JavaWizard", "PythonPanda", "AnimeFanatic", + "GamerGuru", "MemeMaster", "StarWarsNerd", "HobbitFan", "CodeSamurai", + "MangaManiac", "PixelPioneer", "RetroGamer", "FunkyFeline", "QuirkyQuokka", + "TechTitan", "AstroNerd", "EpicEngineer", "MatrixMaven", "NinjaCoder", + "DragonSlayer", "GokuFan", "NarutoNerd", "OnePieceGuru", "SpaceCadet", + "TechieTurtle", "CyberWizard", "BinaryBoss", "EpicCoder", "FunkyFrog", + "CodeCrafter", "AstroAce", "PixelProwler", "MatrixMogul", "CodeKing", + "AnimeAce", "RetroRebel", "DragonMaster", "TechieTiger", "MemeLord", + "CoderCrusader", "AnimeHero", "GamerGeek", "AstroGamer", "PixelProdigy", + "CodeKnight", "NinjaWarrior", "DragonQueen", "FunkyMonkey", "MatrixMaster", + "AstroAlien", "DragonWarrior", "PixelPhantom", "MatrixMagician", "RetroRaider", + "GokuGamer", "MemeMaven", "SpaceSage", "DragonDiva", "CodeWizard", + "AstroArtist", "AnimeNinja", "FunkyFox", "GamerGoddess", "PixelPaladin", + "MatrixMonarch", "TechieToad", "RetroRogue", "NinjaMaster", "SpaceScout", + "BinaryMaster", "DragonKnight", "CodeGuru", "AstroAdventurer", "AnimeChampion", + "FunkyFerret", "GamerGenius", "PixelProtector", "MatrixMentor", "TechieTyrant", + "ForestNinja", "CyberForest", "ProForest", "MasterForest", "LegendForest", + "ForestQueen", "ForestMage", "ForestKnight", "ForestWarrior", "ForestDragon", + "ForestSage", "ForestHero", "ForestWanderer", "ForestWitch", "ForestTitan", + "ForestShaman", "ForestGuardian", "ForestSorcerer", "ForestPrince", "ForestRanger", + "ForestWarlock", "ForestPaladin", "ForestChampion", "ForestDruid", "ForestViking", + "ForestConqueror", "ForestTamer", "ForestSummoner", "ForestCrusader", "ForestMystic", + "ForestArtisan", "ForestProtector", "ForestSentinel", "ForestEnchanter", "ForestSquire", + "ForestBard", "ForestFighter", "ForestInvoker", "ForestSeer", "ForestPioneer", + "ForestTactician", "ForestGladiator", "ForestMonarch", "ForestChampion", "ForestWarden", + "ForestAlchemist", "ForestDemon", "ForestLord", "ForestVanguard", "ForestWarlord", + "ForestDrake", "ForestPriest", "ForestHunter", "ForestGiant", "ForestRuler", + "ForestMage", "ForestLord", "ForestSwordsman", "ForestGladiator", "ForestDemon" ]; + export default usernames; \ No newline at end of file diff --git a/frontend/src/pages/Signup.jsx b/frontend/src/pages/Signup.jsx index 40cdfb2..6f6c19f 100644 --- a/frontend/src/pages/Signup.jsx +++ b/frontend/src/pages/Signup.jsx @@ -18,6 +18,8 @@ import { login } from '../redux/login'; import { getUserData } from '../App'; import { show } from '../redux/welcome'; import { v4 as uuidv4 } from 'uuid'; +import SmoothLoaderN from '../assets/SmoothLoaderN'; +import SmoothLoaderHome from '../assets/SmoothLoaderHome'; @@ -45,6 +47,8 @@ const Signup = () => { const passref = useRef(); const [isLoading, setisLoading] = useState(false) const [loading, setLoading] = useState(false) + const [sendOtpLoading, setsendOtpLoading] = useState(false); + const [verifyLoading, setverifyLoading] = useState(false) const usernameRef = useRef(null); @@ -109,10 +113,14 @@ const Signup = () => { const sendOtp = async () => { setLoading(true) + setsendOtpLoading(true) + try { toast.loading("Sending OTP") const res = await axios.post(`${baseAddress}auth/signup`, form); if (res.status == 202) { + setdisable(true); + setTimeLeft(60) toast.dismiss(); setVarifyOtpData({ ...varifyOtpData, userID: res.data.userID, email: res.data.email }); toast.success("Your OTP is on its way !"); @@ -128,6 +136,7 @@ const Signup = () => { } console.log(error) } + setsendOtpLoading(false) setLoading(false) } @@ -150,46 +159,29 @@ const Signup = () => { else { await sendOtp(); - setdisable(true); - setTimeLeft(60) - setForm({ username: "", email: "", password: "" }) + + // setForm({ username: "", email: "", password: "" }) } } const resendOTP = async () => { - dispatch(loading()); - setErrorOtp(null) + console.log("resend"); - try { - const res = await axios.post(`${baseAddress}auth/resendotp"`, varifyOtpData); - if (res.status == 202) { - setTimeLeft(60); - setdisable(true) - setOnSave(true) - setVarifyOtpData({ ...varifyOtpData, userID: res.data.userID, email: res.data.email }); - toast.success("Your OTP is on its way !"); - } else if (res.status == 500) { - toast.error("Some error occured! Try Again.") - } - - } catch (error) { - if (error.response.status == 500) { - toast.error("Some error occured! Try Again.") - } - console.log(error); - } - dispatch(loading()); + setErrorOtp(null) + sendOtp() + } const varifyOtp = async () => { - setLoading(true) + setverifyLoading(true) + toast.loading("Verifying OTP...") try { const res = await axios.post(`${baseAddress}auth/varifyotp`, varifyOtpData); - + if (res.status == 202) { @@ -200,6 +192,7 @@ const Signup = () => { dispatch(login()) } } catch (error) { + toast.dismiss() console.log(error); if (error.response.status === 401) { toast.error("Invalid OTP!"); @@ -214,7 +207,7 @@ const Signup = () => { } - setLoading(false) + setverifyLoading(false) } @@ -257,6 +250,10 @@ const Signup = () => { } + const changeEmail = () => { + setOtpsent(false) + } + @@ -269,20 +266,31 @@ const Signup = () => {