Skip to content
This repository was archived by the owner on Apr 13, 2023. It is now read-only.

Commit fa7787e

Browse files
author
Matt Karl
committed
Added validation to registration form, updated library, added query string to embed
1 parent 615abda commit fa7787e

File tree

7 files changed

+75
-10
lines changed

7 files changed

+75
-10
lines changed

app/public/js/embed.js

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

app/public/js/libraries.js

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

app/routes/register.js

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,21 @@ router.get('/', function(req, res)
1111

1212
router.post('/', function(req, res, next)
1313
{
14+
// Do some basic validation
15+
req.checkBody('name', 'Name is required').notEmpty();
16+
req.checkBody('username', 'Username must only be alpha characters').isAlpha();
17+
req.checkBody('email', 'Email must be a valid email address').isEmail();
18+
19+
var errors = req.validationErrors();
20+
21+
if (errors)
22+
{
23+
return res.render('register',
24+
{
25+
errors: errors
26+
});
27+
}
28+
1429
// Make sure that someone can override
1530
// the user default privilege, would be
1631
// ugly to expose edit of this to anonymous

bower.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "SpringRollConnect",
3-
"version": "1.3.2",
3+
"version": "1.3.3",
44
"dependencies": {
55
"jquery": "*",
66
"bootstrap": "*",

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
{
2-
"version": "1.3.2",
2+
"version": "1.3.3",
33
"private": true,
44
"devDependencies": {
55
"grunt": "^0.4.5",

project.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "SpringRollConnect",
3-
"version": "1.3.2",
3+
"version": "1.3.3",
44
"main": [
55
"src/plugins/jquery-search.js",
66
"src/widgets/*.js",

src/embed.js

Lines changed: 55 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -105,7 +105,10 @@
105105

106106
// Open via api
107107
var api = location.pathname.replace('/embed/', '/api/release/');
108-
108+
var query;
109+
var playOptions = null;
110+
var singlePlay = false;
111+
109112
if (location.search)
110113
{
111114
var params = parseQuery(location.search.substr(1));
@@ -115,25 +118,72 @@
115118
['version', 'status', 'commitId', 'token'].forEach(function(param)
116119
{
117120
if (params[param])
121+
{
118122
apiArgs.push(param + "=" + params[param]);
123+
delete params[param];
124+
}
119125
});
120126

121127
// Check for debug
122-
if (params.debug) apiArgs.push("debug=true");
128+
if (params.debug)
129+
{
130+
apiArgs.push("debug=true");
131+
delete params.debug;
132+
}
123133

124134
// Show the controls
125-
if (params.controls) this.frame.addClass('show-controls');
135+
if (params.controls)
136+
{
137+
this.frame.addClass('show-controls');
138+
delete params.controls;
139+
}
126140

127141
// Show the title
128-
if (params.title) this.frame.addClass('show-title');
142+
if (params.title)
143+
{
144+
this.frame.addClass('show-title');
145+
delete params.title;
146+
}
129147

130148
// Add the arguments
131149
if (apiArgs.length)
132150
{
133151
api += "?" + apiArgs.join("&");
134152
}
153+
154+
// Single play
155+
if (params.singlePlay)
156+
{
157+
singlePlay = params.singlePlay == "true" || params.singlePlay == "1";
158+
delete params.singlePlay;
159+
}
160+
161+
// Play options
162+
if (params.playOptions)
163+
{
164+
try
165+
{
166+
playOptions = JSON.parse(params.playOptions);
167+
}
168+
catch(e){} // ignore invalid JSON parse
169+
delete params.playOptions;
170+
}
171+
172+
// Get any other options and pass them to the query string
173+
query = [];
174+
for(var param in params)
175+
{
176+
query.push(param + "=" + params[param]);
177+
}
178+
query = query.length ? "?" + query.join("&") : '';
135179
}
136-
this.openRemote(api);
180+
181+
this.openRemote(api,
182+
{
183+
singlePlay: singlePlay,
184+
playOptions: playOptions,
185+
query: query
186+
});
137187
};
138188

139189
function parseQuery(queryString)

0 commit comments

Comments
 (0)