mirror of
https://github.com/ClaytonWWilson/CS307-Team24.git
synced 2026-03-10 13:15:05 +00:00
Merge branch 'master' into profile_display
This commit is contained in:
@@ -1,5 +1,10 @@
|
||||
This project was bootstrapped with [Create React App](https://github.com/facebookincubator/create-react-app).
|
||||
|
||||
|
||||
Cloud: https://us-central1-twistter-e4649.cloudfunctions.net/api
|
||||
Local: http://localhost:5001/twistter-e4649/us-central1/api (npm install --save firebase)
|
||||
|
||||
|
||||
Below you will find some information on how to perform common tasks.<br>
|
||||
You can find the most recent version of this guide [here](https://github.com/facebookincubator/create-react-app/blob/master/packages/react-scripts/template/README.md).
|
||||
|
||||
|
||||
@@ -27,6 +27,7 @@ import signup from './pages/Signup';
|
||||
import login from './pages/Login';
|
||||
import user from './pages/user';
|
||||
import logout from './pages/Logout';
|
||||
import Delete from './pages/Delete';
|
||||
import writeMicroblog from './Writing_Microblogs.js';
|
||||
import editProfile from './pages/editProfile';
|
||||
import userLine from './Userline.js';
|
||||
@@ -63,6 +64,7 @@ class App extends Component {
|
||||
<AuthRoute exact path="/signup" component={signup} />
|
||||
<AuthRoute exact path="/login" component={login} />
|
||||
<Route exact path="/logout" component={logout} />
|
||||
<Route exact path="/delete" component={Delete} />
|
||||
|
||||
<Route exact path="/user" component={user} />
|
||||
<Route exact path="/home" component={writeMicroblog} />
|
||||
|
||||
@@ -50,9 +50,12 @@ import withStyles from "@material-ui/core/styles/withStyles";
|
||||
<Button component={ Link } to='/signup'>
|
||||
Sign Up
|
||||
</Button>
|
||||
<Button component={ Link } to='/logout'>
|
||||
Logout
|
||||
</Button>
|
||||
<Button component={ Link } to='/logout'>
|
||||
Logout
|
||||
</Button>
|
||||
<Button component={ Link } to='/delete'>
|
||||
Delete Account
|
||||
</Button>
|
||||
</ToolBar>
|
||||
</AppBar>
|
||||
)
|
||||
|
||||
56
twistter-frontend/src/pages/Delete.js
Normal file
56
twistter-frontend/src/pages/Delete.js
Normal file
@@ -0,0 +1,56 @@
|
||||
/* eslint-disable */
|
||||
import React, { Component } from "react";
|
||||
import PropTypes from "prop-types";
|
||||
|
||||
// Material UI stuff
|
||||
import Button from "@material-ui/core/Button";
|
||||
import withStyles from "@material-ui/core/styles/withStyles";
|
||||
|
||||
// Redux stuff
|
||||
import { logoutUser } from "../redux/actions/userActions";
|
||||
import { connect } from "react-redux";
|
||||
|
||||
const styles = {
|
||||
form: {
|
||||
textAlign: "center"
|
||||
},
|
||||
textField: {
|
||||
marginBottom: 30
|
||||
},
|
||||
pageTitle: {
|
||||
marginBottom: 40
|
||||
},
|
||||
button: {
|
||||
positon: "relative",
|
||||
marginBottom: 30
|
||||
},
|
||||
progress: {
|
||||
position: "absolute"
|
||||
}
|
||||
};
|
||||
|
||||
export class Delete extends Component {
|
||||
|
||||
componentDidMount() {
|
||||
this.props.logoutUser();
|
||||
this.props.history.push('/');
|
||||
}
|
||||
|
||||
render() {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
const mapStateToProps = (state) => ({
|
||||
user: state.user
|
||||
});
|
||||
|
||||
const mapActionsToProps = { logoutUser };
|
||||
|
||||
Delete.propTypes = {
|
||||
logoutUser: PropTypes.func.isRequired,
|
||||
user: PropTypes.object.isRequired,
|
||||
classes: PropTypes.object.isRequired
|
||||
};
|
||||
|
||||
export default connect(mapStateToProps, mapActionsToProps)(withStyles(styles)(Delete));
|
||||
@@ -146,7 +146,7 @@ export class Login extends Component {
|
||||
)}
|
||||
</Button>
|
||||
{errors.general && (
|
||||
<Typography color="error">Wrong Email or Password</Typography>
|
||||
<Typography color="error">Invalid username/email or password</Typography>
|
||||
)}
|
||||
</form>
|
||||
</Grid>
|
||||
|
||||
@@ -159,7 +159,7 @@ export class Signup extends Component {
|
||||
)}
|
||||
</Button>
|
||||
{errors.general && (
|
||||
<Typography color="error">Wrong Email or Password</Typography>
|
||||
<Typography color="error">Invalid username/email or password</Typography>
|
||||
)}
|
||||
</form>
|
||||
</Grid>
|
||||
|
||||
@@ -88,6 +88,14 @@ export class edit extends Component {
|
||||
handle: this.state.handle,
|
||||
bio: this.state.bio
|
||||
};
|
||||
|
||||
// Removes all keys from newProfileData that are empty, undefined, or null
|
||||
Object.keys(newProfileData).forEach(key => {
|
||||
if (newProfileData[key] === "" || newProfileData[key] === undefined || newProfileData[key] === null) {
|
||||
delete newProfileData[key];
|
||||
}
|
||||
})
|
||||
|
||||
axios
|
||||
.post("/updateProfileInfo", newProfileData)
|
||||
.then((res) => {
|
||||
|
||||
@@ -61,6 +61,26 @@ export const logoutUser = () => (dispatch) => {
|
||||
dispatch({ type: SET_UNAUTHENTICATED });
|
||||
}
|
||||
|
||||
export const deleteUser = () => (dispatch) => {
|
||||
axios
|
||||
.delete("/delete")
|
||||
.then((res) => {
|
||||
console.log(res);
|
||||
console.log("User account successfully deleted.");
|
||||
}
|
||||
)
|
||||
.catch((err) => {
|
||||
dispatch ({
|
||||
type: SET_ERRORS,
|
||||
payload: err.response.data,
|
||||
})
|
||||
});
|
||||
|
||||
localStorage.removeItem('FBIdToken');
|
||||
delete axios.defaults.headers.common['Authorization'];
|
||||
dispatch({ type: SET_UNAUTHENTICATED });
|
||||
}
|
||||
|
||||
const setAuthorizationHeader = (token) => {
|
||||
const FBIdToken = `Bearer ${token}`;
|
||||
localStorage.setItem('FBIdToken', FBIdToken);
|
||||
|
||||
Reference in New Issue
Block a user