From 2d6ae26016e66f7802dbbd54f9753f9ccfb945bc Mon Sep 17 00:00:00 2001 From: Priyatham-sai-chand Date: Mon, 9 Nov 2020 22:15:04 +0530 Subject: [PATCH] user auth ui --- auth/routes/users.js | 58 ++++++++++++- package-lock.json | 88 +++++++++++++++++++ package.json | 1 + src/App.css | 38 -------- src/App.js | 7 +- src/components/HomePage.js | 16 ++-- src/components/LogInContainer.js | 37 ++++++++ src/components/SignIn.js | 57 ++++++++++++ src/components/SignUp.js | 68 +++++++++++++++ src/{style.css => homepage.css} | 0 src/index.css | 15 ++++ src/index.js | 2 +- src/login_reg.css | 145 +++++++++++++++++++++++++++++++ 13 files changed, 486 insertions(+), 46 deletions(-) delete mode 100644 src/App.css create mode 100644 src/components/LogInContainer.js create mode 100644 src/components/SignIn.js create mode 100644 src/components/SignUp.js rename src/{style.css => homepage.css} (100%) create mode 100644 src/index.css create mode 100644 src/login_reg.css diff --git a/auth/routes/users.js b/auth/routes/users.js index 2a8be9c..6fb7da4 100644 --- a/auth/routes/users.js +++ b/auth/routes/users.js @@ -12,7 +12,7 @@ router.post( check('email','E-mail is required').isEmail(), check('password','Password is required').notEmpty() ], - async (req,res) =>{ + async (req,res) =>{ try{ let { username,email,phonenumber,password } = req.body; @@ -61,4 +61,60 @@ router.post( } ) +router.post( + '/login', + [ + check('email',"Type valid e-mail").isEmail(), + check('password','Passoword is required').notEmpty() + ], + async (req,res) => { + try{ + + const { email, password } = req.body; + + let user = await UserSchema.findOne({ email }); + const errors = validationResult(req); + + if(!errors.isEmpty()){ + return res.status(401).json({ + errors: errors.array() + }); + } + + if(!user) { + return res.status(401).json({ msg: "This user doesn't exists"}); + } + + let isPassowardMatch = await bcrypt.compare(password,user.password); + + if(isPassowardMatch){ + const payload = { + user: { + id: user.id, + + } + } + jwt.sign( + payload, + config.get('jwtSecret'), + (err,token) =>{ + if(err) throw err; + res.json({ token }); + } + ) + + + }else return res.status(401).json({ + msg:"incorrect Passoword" + }); + + } catch (error) { + console.log(error.message); + return res.status(500).json({ + msg:"serve error ...." + }); + } + + } +) module.exports = router; \ No newline at end of file diff --git a/package-lock.json b/package-lock.json index 571bbdb..6d6c5f6 100644 --- a/package-lock.json +++ b/package-lock.json @@ -7085,6 +7085,19 @@ "resolved": "https://registry.npmjs.org/hex-color-regex/-/hex-color-regex-1.1.0.tgz", "integrity": "sha512-l9sfDFsuqtOqKDsQdqrMRk0U85RZc0RtOR9yPI7mRVOa4FsR/BVnZ0shmQRM96Ji99kYZP/7hn1cedc1+ApsTQ==" }, + "history": { + "version": "4.10.1", + "resolved": "https://registry.npmjs.org/history/-/history-4.10.1.tgz", + "integrity": "sha512-36nwAD620w12kuzPAsyINPWJqlNbij+hpK1k9XRloDtym8mxzGYl2c17LnV6IAGB2Dmg4tEa7G7DlawS0+qjew==", + "requires": { + "@babel/runtime": "^7.1.2", + "loose-envify": "^1.2.0", + "resolve-pathname": "^3.0.0", + "tiny-invariant": "^1.0.2", + "tiny-warning": "^1.0.0", + "value-equal": "^1.0.1" + } + }, "hmac-drbg": { "version": "1.0.1", "resolved": "https://registry.npmjs.org/hmac-drbg/-/hmac-drbg-1.0.1.tgz", @@ -10049,6 +10062,15 @@ "resolved": "https://registry.npmjs.org/min-indent/-/min-indent-1.0.1.tgz", "integrity": "sha512-I9jwMn07Sy/IwOj3zVkVik2JTvgpaykDZEigL6Rx6N9LbMywwUSMtxET+7lVoDLLd3O3IXwJwvuuns8UB/HeAg==" }, + "mini-create-react-context": { + "version": "0.4.1", + "resolved": "https://registry.npmjs.org/mini-create-react-context/-/mini-create-react-context-0.4.1.tgz", + "integrity": "sha512-YWCYEmd5CQeHGSAKrYvXgmzzkrvssZcuuQDDeqkT+PziKGMgE+0MCCtcKbROzocGBG1meBLl2FotlRwf4gAzbQ==", + "requires": { + "@babel/runtime": "^7.12.1", + "tiny-warning": "^1.0.3" + } + }, "mini-css-extract-plugin": { "version": "0.11.3", "resolved": "https://registry.npmjs.org/mini-css-extract-plugin/-/mini-css-extract-plugin-0.11.3.tgz", @@ -12536,6 +12558,52 @@ "resolved": "https://registry.npmjs.org/react-refresh/-/react-refresh-0.8.3.tgz", "integrity": "sha512-X8jZHc7nCMjaCqoU+V2I0cOhNW+QMBwSUkeXnTi8IPe6zaRWfn60ZzvFDZqWPfmSJfjub7dDW1SP0jaHWLu/hg==" }, + "react-router": { + "version": "5.2.0", + "resolved": "https://registry.npmjs.org/react-router/-/react-router-5.2.0.tgz", + "integrity": "sha512-smz1DUuFHRKdcJC0jobGo8cVbhO3x50tCL4icacOlcwDOEQPq4TMqwx3sY1TP+DvtTgz4nm3thuo7A+BK2U0Dw==", + "requires": { + "@babel/runtime": "^7.1.2", + "history": "^4.9.0", + "hoist-non-react-statics": "^3.1.0", + "loose-envify": "^1.3.1", + "mini-create-react-context": "^0.4.0", + "path-to-regexp": "^1.7.0", + "prop-types": "^15.6.2", + "react-is": "^16.6.0", + "tiny-invariant": "^1.0.2", + "tiny-warning": "^1.0.0" + }, + "dependencies": { + "isarray": { + "version": "0.0.1", + "resolved": "https://registry.npmjs.org/isarray/-/isarray-0.0.1.tgz", + "integrity": "sha1-ihis/Kmo9Bd+Cav8YDiTmwXR7t8=" + }, + "path-to-regexp": { + "version": "1.8.0", + "resolved": "https://registry.npmjs.org/path-to-regexp/-/path-to-regexp-1.8.0.tgz", + "integrity": "sha512-n43JRhlUKUAlibEJhPeir1ncUID16QnEjNpwzNdO3Lm4ywrBpBZ5oLD0I6br9evr1Y9JTqwRtAh7JLoOzAQdVA==", + "requires": { + "isarray": "0.0.1" + } + } + } + }, + "react-router-dom": { + "version": "5.2.0", + "resolved": "https://registry.npmjs.org/react-router-dom/-/react-router-dom-5.2.0.tgz", + "integrity": "sha512-gxAmfylo2QUjcwxI63RhQ5G85Qqt4voZpUXSEqCwykV0baaOTQDR1f0PmY8AELqIyVc0NEZUj0Gov5lNGcXgsA==", + "requires": { + "@babel/runtime": "^7.1.2", + "history": "^4.9.0", + "loose-envify": "^1.3.1", + "prop-types": "^15.6.2", + "react-router": "5.2.0", + "tiny-invariant": "^1.0.2", + "tiny-warning": "^1.0.0" + } + }, "react-scripts": { "version": "4.0.0", "resolved": "https://registry.npmjs.org/react-scripts/-/react-scripts-4.0.0.tgz", @@ -13002,6 +13070,11 @@ "resolved": "https://registry.npmjs.org/resolve-from/-/resolve-from-4.0.0.tgz", "integrity": "sha512-pb/MYmXstAkysRFx8piNI1tGFNQIFA3vkE3Gq4EuA1dF6gHp/+vgZqsCGJapvy8N3Q+4o7FwvquPJcnZ7RYy4g==" }, + "resolve-pathname": { + "version": "3.0.0", + "resolved": "https://registry.npmjs.org/resolve-pathname/-/resolve-pathname-3.0.0.tgz", + "integrity": "sha512-C7rARubxI8bXFNB/hqcp/4iUeIXJhJZvFPFPiSPRnhU5UPxzMFIl+2E6yY6c4k9giDJAhtV+enfA+G89N6Csng==" + }, "resolve-url": { "version": "0.2.1", "resolved": "https://registry.npmjs.org/resolve-url/-/resolve-url-0.2.1.tgz", @@ -14801,6 +14874,16 @@ "resolved": "https://registry.npmjs.org/timsort/-/timsort-0.3.0.tgz", "integrity": "sha1-QFQRqOfmM5/mTbmiNN4R3DHgK9Q=" }, + "tiny-invariant": { + "version": "1.1.0", + "resolved": "https://registry.npmjs.org/tiny-invariant/-/tiny-invariant-1.1.0.tgz", + "integrity": "sha512-ytxQvrb1cPc9WBEI/HSeYYoGD0kWnGEOR8RY6KomWLBVhqz0RgTwVO9dLrGz7dC+nN9llyI7OKAgRq8Vq4ZBSw==" + }, + "tiny-warning": { + "version": "1.0.3", + "resolved": "https://registry.npmjs.org/tiny-warning/-/tiny-warning-1.0.3.tgz", + "integrity": "sha512-lBN9zLN/oAf68o3zNXYrdCt1kP8WsiGW8Oo2ka41b2IM5JL/S1CTyX1rW0mb/zSuJun0ZUrDxx4sqvYS2FWzPA==" + }, "tmp": { "version": "0.0.33", "resolved": "https://registry.npmjs.org/tmp/-/tmp-0.0.33.tgz", @@ -15260,6 +15343,11 @@ "spdx-expression-parse": "^3.0.0" } }, + "value-equal": { + "version": "1.0.1", + "resolved": "https://registry.npmjs.org/value-equal/-/value-equal-1.0.1.tgz", + "integrity": "sha512-NOJ6JZCAWr0zlxZt+xqCHNTEKOsrks2HQd4MqhP1qy4z1SkbEP467eNx6TgDKXMvUOb+OENfJCZwM+16n7fRfw==" + }, "vary": { "version": "1.1.2", "resolved": "https://registry.npmjs.org/vary/-/vary-1.1.2.tgz", diff --git a/package.json b/package.json index c69b11e..22efc41 100644 --- a/package.json +++ b/package.json @@ -10,6 +10,7 @@ "react": "^17.0.1", "react-bootstrap": "^1.4.0", "react-dom": "^17.0.1", + "react-router-dom": "^5.2.0", "react-scripts": "4.0.0", "styled-components": "^5.2.1", "web-vitals": "^0.2.4" diff --git a/src/App.css b/src/App.css deleted file mode 100644 index 74b5e05..0000000 --- a/src/App.css +++ /dev/null @@ -1,38 +0,0 @@ -.App { - text-align: center; -} - -.App-logo { - height: 40vmin; - pointer-events: none; -} - -@media (prefers-reduced-motion: no-preference) { - .App-logo { - animation: App-logo-spin infinite 20s linear; - } -} - -.App-header { - background-color: #282c34; - min-height: 100vh; - display: flex; - flex-direction: column; - align-items: center; - justify-content: center; - font-size: calc(10px + 2vmin); - color: white; -} - -.App-link { - color: #61dafb; -} - -@keyframes App-logo-spin { - from { - transform: rotate(0deg); - } - to { - transform: rotate(360deg); - } -} diff --git a/src/App.js b/src/App.js index fbe6818..80aa976 100644 --- a/src/App.js +++ b/src/App.js @@ -1,10 +1,15 @@ import React, { Component } from 'react'; +import { Switch, Route, withRouter } from "react-router-dom"; import HomePage from "./components/HomePage"; +import Login from "./components/SignIn"; +import LogInContainer from "./components/LogInContainer"; class App extends Component { render(){ return (
- + < LogInContainer /> + +
); diff --git a/src/components/HomePage.js b/src/components/HomePage.js index f09570c..2e836b8 100644 --- a/src/components/HomePage.js +++ b/src/components/HomePage.js @@ -1,10 +1,14 @@ import React, { Component } from 'react'; -import { Button } from 'react-bootstrap'; -import 'C:\\Priyathamwork\\locaft\\locaft\\src\\style.css'; +import '../homepage.css'; +import LogInContainer from './LogInContainer'; import 'bootstrap/dist/css/bootstrap.min.css'; class HomePage extends Component { + state = { render: false } + add = () => { + this.setState({render : !this.state.render}) + } render(){ return (
@@ -34,7 +38,7 @@ class HomePage extends Component { Blog @@ -44,13 +48,15 @@ class HomePage extends Component {
- +

Adapt to a new place easy peasy.

- + +
+
locaft-mockup
diff --git a/src/components/LogInContainer.js b/src/components/LogInContainer.js new file mode 100644 index 0000000..1689700 --- /dev/null +++ b/src/components/LogInContainer.js @@ -0,0 +1,37 @@ +import React, { Component } from 'react'; +import { HashRouter as Router, Route, Link, NavLink } from 'react-router-dom'; +import SignUpForm from './SignUp'; +import SignInForm from './SignIn'; + +import '../login_reg.css'; + +class LogInContainer extends Component { + render() { + return ( + +
+
+
+
+ Sign In + Sign Up +
+ +
+ Sign In or Sign Up +
+ + + + + +
+ +
+
+ ); + } +} + +export default LogInContainer; + diff --git a/src/components/SignIn.js b/src/components/SignIn.js new file mode 100644 index 0000000..38fc5ad --- /dev/null +++ b/src/components/SignIn.js @@ -0,0 +1,57 @@ +import React, { Component } from 'react'; +import { Link } from 'react-router-dom'; + +class SignInForm extends Component { + constructor() { + super(); + + this.state = { + email: '', + password: '' + }; + + this.handleChange = this.handleChange.bind(this); + this.handleSubmit = this.handleSubmit.bind(this); + } + + handleChange(e) { + let target = e.target; + let value = target.type === 'checkbox' ? target.checked : target.value; + let name = target.name; + + this.setState({ + [name]: value + }); + } + + handleSubmit(e) { + e.preventDefault(); + + console.log('The form was submitted with the following data:'); + console.log(this.state); + } + + render() { + return ( +
+
+
+ + +
+ +
+ + +
+ +
+ Create an account +
+
+
+ ); + } +} + +export default SignInForm; \ No newline at end of file diff --git a/src/components/SignUp.js b/src/components/SignUp.js new file mode 100644 index 0000000..13be839 --- /dev/null +++ b/src/components/SignUp.js @@ -0,0 +1,68 @@ +import React, { Component } from 'react'; +import { Link } from 'react-router-dom'; + +class SignUpForm extends Component { + constructor() { + super(); + + this.state = { + email: '', + password: '', + name: '', + hasAgreed: false + }; + + this.handleChange = this.handleChange.bind(this); + this.handleSubmit = this.handleSubmit.bind(this); + } + + handleChange(e) { + let target = e.target; + let value = target.type === 'checkbox' ? target.checked : target.value; + let name = target.name; + + this.setState({ + [name]: value + }); + } + + handleSubmit(e) { + e.preventDefault(); + + console.log('The form was submitted with the following data:'); + console.log(this.state); + } + + render() { + return ( +
+
+
+ + +
+
+ + +
+
+ + +
+ +
+ +
+ +
+ I'm already member +
+
+
+ ); + } +} + +export default SignUpForm; \ No newline at end of file diff --git a/src/style.css b/src/homepage.css similarity index 100% rename from src/style.css rename to src/homepage.css diff --git a/src/index.css b/src/index.css new file mode 100644 index 0000000..c8bfaee --- /dev/null +++ b/src/index.css @@ -0,0 +1,15 @@ +@import url('https://fonts.googleapis.com/css?family=Roboto:300,400,500,700'); + +* { + box-sizing: border-box; + font-family: "Roboto", sans-serif; +} + +body { + margin: 0; + padding: 0; +} + +.mr-20 { + margin-right: 20px !important; +} \ No newline at end of file diff --git a/src/index.js b/src/index.js index 71b4c0c..2d0667b 100644 --- a/src/index.js +++ b/src/index.js @@ -1,6 +1,6 @@ import React from 'react'; import ReactDOM from 'react-dom'; - +import './index.css'; import App from './App'; ReactDOM.render(,document.getElementById('root')); diff --git a/src/login_reg.css b/src/login_reg.css new file mode 100644 index 0000000..89a43af --- /dev/null +++ b/src/login_reg.css @@ -0,0 +1,145 @@ +.Apper { + height: 100vh; + display: flex; + color: white; +} + +.Apper__Aside { + width: 50%; + background-color: #66DAC7; +} + +.Apper__Form { + width: 50%; + background-color: #2E4158; + padding: 25px 40px; + overflow: auto; +} + +.PageSwitcher { + display: flex; + justify-content: flex-end; + margin-bottom: 10%; +} + +.PageSwitcher__Item { + background-color: #4C5D72; + color: #9DA6B1; + padding: 10px 25px; + cursor: pointer; + font-size: .9em; + border: none; + outline: none; + display: inline-block; + text-decoration: none; +} + +.PageSwitcher__Item--Active { + background-color: #5ED0C0; + color: white; +} + +.PageSwitcher__Item:first-child { + border-top-left-radius: 25px; + border-bottom-left-radius: 25px; +} +.PageSwitcher__Item:last-child { + border-top-right-radius: 25px; + border-bottom-right-radius: 25px; +} + +.FormCenter { + margin-bottom: 100px; +} + +.FormTitle { + color: #707C8B; + font-weight: 300; + margin-bottom: 50px; +} + +.FormTitle__Link { + color: #707C8B; + text-decoration: none; + display: inline-block; + font-size: 1.7em; + margin: 0 10px; + padding-bottom: 5px; +} + +.FormTitle__Link:first-child { + margin-left: 0; +} + +.FormTitle__Link--Active { + color: white; + border-bottom: 1px solid #199087; +} + +.FormField { + margin-bottom: 40px; +} + +.FormField__Label { + display: block; + text-transform: uppercase; + font-size: .9em; + color: white; + text-align: start; + margin-left:45px; + +} +.FormField__Input { + width: 85%; + background-color: transparent; + border: none; + color: white; + outline: none; + border-bottom: 1px solid #445366; + font-size: 1em; + font-weight: 300; + padding-bottom: 10px; + margin-top: 10px; +} + +.FormField__Input::placeholder { + color: #616E7F; +} + +.FormField__Button { + background-color: #52C4B9; + color: white; + border: none; + outline: none; + border-radius: 25px; + padding: 15px 70px; + font-size: .8em; + font-weight: 500; +} + +.FormField__Link { + color: #66707D; + text-decoration: none; + display: inline-block; + border-bottom: 1.5px solid #225E62; + padding-bottom: 5px; +} + +.FormField__CheckboxLabel { + color: #646F7D; + font-size: .9em; +} + +.FormField__Checkbox { + position: relative; + top: 1.5px; +} + +.FormField__TermsLink { + color: white; + border-bottom: 1px solid #199087; + text-decoration: none; + display: inline-block; + padding-bottom: 2px; + margin-left: 5px; +} \ No newline at end of file