Skip to content
This repository was archived by the owner on Feb 20, 2021. It is now read-only.

Commit 35408b4

Browse files
Dump of changes
1 parent d8b0554 commit 35408b4

File tree

15 files changed

+465
-114
lines changed

15 files changed

+465
-114
lines changed

.gitignore

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,4 +9,4 @@ dist/
99
# Temporary files
1010
oid_settings.json
1111
nginx.conf
12-
sample_data.sql
12+
sample_*.sql

Gruntfile.js

Lines changed: 49 additions & 46 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ module.exports = function (grunt) {
77
entry: __dirname + '/app/index.jsx',
88
output: {
99
filename: 'bundle.js',
10-
path: __dirname + '/dist/app/'
10+
path: __dirname + '/dist/app/',
1111
},
1212
resolve: {
1313
extensions: ['.js', '.jsx'],
@@ -25,15 +25,15 @@ module.exports = function (grunt) {
2525
presets: [
2626
['env', {
2727
targets: {
28-
browsers: ['last 2 versions']
28+
browsers: ['last 2 versions'],
2929
},
30-
modules: false
30+
modules: false,
3131
}],
32-
'react'
33-
]
34-
}
35-
}
36-
]
32+
'react',
33+
],
34+
},
35+
},
36+
],
3737
},
3838
{
3939
test: /\.css$/,
@@ -45,17 +45,17 @@ module.exports = function (grunt) {
4545
sourceMap: true,
4646
modules: true,
4747
importLoaders: 1,
48-
localIdentName: '[name]--[local]--[hash:base64:8]'
49-
}
48+
localIdentName: '[name]--[local]--[hash:base64:8]',
49+
},
5050
},
5151
{
52-
loader: 'postcss-loader'
53-
}
54-
]
55-
}
56-
]
57-
}
58-
}
52+
loader: 'postcss-loader',
53+
},
54+
],
55+
},
56+
],
57+
},
58+
},
5959
},
6060
copy: {
6161
app: {
@@ -64,45 +64,48 @@ module.exports = function (grunt) {
6464
expand: true,
6565
cwd: __dirname + '/app/',
6666
src: ['index.html'],
67-
dest: __dirname + '/dist/app/'
67+
dest: __dirname + '/dist/app/',
6868
},
6969
{
7070
expand: true,
7171
cwd: __dirname + '/app/',
7272
src: ['assets/**'],
73-
dest: __dirname + '/dist/app/assets/'
73+
dest: __dirname + '/dist/app/assets/',
7474
},
7575
{
7676
expand: true,
7777
cwd: __dirname + '/node_modules/oidc-client/',
7878
src: ['dist/**'],
79-
dest: __dirname + '/dist/app/assets/oidc-client/'
80-
}
81-
]
82-
}
79+
dest: __dirname + '/dist/app/assets/oidc-client/',
80+
},
81+
],
82+
},
8383
},
8484
babel: {
8585
options: {
8686
sourceMap: true,
8787
presets: [
88-
['env', {
89-
targets: {
90-
node: 'current'
88+
[
89+
'env',
90+
{
91+
targets: {
92+
node: 'current',
93+
},
94+
modules: 'commonjs',
9195
},
92-
modules: 'commonjs'
93-
}]
94-
]
96+
],
97+
],
9598
},
9699
server: {
97100
files: [
98101
{
99102
expand: true,
100103
cwd: __dirname + '/server/',
101104
src: ['**/*.js'],
102-
dest: __dirname + '/dist/server/'
103-
}
104-
]
105-
}
105+
dest: __dirname + '/dist/server/',
106+
},
107+
],
108+
},
106109
},
107110
eslint: {
108111
app: {
@@ -111,37 +114,37 @@ module.exports = function (grunt) {
111114
expand: true,
112115
cwd: __dirname + '/app/',
113116
src: ['**/*.js*'],
114-
dest: __dirname + '/dist/app/'
115-
}
116-
]
117+
dest: __dirname + '/dist/app/',
118+
},
119+
],
117120
},
118121
server: {
119122
files: [
120123
{
121124
expand: true,
122125
cwd: __dirname + '/server/',
123126
src: ['**/*.js'],
124-
dest: __dirname + '/dist/server/'
125-
}
126-
]
127-
}
127+
dest: __dirname + '/dist/server/',
128+
},
129+
],
130+
},
128131
},
129132
watch: {
130133
app: {
131134
files: '**/*.js*',
132135
tasks: ['app'],
133136
options: {
134-
cwd: __dirname + '/app/'
135-
}
137+
cwd: __dirname + '/app/',
138+
},
136139
},
137140
server: {
138141
files: '**/*.js',
139142
tasks: ['server'],
140143
options: {
141-
cwd: __dirname + '/server/'
142-
}
143-
}
144-
}
144+
cwd: __dirname + '/server/',
145+
},
146+
},
147+
},
145148
});
146149

147150
grunt.loadNpmTasks('grunt-webpack');

README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,4 +31,5 @@ A school event planner and timetable
3131
## Security Pitfalls
3232

3333
- Auth mechanism not verified
34+
- Verification of OID tokens is done by upn being the email address
3435
- Succeptable to insecure direct object references

app/components/addeventdialog.jsx

Lines changed: 127 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,127 @@
1+
import React from 'react';
2+
3+
import { Dialog, Input, Dropdown, DatePicker, TimePicker } from 'react-toolbox';
4+
5+
export default class AddEventDialog extends React.Component {
6+
constructor(props) {
7+
super(props);
8+
const now = new Date();
9+
this.state = {
10+
group: null,
11+
name: '',
12+
start: new Date(now.getFullYear(), now.getMonth(), now.getDate() + 1, 8),
13+
end: new Date(now.getFullYear(), now.getMonth(), now.getDate() + 1, 10),
14+
groups: [
15+
{ value: 1, label: 'M17502' },
16+
{ value: 2, label: 'Infocomm Club' },
17+
{ value: 3, label: 'Youth Flying Club', disabled: true },
18+
{ value: 4, label: 'Engineering Intrest Group' },
19+
],
20+
};
21+
22+
this.handleGroupChange = this.handleGroupChange.bind(this);
23+
this.handleNameChange = this.handleNameChange.bind(this);
24+
this.handleStartChange = this.handleStartChange.bind(this);
25+
this.handleEndChange = this.handleEndChange.bind(this);
26+
27+
this.actions = [
28+
{ label: 'Cancel', onClick: this.props.onCancel, accent: true },
29+
{ label: 'Add', onClick: this.addEvent, accent: true },
30+
];
31+
32+
// pull user groups, together with the relationship attribute role
33+
// put user groups into state.groups, disabling those not admin
34+
}
35+
36+
handleGroupChange(value) {
37+
this.setState({
38+
group: value,
39+
});
40+
}
41+
42+
handleNameChange(value) {
43+
this.setState({
44+
name: value,
45+
});
46+
}
47+
48+
handleStartChange(value) {
49+
this.setState(prev => ({
50+
start: value,
51+
end: new Date(
52+
value.getFullYear(),
53+
value.getMonth(),
54+
value.getDate(),
55+
prev.end.getHours(),
56+
prev.end.getMinutes(),
57+
),
58+
}));
59+
}
60+
handleEndChange(value) {
61+
this.setState({
62+
end: value,
63+
});
64+
}
65+
66+
render() {
67+
return (
68+
<Dialog
69+
{...this.props}
70+
actions={this.actions}
71+
title="Create a one-time event"
72+
>
73+
<Dropdown
74+
auto
75+
label="Group"
76+
source={this.state.groups}
77+
value={this.state.group}
78+
required
79+
onChange={this.handleGroupChange}
80+
/>
81+
<Input
82+
type="text"
83+
label="Name"
84+
value={this.state.name}
85+
required
86+
onChange={this.handleNameChange}
87+
/>
88+
<DatePicker
89+
label="Start Date"
90+
minDate={new Date()}
91+
value={this.state.start}
92+
required
93+
onChange={this.handleStartChange}
94+
/>
95+
<TimePicker
96+
label="Start Time"
97+
value={this.state.start}
98+
required
99+
onChange={this.handleStartChange}
100+
/>
101+
<DatePicker
102+
label="End Date"
103+
minDate={
104+
new Date(
105+
this.state.start.getFullYear(),
106+
this.state.start.getMonth(),
107+
this.state.start.getDate(),
108+
)
109+
}
110+
value={this.state.end}
111+
required
112+
onChange={this.handleEndChange}
113+
/>
114+
<TimePicker
115+
label="End Time"
116+
value={this.state.end}
117+
required
118+
onChange={this.handleEndChange}
119+
/>
120+
</Dialog>
121+
);
122+
}
123+
}
124+
125+
AddEventDialog.propTypes = {
126+
onCancel: React.PropTypes.func.isRequired,
127+
};

app/components/app.jsx

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
import React from 'react';
2+
import { BrowserRouter as Router, Route } from 'react-router-dom';
3+
4+
import LayoutMain from '../layouts/main';
5+
import PageHome from '../pages/home';
6+
import PageLogin from '../pages/login';
7+
import PageLoginSchool from '../pages/login_school';
8+
9+
export default class App extends React.Component {
10+
getChildContext() {
11+
return {
12+
user: {},
13+
token: null,
14+
};
15+
}
16+
17+
render() {
18+
return (
19+
<Router>
20+
<LayoutMain>
21+
<Route exact path="/" component={PageHome} />
22+
<Route path="/login" component={PageLogin} />
23+
<Route path="/login/:id" component={PageLoginSchool} />
24+
</LayoutMain>
25+
</Router>
26+
);
27+
}
28+
}
29+
30+
App.childContextTypes = {
31+
// eslint-disable-next-line react/forbid-prop-types
32+
user: React.PropTypes.object.isRequired,
33+
token: React.PropTypes.string,
34+
};

app/index.html

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
<head>
22
<meta charset="UTF-8" />
33
<title>Chronos</title>
4+
<meta name="viewport" content="width=device-width" />
45
<link href="//fonts.googleapis.com/icon?family=Material+Icons" rel="stylesheet" />
56
<link href="//fonts.googleapis.com/css?family=Roboto:300,400,500,700" rel="stylesheet" />
67
<style>*, *:before, *:after { box-sizing: border-box; } html, body { margin: 0; padding: 0; }</style>

app/index.jsx

Lines changed: 2 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -2,23 +2,10 @@ import 'babel-polyfill';
22

33
import React from 'react';
44
import ReactDOM from 'react-dom';
5-
import { BrowserRouter as Router, Route } from 'react-router-dom';
65

7-
// eslint-disable-next-line no-unused-vars
8-
import * as oidc from 'oidc-client';
9-
10-
import LayoutMain from './layouts/main';
11-
import PageHome from './pages/home';
12-
import PageLogin from './pages/login';
13-
import PageLoginSchool from './pages/login_school';
6+
import App from './components/app';
147

158
ReactDOM.render(
16-
<Router>
17-
<LayoutMain>
18-
<Route exact path="/" component={PageHome} />
19-
<Route path="/login" component={PageLogin} />
20-
<Route path="/login/:id" component={PageLoginSchool} />
21-
</LayoutMain>
22-
</Router>,
9+
<App />,
2310
document.getElementById('root'),
2411
);

0 commit comments

Comments
 (0)