mirror of
https://github.com/ClaytonWWilson/CS307-Team24.git
synced 2025-12-16 10:18:48 +00:00
Logout is working now : )
This commit is contained in:
parent
bb6c7a07fc
commit
d1233e77ed
@ -1,6 +1,7 @@
|
|||||||
/* eslint-disable */
|
/* eslint-disable */
|
||||||
import React, { Component } from "react";
|
import React, { Component } from "react";
|
||||||
import "./App.css";
|
import "./App.css";
|
||||||
|
import axios from "axios";
|
||||||
|
|
||||||
import { BrowserRouter as Router, Route, Switch } from "react-router-dom";
|
import { BrowserRouter as Router, Route, Switch } from "react-router-dom";
|
||||||
import Navbar from "./components/layout/NavBar";
|
import Navbar from "./components/layout/NavBar";
|
||||||
@ -26,7 +27,7 @@ import user from './pages/user';
|
|||||||
import writeMicroblog from "./Writing_Microblogs.js";
|
import writeMicroblog from "./Writing_Microblogs.js";
|
||||||
import edit from "./pages/edit.js";
|
import edit from "./pages/edit.js";
|
||||||
import userLine from "./Userline.js";
|
import userLine from "./Userline.js";
|
||||||
import axios from "axios";
|
import logout from './pages/Logout';
|
||||||
|
|
||||||
const theme = createMuiTheme(themeObject);
|
const theme = createMuiTheme(themeObject);
|
||||||
|
|
||||||
@ -59,6 +60,7 @@ class App extends Component {
|
|||||||
{/* AuthRoute checks if the user is logged in and if they are it redirects them to /home */}
|
{/* AuthRoute checks if the user is logged in and if they are it redirects them to /home */}
|
||||||
<AuthRoute exact path="/signup" component={signup} />
|
<AuthRoute exact path="/signup" component={signup} />
|
||||||
<AuthRoute exact path="/login" component={login} />
|
<AuthRoute exact path="/login" component={login} />
|
||||||
|
<Route exact path="/logout" component={logout} />
|
||||||
|
|
||||||
<Route exact path="/user" component={user} />
|
<Route exact path="/user" component={user} />
|
||||||
<Route exact path="/home" component={writeMicroblog} />
|
<Route exact path="/home" component={writeMicroblog} />
|
||||||
|
|||||||
@ -1,22 +0,0 @@
|
|||||||
/* eslint-disable */
|
|
||||||
import React, { Component} from 'react';
|
|
||||||
import './App.css';
|
|
||||||
import logo from './images/twistter-logo.png';
|
|
||||||
import TextField from '@material-ui/core/TextField';
|
|
||||||
|
|
||||||
class Logout extends Component {
|
|
||||||
render() {
|
|
||||||
return(
|
|
||||||
<div>
|
|
||||||
<img src={logo} className="app-logo" alt="logo" />
|
|
||||||
<br/><br/>
|
|
||||||
<b>Logout of your Twistter Account</b>
|
|
||||||
<br/><br/>
|
|
||||||
<br/><br/>
|
|
||||||
<button className="authButtons signup" type="submit">Sign Out</button>
|
|
||||||
</div>
|
|
||||||
);
|
|
||||||
};
|
|
||||||
}
|
|
||||||
|
|
||||||
export default Logout;
|
|
||||||
@ -1,12 +1,43 @@
|
|||||||
/* eslint-disable */
|
/* eslint-disable */
|
||||||
import React, { Component } from 'react';
|
import React, { Component } from 'react';
|
||||||
import { Link } from 'react-router-dom';
|
import { Link } from 'react-router-dom';
|
||||||
|
// import PropTypes from 'prop-types';
|
||||||
|
|
||||||
|
// Material UI stuff
|
||||||
import AppBar from '@material-ui/core/AppBar';
|
import AppBar from '@material-ui/core/AppBar';
|
||||||
import ToolBar from '@material-ui/core/Toolbar';
|
import ToolBar from '@material-ui/core/Toolbar';
|
||||||
import Button from '@material-ui/core/Button';
|
import Button from '@material-ui/core/Button';
|
||||||
|
import withStyles from "@material-ui/core/styles/withStyles";
|
||||||
|
|
||||||
export class Navbar extends Component {
|
// Redux stuff
|
||||||
render() {
|
// 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 Navbar extends Component {
|
||||||
|
render() {
|
||||||
return (
|
return (
|
||||||
<AppBar>
|
<AppBar>
|
||||||
<ToolBar>
|
<ToolBar>
|
||||||
@ -28,4 +59,18 @@ export class Navbar extends Component {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// const mapStateToProps = (state) => ({
|
||||||
|
// user: state.user
|
||||||
|
// })
|
||||||
|
|
||||||
|
// const mapActionsToProps = { logoutUser };
|
||||||
|
|
||||||
|
// Navbar.propTypes = {
|
||||||
|
// logoutUser: PropTypes.func.isRequired,
|
||||||
|
// user: PropTypes.object.isRequired,
|
||||||
|
// classes: PropTypes.object.isRequired
|
||||||
|
// }
|
||||||
|
|
||||||
|
// export default connect(mapStateToProps, mapActionsToProps)(withStyles(styles)(Navbar));
|
||||||
|
|
||||||
export default Navbar;
|
export default Navbar;
|
||||||
|
|||||||
@ -1,6 +1,6 @@
|
|||||||
/* eslint-disable */
|
/* eslint-disable */
|
||||||
import React, { Component } from 'react';
|
import React, { Component } from 'react';
|
||||||
import '../App.css';
|
// import '../App.css';
|
||||||
import PropTypes from 'prop-types';
|
import PropTypes from 'prop-types';
|
||||||
|
|
||||||
import logo from '../images/twistter-logo.png';
|
import logo from '../images/twistter-logo.png';
|
||||||
@ -173,6 +173,7 @@ const mapStateToProps = (state) => ({
|
|||||||
const mapActionsToProps = {
|
const mapActionsToProps = {
|
||||||
loginUser
|
loginUser
|
||||||
}
|
}
|
||||||
|
|
||||||
Login.propTypes = {
|
Login.propTypes = {
|
||||||
classes: PropTypes.object.isRequired
|
classes: PropTypes.object.isRequired
|
||||||
};
|
};
|
||||||
|
|||||||
56
twistter-frontend/src/pages/Logout.js
Normal file
56
twistter-frontend/src/pages/Logout.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 Logout extends Component {
|
||||||
|
|
||||||
|
componentDidMount() {
|
||||||
|
this.props.logoutUser();
|
||||||
|
this.props.history.push('/');
|
||||||
|
}
|
||||||
|
|
||||||
|
render() {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
const mapStateToProps = (state) => ({
|
||||||
|
user: state.user
|
||||||
|
});
|
||||||
|
|
||||||
|
const mapActionsToProps = { logoutUser };
|
||||||
|
|
||||||
|
Logout.propTypes = {
|
||||||
|
logoutUser: PropTypes.func.isRequired,
|
||||||
|
user: PropTypes.object.isRequired,
|
||||||
|
classes: PropTypes.object.isRequired
|
||||||
|
};
|
||||||
|
|
||||||
|
export default connect(mapStateToProps, mapActionsToProps)(withStyles(styles)(Logout));
|
||||||
@ -1,6 +1,6 @@
|
|||||||
/* eslint-disable */
|
/* eslint-disable */
|
||||||
import React, { Component } from 'react';
|
import React, { Component } from 'react';
|
||||||
import '../App.css';
|
// import '../App.css';
|
||||||
import PropTypes from 'prop-types';
|
import PropTypes from 'prop-types';
|
||||||
|
|
||||||
import logo from '../images/twistter-logo.png';
|
import logo from '../images/twistter-logo.png';
|
||||||
@ -42,8 +42,10 @@ export class Signup extends Component {
|
|||||||
constructor() {
|
constructor() {
|
||||||
super();
|
super();
|
||||||
this.state = {
|
this.state = {
|
||||||
|
handle: "",
|
||||||
email: "",
|
email: "",
|
||||||
password:"",
|
password:"",
|
||||||
|
confirmPassword: "",
|
||||||
errors: {}
|
errors: {}
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
@ -60,8 +62,10 @@ export class Signup extends Component {
|
|||||||
handleSubmit = (event) => {
|
handleSubmit = (event) => {
|
||||||
event.preventDefault();
|
event.preventDefault();
|
||||||
const signupData = {
|
const signupData = {
|
||||||
|
handle: this.state.handle,
|
||||||
email: this.state.email,
|
email: this.state.email,
|
||||||
password: this.state.password,
|
password: this.state.password,
|
||||||
|
confirmPassword: this.state.confirmPassword
|
||||||
};
|
};
|
||||||
this.props.signupUser(signupData, this.props.history);
|
this.props.signupUser(signupData, this.props.history);
|
||||||
};
|
};
|
||||||
@ -88,7 +92,7 @@ export class Signup extends Component {
|
|||||||
<Grid item sm>
|
<Grid item sm>
|
||||||
<img src={logo} className="app-logo" alt="logo" />
|
<img src={logo} className="app-logo" alt="logo" />
|
||||||
<Typography variant="h2" className={classes.pageTitle}>
|
<Typography variant="h2" className={classes.pageTitle}>
|
||||||
Log in to Twistter
|
Create a new account
|
||||||
</Typography>
|
</Typography>
|
||||||
<form noValidate onSubmit={this.handleSubmit}>
|
<form noValidate onSubmit={this.handleSubmit}>
|
||||||
<TextField
|
<TextField
|
||||||
@ -156,6 +160,7 @@ const mapStateToProps = (state) => ({
|
|||||||
const mapActionsToProps = {
|
const mapActionsToProps = {
|
||||||
signupUser
|
signupUser
|
||||||
}
|
}
|
||||||
|
|
||||||
Signup.propTypes = {
|
Signup.propTypes = {
|
||||||
classes: PropTypes.object.isRequired
|
classes: PropTypes.object.isRequired
|
||||||
};
|
};
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user