AnonSec Shell
Server IP : 162.213.251.212  /  Your IP : 18.219.236.143   [ Reverse IP ]
Web Server : LiteSpeed
System : Linux business55.web-hosting.com 4.18.0-553.lve.el8.x86_64 #1 SMP Mon May 27 15:27:34 UTC 2024 x86_64
User : allssztx ( 535)
PHP Version : 8.1.31
Disable Function : NONE
Domains : 1 Domains
MySQL : OFF  |  cURL : ON  |  WGET : ON  |  Perl : ON  |  Python : ON  |  Sudo : OFF  |  Pkexec : OFF
Directory :  /home/allssztx/clarkesmusicservices.com/routes/

Upload File :
current_dir [ Writeable ] document_root [ Writeable ]

 

Command :


[ HOME ]     [ BACKUP SHELL ]     [ JUMPING ]     [ MASS DEFACE ]     [ SCAN ROOT ]     [ SYMLINK ]     

Current File : /home/allssztx/clarkesmusicservices.com/routes/authentication.js
const express = require("express")
const User = require("../schema/User")
const router = express.Router()
const bcrypt = require('bcryptjs');
const jwt = require('jsonwebtoken');
const JWT_SECRET = "mU$!cC|@rK";

router.post('/register', async (req, res) => {
    try {
        const { profilePicture, firstName, lastName, email, password } = req.body
        const checkUser = await User.findOne({ email })
        if (checkUser) {
            return res.json({
                success: false,
                error: 'Email Already Registered'
            })
        }
        const salt = await bcrypt.genSalt(10)
        const hashPassword = await bcrypt.hash(password, salt)
        const newUser = await User.create({ profilePicture, firstName, lastName, email, password: hashPassword })
        if (newUser) {
            const { _id, role } = newUser
            const user = {
                id: _id, firstName, lastName, email, role
            }
            const authtoken = jwt.sign(user, JWT_SECRET);
            return res.cookie('authtoken', authtoken).json({
                success: true,
                user,
                authtoken
            })
        }
        return res.json({
            success: false,
            error: 'Something Went Wrong'
        })
    } catch (error) {
        return res.json({
            success: false,
            error: error.message
        })
    }
})

router.post('/login', async (req, res) => {
    try {
        const { email, password } = req.body
        const checkUser = await User.findOne({ email })
        if (checkUser) {
            const passwordCompare = await bcrypt.compare(password, checkUser.password);
            if (!passwordCompare) {
                return res.json({
                    success: false,
                    error: 'Invalid Credentials'
                })
            }
            const { _id, profilePicture, firstName, lastName, email, role } = checkUser
            const user = {
                id: _id, profilePicture, firstName, lastName, email, role
            }
            const authtoken = jwt.sign(user, JWT_SECRET);
            return res.cookie('authtoken', authtoken).json({
                success: true,
                user,
                authtoken
            })
        }
        return res.json({
            success: false,
            error: 'Invalid Credentials'
        })
    } catch (error) {
        return res.json({
            success: false,
            error: error.message
        })
    }
})

module.exports = router

Anon7 - 2022
AnonSec Team