Skip to content

Commit

Permalink
changed user check in injury list to the user id, not username
Browse files Browse the repository at this point in the history
  • Loading branch information
b-bly committed May 9, 2018
1 parent a832072 commit 01c28e0
Show file tree
Hide file tree
Showing 7 changed files with 12 additions and 4 deletions.
1 change: 1 addition & 0 deletions server/routes/user.js
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@ router.post(
(req, res) => {
console.log('logged in', req.user);
var userInfo = {
_id: req.user._id,
username: req.user.username
};
res.send(userInfo);
Expand Down
2 changes: 1 addition & 1 deletion src/App.js
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ class App extends Component {
/>}
/> */}
<Route
path="/"
exact path="/"
component={InjuryList} />
<Route
path="/login"
Expand Down
1 change: 1 addition & 0 deletions src/actions/get-user.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ export default function getUser() {
console.log(res.data);
const user = {
username: res.data.user.username,
id: res.data.user._id,
loggedIn: true
};
if (!res.data.user.username) user.loggedIn = false;
Expand Down
1 change: 1 addition & 0 deletions src/actions/login.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ export default function login(userInfo) {
console.log(res.data);
const user = {
username: res.data.username,
id: res.data._id,
loggedIn: true
}
dispatch(loginAsync(user));
Expand Down
4 changes: 4 additions & 0 deletions src/index.css
Original file line number Diff line number Diff line change
Expand Up @@ -137,4 +137,8 @@ body {
flex-direction: column;
justify-content: center;
}
}

.pointer {
cursor: pointer;
}
3 changes: 2 additions & 1 deletion src/scenes/injury-list/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -106,7 +106,8 @@ class InjuryList extends Component {
delete={this.delete}
showForm={this.showForm.bind(this)}
injury={injury}
username={this.props.user.username} />
username={this.props.user.username}
userId={this.props.user.id}/>

)}

Expand Down
4 changes: 2 additions & 2 deletions src/scenes/injury-list/injury-list-item.js
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ export default class InjuryListItem extends Component {
<div className="col-4 col-mx-auto">
<div className="card">
<div className="columns card-bdy">
<div className=" col-12 card-title-line"
<div className="col-12 card-title-line pointer"
onClick={this.handleClick.bind(this)}
>
{this.props.injury.title}
Expand All @@ -47,7 +47,7 @@ export default class InjuryListItem extends Component {
{ this.props.injury.author ?(
<div>
{
this.props.username === this.props.injury.author.username &&
this.props.userId === this.props.injury.author.id &&
(
<div>
<a className="list-links card-line"
Expand Down

0 comments on commit 01c28e0

Please sign in to comment.