import bcrypt from 'bcryptjs';
import jwt from 'jsonwebtoken';
import user from '../models/user';
export const signin=async (res,req)=>{
const {email,password} =req.body;
try {
const existingUser=await userfindOne({email: email});
if(!existingUser) return res.status(404).json({message: 'user doesnot exist'});
const isPasswordCorrect=await bcrypt.compare(password,existingUser.password);
if(!isPasswordCorrect) return res.status(400).json({message: 'invalid credintials'});
const token=jwt.sign({email:existingUser.email,id:existingUser._id},process.env.SECRET,{expiresIn:'1h'})
res.status(200).json({result:existingUser,token})
} catch (error) {
res.status(500).json({message:'something went wrong'})
}
}
export const signup=async (res,req)=>{
}