-
Notifications
You must be signed in to change notification settings - Fork 2
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Login reg #7
Open
BigUncleYemi
wants to merge
12
commits into
master
Choose a base branch
from
login-reg
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Login reg #7
Changes from all commits
Commits
Show all changes
12 commits
Select commit
Hold shift + click to select a range
c461bbf
layout view
tanim0la 338f33e
sign in and login page done seting background
BigUncleYemi 2775251
done ui: sign in and login page done as well as the background
BigUncleYemi 945740a
done ui: sign in and login page done as well as the background
BigUncleYemi 24b4270
intial commit
BigUncleYemi 98fc065
fix: background bug
BigUncleYemi debc7e7
fix: bug
BigUncleYemi c7de0fc
fixed warnings and made jwt logic
BigUncleYemi d9a52c5
auth with jwt for login has been made
BigUncleYemi f3cd966
pull request check
BigUncleYemi 6dce799
pull request
BigUncleYemi ddc328e
fixed: added auth
BigUncleYemi File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
Large diffs are not rendered by default.
Oops, something went wrong.
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Binary file not shown.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,40 +1,12 @@ | ||
<!DOCTYPE html> | ||
<html lang="en"> | ||
<head> | ||
<meta charset="utf-8"> | ||
<meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no"> | ||
<meta name="theme-color" content="#000000"> | ||
<!-- | ||
manifest.json provides metadata used when your web app is added to the | ||
homescreen on Android. See https://developers.google.com/web/fundamentals/engage-and-retain/web-app-manifest/ | ||
--> | ||
<link rel="manifest" href="%PUBLIC_URL%/manifest.json"> | ||
<link rel="shortcut icon" href="%PUBLIC_URL%/favicon.ico"> | ||
<!-- | ||
Notice the use of %PUBLIC_URL% in the tags above. | ||
It will be replaced with the URL of the `public` folder during the build. | ||
Only files inside the `public` folder can be referenced from the HTML. | ||
|
||
Unlike "/favicon.ico" or "favicon.ico", "%PUBLIC_URL%/favicon.ico" will | ||
work correctly both with client-side routing and a non-root public URL. | ||
Learn how to configure a non-root public URL by running `npm run build`. | ||
--> | ||
<title>React App</title> | ||
<title>VendorList</title> | ||
</head> | ||
<body> | ||
<noscript> | ||
You need to enable JavaScript to run this app. | ||
</noscript> | ||
<div id="root"></div> | ||
<!-- | ||
This HTML file is a template. | ||
If you open it directly in the browser, you will see an empty page. | ||
|
||
You can add webfonts, meta tags, or analytics to this file. | ||
The build step will place the bundled scripts into the <body> tag. | ||
|
||
To begin the development, run `npm start` or `yarn start`. | ||
To create a production bundle, use `npm run build` or `yarn build`. | ||
--> | ||
</body> | ||
</html> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,21 +1,38 @@ | ||
import React, { Component } from 'react'; | ||
import logo from './logo.svg'; | ||
import React, {Component} from 'react'; | ||
import Header from './components/header'; | ||
import Search from './components/search'; | ||
import Info from './components/info'; | ||
import './App.css'; | ||
import AuthService from './components/helper/auth'; | ||
import withAuth from './components/config/constants'; | ||
const Auth = new AuthService(); | ||
|
||
class App extends Component { | ||
constructor(props) { | ||
super(props) | ||
this.handleLogout = this.handleLogout.bind(this) | ||
} | ||
|
||
handleLogout() { | ||
Auth.logout() | ||
this | ||
.props | ||
.history | ||
.replace('/login'); | ||
} | ||
|
||
render() { | ||
return ( | ||
<div className="App"> | ||
<header className="App-header"> | ||
<img src={logo} className="App-logo" alt="logo" /> | ||
<h1 className="App-title">Welcome to React</h1> | ||
</header> | ||
<p className="App-intro"> | ||
To get started, edit <code>src/App.js</code> and save to reload. | ||
</p> | ||
<button type="button" className="form-submit" onClick={this.handleLogout}>Logout</button> | ||
<Header/> | ||
<br/> | ||
<Search/> | ||
<br/> | ||
<Info/> | ||
</div> | ||
); | ||
} | ||
} | ||
|
||
export default App; | ||
export default withAuth(App); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,177 @@ | ||
import React, { Component } from 'react'; | ||
import AuthService from '../helper/auth'; | ||
import axios from 'axios'; | ||
|
||
export default class Page extends Component { | ||
state={ | ||
signup: true, | ||
signin: false, | ||
Auth: {}, | ||
Reg: {} | ||
} | ||
|
||
toggleSignUp(e){ | ||
this.setState({ | ||
signup: true, | ||
signin: false | ||
}) | ||
} | ||
|
||
toggleSignIn(e){ | ||
this.setState({ | ||
signup: false, | ||
signin: true | ||
}) | ||
} | ||
|
||
|
||
Auth = new AuthService () | ||
|
||
Login(e){ | ||
e.preventDefault(); | ||
const auth = { | ||
email: this.Email.value, | ||
password: this.Password.value | ||
} | ||
const Auth = {...this.state.Auth} | ||
Object.assign(Auth, auth) | ||
this.setState({ | ||
Auth | ||
}) | ||
this.Auth.login(this.state.Auth.email,this.state.Auth.password) | ||
.then(res=>{ | ||
this.props.history.replace("/"); | ||
}) | ||
.catch(err =>{ | ||
alert(err) | ||
}) | ||
this.setState({ | ||
signup: false, | ||
signin: true | ||
}) | ||
} | ||
|
||
register(e){ | ||
const reg = { | ||
email: this.email.value, | ||
name: this.name.value, | ||
telephone: this.telephone.value, | ||
password: this.password.value | ||
} | ||
const Reg = {...this.state.Reg} | ||
const stamp = Date.now(); | ||
Reg[`reg-${stamp}`] = reg; | ||
this.setState({ | ||
Reg | ||
}) | ||
console.log(...this.state.Reg) | ||
axios.post('https://Prostus.herokuapp.com/register', {...this.state.Reg}) | ||
.then(function(response){ | ||
console.log('saved successfully',response.data) | ||
}).catch(err =>{ | ||
alert(err) | ||
}); | ||
} | ||
|
||
componentDidMount(){ | ||
if(this.Auth.loggedIn()) | ||
this.props.history.replace('/') | ||
} | ||
|
||
render() { | ||
|
||
const {signin,signup} = this.state; | ||
|
||
const Login = () => ( | ||
<div className=""> | ||
<form method="POST" onSubmit={(e)=> this.Login(e)} className="measure center"> | ||
<fieldset id="sign_up" className="b--black-80 ba b--transparent ph0 mh0"> | ||
<legend className="f4 fw6 ph0 mh0">Sign In</legend> | ||
<div className="mt3"> | ||
<label className="db fw6 lh-copy f6" htmlFor="email-address">Email</label> | ||
<input className="pa2 input-reset b--black-60 ba bg-transparent w-100" type="email" name="email-address" id="email-address" ref={(input) => this.Email = input}/> | ||
</div> | ||
<div className="mv3"> | ||
<label className="db fw6 lh-copy f6" htmlFor="password">Password</label> | ||
<input className="b pa2 input-reset b--black-60 ba bg-transparent w-100" type="password" name="password" id="password" ref={(input)=> this.Password = input}/> | ||
</div> | ||
<label className="pa0 ma0 lh-copy f6 pointer"><input type="checkbox" /> Remember me</label> | ||
</fieldset> | ||
<div className=""> | ||
<input className="b ph3 pv2 input-reset b--black-60 ba bg-transparent grow pointer f6 dib" type="submit" value="Sign in" /> | ||
</div> | ||
<div className="lh-copy mt3"> | ||
<a href="#0" className="f6 link dim black db" onClick={(e)=>this.toggleSignUp(e)}>Sign Up</a> | ||
<a href="#0" className="f6 link dim black db">Forgot your password?</a> | ||
</div> | ||
</form> | ||
<hr className="mv3"/> | ||
<div className="inline-block-ns white"> | ||
<input className="b ph3 pv2 mv2 white b--transparent ba bg-red grow pointer f6 dib mr2" value="Sign In with Google" /> | ||
<input className="b ph3 pv2 mv2 white b--transparent ba bg-blue grow pointer f6 dib mr2" value="Sign In with Microsoft" /> | ||
<input className="b ph3 pv2 mv2 white b--transparent ba bg-dark-blue grow pointer f6 dib mr2" value="Sign In with Facebook" /> | ||
</div> | ||
</div> | ||
); | ||
|
||
const Register = () => ( | ||
<div> | ||
<form method="POST" onSubmit={(e)=> this.register(e)} className="measure center"> | ||
<fieldset id="sign_up" className="b--black-80 ba b--transparent ph0 mh0"> | ||
<legend className="f4 fw6 ph0 mh0">Sign Up</legend> | ||
<div className="inline-flex-ns"> | ||
<div className="mt3 mr2"> | ||
<label className="db fw6 lh-copy f6" htmlFor="name">Name</label> | ||
<input className="pa2 input-reset b--black-60 ba bg-transparent w-100" type="text" name="name" id="name" ref={(input)=> this.name = input} /> | ||
</div> | ||
<div className="mv3 mr2"> | ||
<label className="db fw6 lh-copy f6" htmlFor="Telephone">Telephone</label> | ||
<input className="b pa2 input-reset b--black-60 ba bg-transparent w-100" type="text" name="telephone" id="telephone" ref={(input)=> this.telephone = input} /> | ||
</div> | ||
</div> | ||
<div className="inline-flex-ns"> | ||
<div className="mt3 mr2"> | ||
<label className="db fw6 lh-copy f6" htmlFor="email-address">Email</label> | ||
<input className="pa2 input-reset b--black-60 ba bg-transparent w-100" type="email" name="email-address" id="email-address" ref={(input)=> this.email = input} /> | ||
</div> | ||
<div className="mv3 mr2"> | ||
<label className="db fw6 lh-copy f6" htmlFor="password">Password</label> | ||
<input className="b pa2 input-reset b--black-60 ba bg-transparent w-100" type="password" name="password" id="password" ref={(input)=> this.password = input} /> | ||
</div> | ||
</div> | ||
</fieldset> | ||
<div className=""> | ||
<input className="b ph3 pv2 input-reset b--black-60 ba bg-transparent grow pointer f6 dib" type="submit" value="Sign up" onClick={(e)=> this.register(e)} /> | ||
</div> | ||
<div className="lh-copy mt3"> | ||
<a href="#0" className="f6 link dim black db" onClick={(e)=>this.toggleSignIn(e)}>Sign In</a> | ||
</div> | ||
</form> | ||
<hr className="mv3"/> | ||
<div className="inline-block-ns white"> | ||
<input className="b ph3 pv2 mv2 white b--transparent ba bg-red grow pointer f6 dib mr2" value="Sign In with Google" /> | ||
<input className="b ph3 pv2 mv2 white b--transparent ba bg-blue grow pointer f6 dib mr2" value="Sign In with Microsoft" /> | ||
<input className="b ph3 pv2 mv2 white b--transparent ba bg-dark-blue grow pointer f6 dib mr2" value="Sign In with Facebook" /> | ||
</div> | ||
</div> | ||
); | ||
|
||
|
||
|
||
return ( | ||
<div> | ||
<div className="user-back"></div> | ||
<div className="login-form-positon "> | ||
<div className="tc"> | ||
<img src="http://tachyons.io/img/avatar_1.jpg" className="br-100 h3 w3 dib ba b--black-60-05 pa2" alt="company logo" title="logo of the company" style={{paddingBotom: '0px'}}/> | ||
<h1 className="f3 mt1 mb4">Vendor</h1> | ||
</div> | ||
<div className=" pa4 black-80 tc"> | ||
{signin === true && <Login />} | ||
{signup === true && <Register />} | ||
</div> | ||
</div> | ||
</div> | ||
); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
import React, {Component} from 'react'; | ||
import AuthService from '../helper/auth'; | ||
|
||
export default function withAuth(AuthComponent) { | ||
const Auth = new AuthService('https://Prostus.herokuapp.com'); | ||
return class AuthWrapped extends Component { | ||
constructor() { | ||
super(); | ||
this.state = { | ||
user: null | ||
} | ||
} | ||
componentWillMount() { | ||
if (!Auth.loggedIn()) { | ||
this | ||
.props | ||
.history | ||
.replace('/login') | ||
} else { | ||
try { | ||
const profile = Auth.getProfile() | ||
this.setState({user: profile}) | ||
} catch (err) { | ||
Auth.logout() | ||
this | ||
.props | ||
.history | ||
.replace('/login') | ||
} | ||
} | ||
} | ||
render() { | ||
if (this.state.user) { | ||
return (<AuthComponent history={this.props.history} user={this.state.user}/>) | ||
} else { | ||
return ( | ||
<h1>loading....</h1> | ||
) | ||
} | ||
} | ||
} | ||
} |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Are you sure this onClick event triggers the
handleLogout
method? you need to bind it .