{"id":31199486,"url":"https://github.com/dilan032/login-api","last_synced_at":"2026-04-28T12:02:19.623Z","repository":{"id":313678177,"uuid":"865870279","full_name":"Dilan032/login-API","owner":"Dilan032","description":"User Registration | User  Login","archived":false,"fork":false,"pushed_at":"2025-09-07T18:08:36.000Z","size":2505,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-10-04T05:33:51.226Z","etag":null,"topics":["bcryptjs","body-parser","dotenv","express","hbs","mysql","nodejs","nodemon"],"latest_commit_sha":null,"homepage":"","language":"Handlebars","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/Dilan032.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null,"zenodo":null,"notice":null,"maintainers":null,"copyright":null,"agents":null,"dco":null,"cla":null}},"created_at":"2024-10-01T09:22:11.000Z","updated_at":"2025-09-07T18:08:40.000Z","dependencies_parsed_at":"2025-09-07T20:23:44.694Z","dependency_job_id":"0427d163-be54-4942-b7cb-9c3bdb76f74f","html_url":"https://github.com/Dilan032/login-API","commit_stats":null,"previous_names":["dilan032/login-api"],"tags_count":3,"template":false,"template_full_name":null,"purl":"pkg:github/Dilan032/login-API","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Dilan032%2Flogin-API","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Dilan032%2Flogin-API/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Dilan032%2Flogin-API/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Dilan032%2Flogin-API/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/Dilan032","download_url":"https://codeload.github.com/Dilan032/login-API/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Dilan032%2Flogin-API/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":32379629,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-04-28T11:25:28.583Z","status":"ssl_error","status_checked_at":"2026-04-28T11:25:05.435Z","response_time":56,"last_error":"SSL_connect returned=1 errno=0 peeraddr=140.82.121.5:443 state=error: unexpected eof while reading","robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":false,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["bcryptjs","body-parser","dotenv","express","hbs","mysql","nodejs","nodemon"],"created_at":"2025-09-20T09:41:02.547Z","updated_at":"2026-04-28T12:02:19.602Z","avatar_url":"https://github.com/Dilan032.png","language":"Handlebars","funding_links":[],"categories":[],"sub_categories":[],"readme":"\u003cpre\u003e\n  └── controllers\n    └── auth\n        ├── loginController.js\n        └── registerController.js\n\n\n/controllers/auth/loginController.js:\n--------------------------------------------------------------------------------\n 1 | const bcryptjs = require('bcryptjs');\n 2 | const db = require('../../connection');\n 3 | \n 4 | exports.login = (req, res) =\u003e {\n 5 |     const { email, password} = req.body;\n 6 | \n 7 |     //check the email and password provided\n 8 |     if(!email || !password){\n 9 |         return res.status(400).render('login',{\n10 |             message:'Pleace provide email and password'\n11 |         });\n12 |         // return res.status(400).json({\n13 |         //     message: 'Please fill in all fields',\n14 |         // });\n15 |     }\n16 | \n17 | \n18 |     db.query('SELECT * FROM users WHERE email = ?', [email], async (error, results)=\u003e{\n19 |         if(error){\n20 |             console.log(error);  \n21 |             return res.status(500).render('login', {\n22 |                 message: 'Server error, please try again later' \n23 |             });\n24 |         }\n25 |         if(results.length === 0 ){\n26 |             return res.render('register',{\n27 |                 message:'the Provide email dose not exsit'\n28 |             })\n29 |         }\n30 | \n31 |         // Compare the password entered with the stored hashed password\n32 |         const isMatch = await bcryptjs.compare(password, results[0].password);\n33 | \n34 |         // If password doesn't match\n35 |         if (!isMatch) {\n36 |             return res.status(401).render('login', {\n37 |                 message: 'Incorrect password'\n38 |                 \n39 |             });\n40 |         }\n41 | \n42 |         // If email and password are correct, log the user in\n43 |         res.status(200).redirect(\"/\");\n44 |         \n45 |     });\n46 |     \n47 | }\n\n\n--------------------------------------------------------------------------------\n/controllers/auth/registerController.js:\n--------------------------------------------------------------------------------\n 1 | const bcryptjs = require('bcryptjs');\n 2 | const db = require('../../connection');\n 3 | \n 4 | \n 5 | exports.register = (req, res) =\u003e {\n 6 |     console.log(req.body);\n 7 | \n 8 |     // const name = req.body.name;\n 9 |     // const email = req.body.email;\n10 |     // const password = req.body.password;\n11 | \n12 |     const { name, email, password} = req.body;\n13 | \n14 |     db.query('SELECT email FROM users WHERE email = ?', [email], async (error, results)=\u003e{\n15 |         if(error){\n16 |             console.log(error);\n17 |             return res.status(500).render('register', {\n18 |                 message: 'Server error, please try again later' \n19 |             });   \n20 |         }\n21 |         if(results.length \u003e 0 ){\n22 |             return res.render('register',{\n23 |                 message:'the email is already in use'\n24 |             });\n25 |         }\n26 | \n27 |         // hashed Password\n28 |         let hashedPassword = await bcryptjs.hash(password, 8);\n29 |         // console.log(hashedPassword);\n30 | \n31 |         //insert data into database\n32 |         db.query('INSERT INTO users SET ?', {name:name, email:email, password:hashedPassword}, (error, results) =\u003e{\n33 |             if(error){\n34 |                 console.log(error);\n35 |                 return res.status(500).render('register', {\n36 |                     message: 'Server error, please try again later' \n37 |                 }); \n38 | \n39 |             }else{\n40 |                 console.log(results);\n41 |                 return res.render('login',{\n42 |                     message: 'User Registered'\n43 |                 });\n44 |             }\n45 |         })\n46 |         \n47 |     });\n48 |     \n49 | }\n\u003c/pre\u003e\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdilan032%2Flogin-api","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fdilan032%2Flogin-api","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdilan032%2Flogin-api/lists"}