Created
June 29, 2018 00:37
-
-
Save NickFoden/a883e79091ce6e5b706ff9f0d263bdee to your computer and use it in GitHub Desktop.
Vidmark
This file contains hidden or 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
import React, { Component } from "react"; | |
import firebase from "../config/firebase"; | |
import { | |
FormGroup, | |
ControlLabel, | |
FormControl, | |
Button, | |
Form | |
} from "react-bootstrap"; | |
import "./components-css/login.css"; | |
class LogIn extends Component { | |
constructor(props) { | |
super(props); | |
this.state = { | |
email: "", | |
password: "", | |
error: { message: "" } | |
}; | |
// this.userLogin = this.userLogin.bind(this); | |
this.handleSubmit = this.handleSubmit.bind(this); | |
this.handleChange = this.handleChange.bind(this); | |
} | |
handleChange(event) { | |
const target = event.target; | |
const value = target.value; | |
const name = target.name; | |
this.setState({ [name]: value }); | |
} | |
handleSubmit(e) { | |
e.preventDefault(); | |
debugger; | |
const { email, password } = this.state; | |
firebase | |
.auth() | |
.signInWithEmailAndPassword(email, password) | |
.then(user => { | |
console.log("logged in user", user); | |
}) | |
.catch(error => { | |
console.log("error", error); | |
}); | |
} | |
// handleSubmit = async e => { | |
// e.preventDefault(); | |
// try { | |
// await firebase.signIn(this.state.email, this.state.password); | |
// this.props.userHasAuthenticated(true); | |
// this.props.history.push("/dashboard"); | |
// } catch (e) { | |
// alert(e.message); | |
// } | |
// } | |
render() { | |
return ( | |
<div className="Login"> | |
<Form onSubmit={this.handleSubmit}> | |
<FormGroup controlId="email" bsSize="large"> | |
<ControlLabel>Email</ControlLabel> | |
<FormControl | |
type="email" | |
name="email" | |
onChange={this.handleChange} | |
/> | |
</FormGroup> | |
<FormGroup controlId="password" bsSize="large"> | |
<ControlLabel>Password</ControlLabel> | |
<FormControl | |
name="password" | |
onChange={this.handleChange} | |
type="password" | |
/> | |
</FormGroup> | |
<Button bsSize="large" type="submit"> | |
Login | |
</Button> | |
</Form> | |
</div> | |
); | |
} | |
} | |
export default LogIn; |
This file contains hidden or 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
import React, { Component } from "react"; | |
import firebase from "../config/firebase"; | |
import { | |
FormGroup, | |
ControlLabel, | |
FormControl, | |
Button, | |
Form | |
} from "react-bootstrap"; | |
import "./components-css/login.css"; | |
class LogIn extends Component { | |
constructor(props) { | |
super(props); | |
this.state = { | |
email: "", | |
password: "", | |
error: { message: "" } | |
}; | |
// this.userLogin = this.userLogin.bind(this); | |
this.handleSubmit = this.handleSubmit.bind(this); | |
this.handleChange = this.handleChange.bind(this); | |
} | |
handleChange(event) { | |
const target = event.target; | |
const value = target.value; | |
const name = target.name; | |
this.setState({ [name]: value }); | |
} | |
handleSubmit(e) { | |
e.preventDefault(); | |
debugger; | |
const { email, password } = this.state; | |
firebase | |
.auth() | |
.createUserWithEmailAndPassword(email, password) | |
.then(user => { | |
console.log("logged in user", user); | |
}) | |
.catch(error => { | |
console.log("error", error); | |
}); | |
} | |
// handleSubmit = async e => { | |
// e.preventDefault(); | |
// try { | |
// await firebase.signIn(this.state.email, this.state.password); | |
// this.props.userHasAuthenticated(true); | |
// this.props.history.push("/dashboard"); | |
// } catch (e) { | |
// alert(e.message); | |
// } | |
// } | |
render() { | |
return ( | |
<div className="Login"> | |
<Form onSubmit={this.handleSubmit}> | |
<FormGroup controlId="email" bsSize="large"> | |
<ControlLabel>Email</ControlLabel> | |
<FormControl | |
type="email" | |
name="email" | |
onChange={this.handleChange} | |
/> | |
</FormGroup> | |
<FormGroup controlId="password" bsSize="large"> | |
<ControlLabel>Password</ControlLabel> | |
<FormControl | |
name="password" | |
onChange={this.handleChange} | |
type="password" | |
/> | |
</FormGroup> | |
<Button bsSize="large" type="submit"> | |
Register | |
</Button> | |
</Form> | |
</div> | |
); | |
} | |
} | |
export default LogIn; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment