{"id":16617670,"url":"https://github.com/akku27-cse/mern-auth","last_synced_at":"2026-04-12T06:33:43.303Z","repository":{"id":204233451,"uuid":"711389883","full_name":"akku27-cse/Mern-Auth","owner":"akku27-cse","description":"User Authentaction Useing Mern Log-in or Log-out ","archived":false,"fork":false,"pushed_at":"2024-02-21T04:21:40.000Z","size":368,"stargazers_count":3,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-01-17T19:51:58.774Z","etag":null,"topics":["bcryptjs","cors-request","expressjs","jwt-token","mern-stack","mongodb","reactjs","vscode"],"latest_commit_sha":null,"homepage":"","language":"JavaScript","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/akku27-cse.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}},"created_at":"2023-10-29T05:27:09.000Z","updated_at":"2024-12-29T10:35:53.000Z","dependencies_parsed_at":"2023-11-03T02:33:22.010Z","dependency_job_id":null,"html_url":"https://github.com/akku27-cse/Mern-Auth","commit_stats":null,"previous_names":["akku27-cse/mern-auth"],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/akku27-cse%2FMern-Auth","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/akku27-cse%2FMern-Auth/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/akku27-cse%2FMern-Auth/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/akku27-cse%2FMern-Auth/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/akku27-cse","download_url":"https://codeload.github.com/akku27-cse/Mern-Auth/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":242968496,"owners_count":20214471,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","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","cors-request","expressjs","jwt-token","mern-stack","mongodb","reactjs","vscode"],"created_at":"2024-10-12T02:17:30.443Z","updated_at":"2025-12-24T06:22:29.883Z","avatar_url":"https://github.com/akku27-cse.png","language":"JavaScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"💻\n# Mern-Auth\nview:\n1\u003e\u003e\u003e Postman test\n![postmantest](https://github.com/akku27-cse/Mern-Auth/assets/115920400/f05954c1-bc1a-49df-b82a-07afd23d68d6)\n\n2\u003e\u003e\u003e PostMan token Test\n![postman-token-test](https://github.com/akku27-cse/Mern-Auth/assets/115920400/24baabd9-3e20-40de-937c-943e9767ef7d)\n\n3\u003e\u003e\u003e Databse view\n![image](https://github.com/akku27-cse/Mern-Auth/assets/115920400/e5781e7c-e76f-4eda-bbf5-07be2d7d1a5a)\n\n##Installation \n1.Initialize node Project\n```shell\nnpm init -y\n```\n2.Express\n```shell\nnpm i express\n```\n3.Install Mongoose\n```shell\nnpm i mongoose\n```\n4.Install Cors(for sending response to client)\n```shell\nnpm i cors\n//expamle\nvar express = require('express')\nvar cors = require('cors')\nvar app = express()\n\napp.use(cors())\n\napp.get('/products/:id', function (req, res, next) {\n  res.json({msg: 'This is CORS-enabled for all origins!'})\n})\n\napp.listen(80, function () {\n  console.log('CORS-enabled web server listening on port 80')\n})\n```\n5.Install bcryptjs(for use hashed password)\n```shell\nnpm i bcryptjs\nex==//\nTo hash a password:\n\nvar bcrypt = require('bcryptjs');\nbcrypt.genSalt(10, function(err, salt) {\n    bcrypt.hash(\"B4c0/\\/\", salt, function(err, hash) {\n        // Store hash in your password DB.\n    });\n});\n\nTo check a password:\n\n// Load hash from your password DB.\nbcrypt.compare(\"B4c0/\\/\", hash, function(err, res) {\n    // res === true\n});\nbcrypt.compare(\"not_bacon\", hash, function(err, res) {\n    // res === false\n});\n \n// As of bcryptjs 2.4.0, compare returns a promise if callback is omitted:\nbcrypt.compare(\"B4c0/\\/\", hash).then((res) =\u003e {\n    // res === true\n});\n\nAuto-gen a salt and hash:\n\nbcrypt.hash('bacon', 8, function(err, hash) {\n});\n\n```\n5.Install jwt (for json Web Token)\n```shell\nnpm i jsonwebtoken\n\nex==//\nconst express = require('express'); \nconst dotenv = require('dotenv'); \nconst jwt = require('jsonwebtoken'); \n\nconst app = express(); \n\n// Set up Global configuration access \ndotenv.config(); \n\nlet PORT = process.env.PORT || 5000; \napp.listen(PORT, () =\u003e { \nconsole.log(`Server is up and running on ${PORT} ...`); \n}); \n\n// Main Code Here // \n// Generating JWT \napp.post(\"/user/generateToken\", (req, res) =\u003e { \n\t// Validate User Here \n\t// Then generate JWT Token \n\n\tlet jwtSecretKey = process.env.JWT_SECRET_KEY; \n\tlet data = { \n\t\ttime: Date(), \n\t\tuserId: 12, \n\t} \n\n\tconst token = jwt.sign(data, jwtSecretKey); \n\n\tres.send(token); \n}); \n\n// Verification of JWT \napp.get(\"/user/validateToken\", (req, res) =\u003e { \n\t// Tokens are generally passed in header of request \n\t// Due to security reasons. \n\n\tlet tokenHeaderKey = process.env.TOKEN_HEADER_KEY; \n\tlet jwtSecretKey = process.env.JWT_SECRET_KEY; \n\n\ttry { \n\t\tconst token = req.header(tokenHeaderKey); \n\n\t\tconst verified = jwt.verify(token, jwtSecretKey); \n\t\tif(verified){ \n\t\t\treturn res.send(\"Successfully Verified\"); \n\t\t}else{ \n\t\t\t// Access Denied \n\t\t\treturn res.status(401).send(error); \n\t\t} \n\t} catch (error) { \n\t\t// Access Denied \n\t\treturn res.status(401).send(error); \n\t} \n});\n```\n## Fronted Install\n# Getting Started with Create React App\n\nThis project was bootstrapped with [Create React App](https://github.com/facebook/create-react-app).\n\n## Available Scripts\n\nIn the project directory, you can run:\n\n### `npm start`\n\nRuns the app in the development mode.\\\nOpen [http://localhost:3000](http://localhost:3000) to view it in your browser.\n\nThe page will reload when you make changes.\\\nYou may also see any lint errors in the console.\n\n### `npm test`\n\nLaunches the test runner in the interactive watch mode.\\\nSee the section about [running tests](https://facebook.github.io/create-react-app/docs/running-tests) for more information.\n\n### `npm run build`\n\nBuilds the app for production to the `build` folder.\\\nIt correctly bundles React in production mode and optimizes the build for the best performance.\n\nThe build is minified and the filenames include the hashes.\\\nYour app is ready to be deployed!\n\nSee the section about [deployment](https://facebook.github.io/create-react-app/docs/deployment) for more information.\n\n### `npm run eject`\n\n**Note: this is a one-way operation. Once you `eject`, you can't go back!**\n\nIf you aren't satisfied with the build tool and configuration choices, you can `eject` at any time. This command will remove the single build dependency from your project.\n\nInstead, it will copy all the configuration files and the transitive dependencies (webpack, Babel, ESLint, etc) right into your project so you have full control over them. All of the commands except `eject` will still work, but they will point to the copied scripts so you can tweak them. At this point you're on your own.\n\nYou don't have to ever use `eject`. The curated feature set is suitable for small and middle deployments, and you shouldn't feel obligated to use this feature. However we understand that this tool wouldn't be useful if you couldn't customize it when you are ready for it.\n\n## Learn More\n\nYou can learn more in the [Create React App documentation](https://facebook.github.io/create-react-app/docs/getting-started).\n\nTo learn React, check out the [React documentation](https://reactjs.org/).\n\n### Code Splitting\n\nThis section has moved here: [https://facebook.github.io/create-react-app/docs/code-splitting](https://facebook.github.io/create-react-app/docs/code-splitting)\n\n### Analyzing the Bundle Size\n\nThis section has moved here: [https://facebook.github.io/create-react-app/docs/analyzing-the-bundle-size](https://facebook.github.io/create-react-app/docs/analyzing-the-bundle-size)\n\n### Making a Progressive Web App\n\nThis section has moved here: [https://facebook.github.io/create-react-app/docs/making-a-progressive-web-app](https://facebook.github.io/create-react-app/docs/making-a-progressive-web-app)\n\n### Advanced Configuration\n\nThis section has moved here: [https://facebook.github.io/create-react-app/docs/advanced-configuration](https://facebook.github.io/create-react-app/docs/advanced-configuration)\n\n### Deployment\n\nThis section has moved here: [https://facebook.github.io/create-react-app/docs/deployment](https://facebook.github.io/create-react-app/docs/deployment)\n\n### `npm run build` fails to minify\n\nThis section has moved here: [https://facebook.github.io/create-react-app/docs/troubleshooting#npm-run-build-fails-to-minify](https://facebook.github.io/create-react-app/docs/troubleshooting#npm-run-build-fails-to-minify)\n\n1.React\n```shell\nnpx i create-react-app userauth\n```\n2.React-router-dom\n```shell\nnpm i react-router-dom\n```\n3.Install axios(send request to backend)\n```shell\nnpm i axios\n\nex==//\naxio.post(\"http://localhos:5000/api/signup)\n```\n4.git command \n(basic git commad use in GitHub when first project are added there has some different command like git repository link or git push main)\n```shell\ngit init\ngit status\ngit add .\ngit commit\ngit push\ngit pull\n```\n\n\n\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fakku27-cse%2Fmern-auth","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fakku27-cse%2Fmern-auth","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fakku27-cse%2Fmern-auth/lists"}