Skip to content
This repository was archived by the owner on Jul 12, 2019. It is now read-only.

Commit ff258f3

Browse files
lipovaceigenfoo
authored andcommitted
More cookies (#67)
* Fixed issues with cookies being passed between components * Fixed company authentication creation bug. Made cookies work for loading company specific dashboard
1 parent a7c3c54 commit ff258f3

File tree

5 files changed

+26
-21
lines changed

5 files changed

+26
-21
lines changed

euphoria-frontend/src/App.js

+7-7
Original file line numberDiff line numberDiff line change
@@ -26,14 +26,14 @@ class App extends Component {
2626
<div>
2727
<Switch>
2828
<Route exact path="/" component={Splash} />
29-
<Route path="/signin" render={(props) => (<Signin {...props} />)} />
29+
<Route path="/signin" render={(props) => (<Signin cookies={this.props.cookies} {...props} />)} />
3030
<Route path="/signup" component={Signup} />
31-
<Route exact path="/postings" render={(props) => (<Postings {...props} />)} />
32-
<Route path="/postings/apply/:postingId" render={(props) => (<Apply {...props} />)} />
33-
<Route exact path="/dashboard" render={(props) => (<Dashboard {...props} />)} />
34-
<Route exact path="/dashboard/post" render={(props) => (<Post {...props} />)} />
35-
<Route path="/dashboard/post/edit/:postingId" render={(props) => (<Editpost {...props} />)} />
36-
<Route path="/dashboard/applications/:postingId" render={(props) => (<Applications {...props} />)} />
31+
<Route exact path="/postings" render={(props) => (<Postings cookies={this.props.cookies} {...props} />)} />
32+
<Route path="/postings/apply/:postingId" render={(props) => (<Apply cookies={this.props.cookies} {...props} />)} />
33+
<Route exact path="/dashboard" render={(props) => (<Dashboard cookies={this.props.cookies} {...props} />)} />
34+
<Route exact path="/dashboard/post" render={(props) => (<Post cookies={this.props.cookies} {...props} />)} />
35+
<Route path="/dashboard/post/edit/:postingId" render={(props) => (<Editpost cookies={this.props.cookies} {...props} />)} />
36+
<Route path="/dashboard/applications/:postingId" render={(props) => (<Applications cookies={this.props.cookies} {...props} />)} />
3737
<Route path="/404" component={NotFound} />
3838
<Redirect to="/404" />
3939
</Switch>

euphoria-frontend/src/views/Apply.jsx

+2-2
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ class Apply extends Component {
1616

1717
componentDidMount() {
1818
let url = "http://localhost:8080/api/posting/" + this.props.match.params.postingId;
19-
console.log(this.props);
19+
2020
this.handleGet(url);
2121
}
2222

@@ -110,7 +110,7 @@ class Apply extends Component {
110110
<Image
111111
src={require('../images/Logo.png')}
112112
fluid
113-
onClick={() => this.handleRedirect("/posting")}
113+
onClick={() => this.handleRedirect("/postings")}
114114
/>
115115
</div>
116116
</div>

euphoria-frontend/src/views/Dashboard.jsx

+1-1
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ class Dashboard extends Component {
55
constructor(props, context) {
66
super(props);
77

8-
this.dashboardUrl = "http://localhost:8080/api/posting/company/" + this.props.cookies.get("id");
8+
this.dashboardUrl = "http://localhost:8080/api/posting/company/" + this.props.cookies.get("id")
99

1010
this.state = {
1111
companyPostingsData: [],

euphoria-frontend/src/views/Signin.jsx

+7-7
Original file line numberDiff line numberDiff line change
@@ -63,15 +63,15 @@ class Signin extends Component {
6363
.then(data => {
6464
const cookie = data[0];
6565

66-
if(cookie != null){
67-
const cookies = this.props.cookies;
66+
if(!(cookie == null)){
67+
const cookiesProp = this.props.cookies;
6868

69-
cookies.set("username", username, { path: '/' });
70-
cookies.set("id", cookies.id, { path: '/' });
71-
cookies.set("isUser", cookies.isUser, { path: '/' });
72-
cookies.set("authenticationHash", cookie.cookie, { path: '/' });
69+
cookiesProp.set("username", username, { path: '/' });
70+
cookiesProp.set("id", cookie.id, { path: '/' });
71+
cookiesProp.set("isUser", cookie.isUser, { path: '/' });
72+
cookiesProp.set("authenticationHash", cookie.cookie, { path: '/' });
7373

74-
if(cookies.isUser){
74+
if(cookie.isUser){
7575
this.handleRedirect("/postings")
7676
}
7777
else{

euphoria-frontend/src/views/Signup.jsx

+9-4
Original file line numberDiff line numberDiff line change
@@ -94,21 +94,24 @@ class Signup extends Component {
9494
website,
9595
description
9696
};
97+
console.log(userPayload)
9798
}
9899

99100
fetch(userUrl, {
100101
method: "POST",
101102
body: JSON.stringify(userPayload)
102103
}) //FIXME add check for is user exists
103104
.then(response => response.json())
104-
.then(data => this.createUserAuthentication(data[0].userId))
105+
.then(data => {
106+
this.createUserAuthentication((isUser) ? data[0].userId : data[0].companyId)
107+
})
105108
.catch(err => {
106109
})
107110

108111
return;
109112
}
110113

111-
createUserAuthentication(userId) {
114+
createUserAuthentication(id) {
112115
const {
113116
isUser,
114117
username,
@@ -118,12 +121,14 @@ class Signup extends Component {
118121
const authenticationUrl = "http://localhost:8080/api/authentication";
119122

120123
let authenticationPayload = {
121-
id: userId,
124+
id: id,
122125
username: username,
123126
passwordHash: password,
124127
isUser: isUser
125128
};
126129

130+
console.log(authenticationPayload);
131+
127132
fetch(authenticationUrl, {
128133
method: "POST",
129134
body: JSON.stringify(authenticationPayload)
@@ -234,7 +239,7 @@ class Signup extends Component {
234239
</Form.Group>
235240

236241
<Form.Group controlId="formGridWebsite">
237-
<Form.Label>Email</Form.Label>
242+
<Form.Label>Website</Form.Label>
238243
<Form.Control
239244
required
240245
type="website"

0 commit comments

Comments
 (0)