mirror of
https://github.com/ClaytonWWilson/CS307-Team24.git
synced 2025-12-16 02:08:47 +00:00
Signup is working
This commit is contained in:
parent
00ed9d64c5
commit
27efa858d5
@ -50,7 +50,7 @@ exports.signup = (req, res) => {
|
|||||||
return res.status(400).json(errors);
|
return res.status(400).json(errors);
|
||||||
}
|
}
|
||||||
|
|
||||||
let idToken, userId;
|
let token, userId;
|
||||||
|
|
||||||
db.doc(`/users/${newUser.handle}`)
|
db.doc(`/users/${newUser.handle}`)
|
||||||
.get()
|
.get()
|
||||||
@ -68,8 +68,8 @@ exports.signup = (req, res) => {
|
|||||||
userId = data.user.uid;
|
userId = data.user.uid;
|
||||||
return data.user.getIdToken();
|
return data.user.getIdToken();
|
||||||
})
|
})
|
||||||
.then((token) => {
|
.then((idToken) => {
|
||||||
idToken = token;
|
token = idToken;
|
||||||
const userCred = {
|
const userCred = {
|
||||||
email: req.body.email,
|
email: req.body.email,
|
||||||
handle: newUser.handle,
|
handle: newUser.handle,
|
||||||
@ -79,7 +79,7 @@ exports.signup = (req, res) => {
|
|||||||
return db.doc(`/users/${newUser.handle}`).set(userCred);
|
return db.doc(`/users/${newUser.handle}`).set(userCred);
|
||||||
})
|
})
|
||||||
.then(() => {
|
.then(() => {
|
||||||
return res.status(201).json({ idToken });
|
return res.status(201).json({ token });
|
||||||
})
|
})
|
||||||
.catch((err) => {
|
.catch((err) => {
|
||||||
console.error(err);
|
console.error(err);
|
||||||
|
|||||||
@ -23,7 +23,7 @@ class Userline extends Component {
|
|||||||
|
|
||||||
componentDidMount() {
|
componentDidMount() {
|
||||||
|
|
||||||
axios.get('http://localhost:5001/twistter-e4649/us-central1/api/getallPostsforUser')
|
axios.get('/getallPostsforUser')
|
||||||
.then(res => {
|
.then(res => {
|
||||||
const post = res.data;
|
const post = res.data;
|
||||||
this.setState({microBlogs : post})
|
this.setState({microBlogs : post})
|
||||||
|
|||||||
@ -123,7 +123,7 @@ export class Login extends Component {
|
|||||||
<TextField
|
<TextField
|
||||||
id="password"
|
id="password"
|
||||||
name="password"
|
name="password"
|
||||||
label="password*"
|
label="Password*"
|
||||||
className={classes.textField}
|
className={classes.textField}
|
||||||
value={this.state.password}
|
value={this.state.password}
|
||||||
helperText={errors.password}
|
helperText={errors.password}
|
||||||
|
|||||||
@ -67,6 +67,7 @@ export class Signup extends Component {
|
|||||||
password: this.state.password,
|
password: this.state.password,
|
||||||
confirmPassword: this.state.confirmPassword
|
confirmPassword: this.state.confirmPassword
|
||||||
};
|
};
|
||||||
|
console.log(signupData)
|
||||||
this.props.signupUser(signupData, this.props.history);
|
this.props.signupUser(signupData, this.props.history);
|
||||||
};
|
};
|
||||||
|
|
||||||
@ -95,6 +96,18 @@ export class Signup extends Component {
|
|||||||
Create a new account
|
Create a new account
|
||||||
</Typography>
|
</Typography>
|
||||||
<form noValidate onSubmit={this.handleSubmit}>
|
<form noValidate onSubmit={this.handleSubmit}>
|
||||||
|
<TextField
|
||||||
|
id="handle"
|
||||||
|
name="handle"
|
||||||
|
label="Username*"
|
||||||
|
className={classes.textField}
|
||||||
|
value={this.state.handle}
|
||||||
|
helperText={errors.handle}
|
||||||
|
error={errors.handle ? true : false}
|
||||||
|
variant="outlined"
|
||||||
|
onChange={this.handleChange}
|
||||||
|
fullWidth
|
||||||
|
/>
|
||||||
<TextField
|
<TextField
|
||||||
id="email"
|
id="email"
|
||||||
name="email"
|
name="email"
|
||||||
@ -110,7 +123,7 @@ export class Signup extends Component {
|
|||||||
<TextField
|
<TextField
|
||||||
id="password"
|
id="password"
|
||||||
name="password"
|
name="password"
|
||||||
label="password*"
|
label="Password*"
|
||||||
className={classes.textField}
|
className={classes.textField}
|
||||||
value={this.state.password}
|
value={this.state.password}
|
||||||
helperText={errors.password}
|
helperText={errors.password}
|
||||||
@ -120,6 +133,19 @@ export class Signup extends Component {
|
|||||||
onChange={this.handleChange}
|
onChange={this.handleChange}
|
||||||
fullWidth
|
fullWidth
|
||||||
/>
|
/>
|
||||||
|
<TextField
|
||||||
|
id="confirmPassword"
|
||||||
|
name="confirmPassword"
|
||||||
|
label="Confirm Password*"
|
||||||
|
className={classes.textField}
|
||||||
|
value={this.state.confirmPassword}
|
||||||
|
helperText={errors.confirmPassword}
|
||||||
|
error={errors.confirmPassword ? true : false}
|
||||||
|
type="password"
|
||||||
|
variant="outlined"
|
||||||
|
onChange={this.handleChange}
|
||||||
|
fullWidth
|
||||||
|
/>
|
||||||
<Button
|
<Button
|
||||||
type="submit"
|
type="submit"
|
||||||
variant="contained"
|
variant="contained"
|
||||||
|
|||||||
@ -50,6 +50,12 @@ export class edit extends Component {
|
|||||||
})
|
})
|
||||||
.catch((err) => {
|
.catch((err) => {
|
||||||
console.error(err);
|
console.error(err);
|
||||||
|
if (err.response.status === 403) {
|
||||||
|
alert("You are not logged in");
|
||||||
|
// TODO: Redirect them, to the profile they are trying to edit
|
||||||
|
// If they are on /itsjimmy/edit, they will be redirected to /itsjimmy
|
||||||
|
this.props.history.push('../');
|
||||||
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -104,6 +110,7 @@ export class edit extends Component {
|
|||||||
// Updates the state whenever one of the textboxes changes.
|
// Updates the state whenever one of the textboxes changes.
|
||||||
// The key is the name of the textbox and the value is the
|
// The key is the name of the textbox and the value is the
|
||||||
// value in the text box.
|
// value in the text box.
|
||||||
|
// Also sets errors to null of textboxes that have been edited
|
||||||
handleChange = (event) => {
|
handleChange = (event) => {
|
||||||
this.setState({
|
this.setState({
|
||||||
[event.target.name]: event.target.value,
|
[event.target.name]: event.target.value,
|
||||||
|
|||||||
@ -38,6 +38,8 @@ export const signupUser = (newUserData, history) => (dispatch) => {
|
|||||||
axios
|
axios
|
||||||
.post("/signup", newUserData)
|
.post("/signup", newUserData)
|
||||||
.then((res) => {
|
.then((res) => {
|
||||||
|
console.log(res);
|
||||||
|
console.log(res.data);
|
||||||
// Save the signup token
|
// Save the signup token
|
||||||
setAuthorizationHeader(res.data.token);
|
setAuthorizationHeader(res.data.token);
|
||||||
dispatch(getUserData());
|
dispatch(getUserData());
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user