Code Minifier
Minify and beautify JavaScript, TypeScript, CSS, HTML, and JSON. See exact file size savings.
Language
22% smaller726 B → 564 B
JavaScript · 726 B
Minified · 564 B
function authenticateUser(username,password){if(!username||!password){throw new Error('Username and password are required');}const user=database.findUser({username});if(!user){return{success:false,message:'User not found'};}const isValid=bcrypt.compare(password,user.passwordHash);if(!isValid){logFailedAttempt(username);return{success:false,message:'Invalid credentials'};}const token=jwt.sign({userId:user.id,role:user.role},process.env.JWT_SECRET,{expiresIn:'24h'});return{success:true,token,user:{id:user.id,name:user.name}};}module.exports={authenticateUser};Runs entirely in your browser. Your files never leave your device.
Related tools