mirror of
https://github.com/ClaytonWWilson/CS307-Team24.git
synced 2025-12-15 18:08:46 +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);
|
||||
}
|
||||
|
||||
let idToken, userId;
|
||||
let token, userId;
|
||||
|
||||
db.doc(`/users/${newUser.handle}`)
|
||||
.get()
|
||||
@ -68,8 +68,8 @@ exports.signup = (req, res) => {
|
||||
userId = data.user.uid;
|
||||
return data.user.getIdToken();
|
||||
})
|
||||
.then((token) => {
|
||||
idToken = token;
|
||||
.then((idToken) => {
|
||||
token = idToken;
|
||||
const userCred = {
|
||||
email: req.body.email,
|
||||
handle: newUser.handle,
|
||||
@ -79,7 +79,7 @@ exports.signup = (req, res) => {
|
||||
return db.doc(`/users/${newUser.handle}`).set(userCred);
|
||||
})
|
||||
.then(() => {
|
||||
return res.status(201).json({ idToken });
|
||||
return res.status(201).json({ token });
|
||||
})
|
||||
.catch((err) => {
|
||||
console.error(err);
|
||||
|
||||
@ -23,7 +23,7 @@ class Userline extends Component {
|
||||
|
||||
componentDidMount() {
|
||||
|
||||
axios.get('http://localhost:5001/twistter-e4649/us-central1/api/getallPostsforUser')
|
||||
axios.get('/getallPostsforUser')
|
||||
.then(res => {
|
||||
const post = res.data;
|
||||
this.setState({microBlogs : post})
|
||||
|
||||
@ -123,7 +123,7 @@ export class Login extends Component {
|
||||
<TextField
|
||||
id="password"
|
||||
name="password"
|
||||
label="password*"
|
||||
label="Password*"
|
||||
className={classes.textField}
|
||||
value={this.state.password}
|
||||
helperText={errors.password}
|
||||
|
||||
@ -67,6 +67,7 @@ export class Signup extends Component {
|
||||
password: this.state.password,
|
||||
confirmPassword: this.state.confirmPassword
|
||||
};
|
||||
console.log(signupData)
|
||||
this.props.signupUser(signupData, this.props.history);
|
||||
};
|
||||
|
||||
@ -95,6 +96,18 @@ export class Signup extends Component {
|
||||
Create a new account
|
||||
</Typography>
|
||||
<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
|
||||
id="email"
|
||||
name="email"
|
||||
@ -110,7 +123,7 @@ export class Signup extends Component {
|
||||
<TextField
|
||||
id="password"
|
||||
name="password"
|
||||
label="password*"
|
||||
label="Password*"
|
||||
className={classes.textField}
|
||||
value={this.state.password}
|
||||
helperText={errors.password}
|
||||
@ -120,6 +133,19 @@ export class Signup extends Component {
|
||||
onChange={this.handleChange}
|
||||
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
|
||||
type="submit"
|
||||
variant="contained"
|
||||
|
||||
@ -50,6 +50,12 @@ export class edit extends Component {
|
||||
})
|
||||
.catch((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.
|
||||
// The key is the name of the textbox and the value is the
|
||||
// value in the text box.
|
||||
// Also sets errors to null of textboxes that have been edited
|
||||
handleChange = (event) => {
|
||||
this.setState({
|
||||
[event.target.name]: event.target.value,
|
||||
|
||||
@ -38,6 +38,8 @@ export const signupUser = (newUserData, history) => (dispatch) => {
|
||||
axios
|
||||
.post("/signup", newUserData)
|
||||
.then((res) => {
|
||||
console.log(res);
|
||||
console.log(res.data);
|
||||
// Save the signup token
|
||||
setAuthorizationHeader(res.data.token);
|
||||
dispatch(getUserData());
|
||||
|
||||
Loading…
Reference in New Issue
Block a user