Skip to content

Commit eb4db73

Browse files
author
Ilya Radchenko
committed
If no users, show setup.html page
1 parent 87a66a4 commit eb4db73

File tree

3 files changed

+129
-14
lines changed

3 files changed

+129
-14
lines changed

lib/models/user.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ var bcrypt = require('bcrypt');
66
var InviteCode = require('./invite');
77

88
var UserSchema = new Schema({
9-
email: { type: String, required: true, index: true },
9+
email: { type: String, required: true, index: true, unique: true },
1010
salt: { type: String, required: true },
1111
hash: { type: String, required: true },
1212
resetPasswordToken: String,

lib/routes/index.js

+19-13
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,6 @@ var TEST_AND_DEPLOY = 'TEST_AND_DEPLOY';
2323
/*
2424
* GET home page dashboard
2525
*/
26-
2726
exports.index = function(req, res){
2827
// Work-around for Safari/Express etags bug on cookie logout.
2928
// Without it, Safari will cache the logged-in version despite logout!
@@ -47,18 +46,25 @@ exports.index = function(req, res){
4746
});
4847
}
4948

50-
jobs.latestJobs(req.user, true, function (err, jobs) {
51-
var availableProviders = Object.keys(common.userConfigs.provider).map(function(k){
52-
return common.userConfigs.provider[k]
53-
})
54-
55-
res.render('index.html', {
56-
jobs: jobs,
57-
availableProviders: availableProviders,
58-
flash: req.flash(),
59-
version: pjson.version
60-
})
61-
})
49+
User.find(function (err, users) {
50+
if (!users || !users.length) {
51+
res.render('setup.html', {});
52+
}
53+
else {
54+
jobs.latestJobs(req.user, true, function (err, jobs) {
55+
var availableProviders = Object.keys(common.userConfigs.provider).map(function(k){
56+
return common.userConfigs.provider[k];
57+
});
58+
59+
res.render('index.html', {
60+
jobs: jobs,
61+
availableProviders: availableProviders,
62+
flash: req.flash(),
63+
version: pjson.version
64+
});
65+
});
66+
}
67+
});
6268
};
6369

6470
exports.setConfig = function (req, res) {

lib/views/setup.html

+109
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,109 @@
1+
{% extends "base.html" %}
2+
3+
{% block bodyContent %}
4+
<div class="row-fluid" ng-app="setup" ng-controller="Setup" class="ng-cloak">
5+
{% for messages in flash %}
6+
{% for message in messages %}
7+
<div class="alert alert-info">{{ message|raw }}</div>
8+
{% endfor %}
9+
{% endfor %}
10+
11+
<h3>Setup Strider</h3>
12+
13+
<div class="row-fluid">
14+
<div class="span6">
15+
<form class="strider-basics">
16+
<fieldset>
17+
<legend>Basics</legend>
18+
19+
<label for="basic-servername">Server Name</label>
20+
<input id="basic-servername" type="text" placeholder="Publically visible url" required=true>
21+
<span class="help-block">Publicaly accessible URL for this instance of Strider, e.g. ci.mydomain.com</span>
22+
</fieldset>
23+
</form>
24+
</div>
25+
26+
<div class="span6">
27+
<form class="strider-db">
28+
<fieldset>
29+
<legend>Database</legend>
30+
31+
<label>Host</label>
32+
<input type="text" placeholder="Type something…">
33+
<span class="help-block">Example block-level help text here.</span>
34+
35+
<label>Port</label>
36+
<input type="text" placeholder="Type something…">
37+
<span class="help-block">Example block-level help text here.</span>
38+
39+
<label>User</label>
40+
<input type="text" placeholder="Type something…">
41+
<span class="help-block">Example block-level help text here.</span>
42+
43+
<label>Password</label>
44+
<input type="text" placeholder="Type something…">
45+
<span class="help-block">Example block-level help text here.</span>
46+
</fieldset>
47+
</form>
48+
</div>
49+
</div>
50+
51+
<div class="row-fluid">
52+
<div class="span6">
53+
<form class="strider-db">
54+
<fieldset>
55+
<legend>Email</legend>
56+
57+
<label>Host</label>
58+
<input type="text" placeholder="Type something…">
59+
<span class="help-block">Example block-level help text here.</span>
60+
61+
<label>Port</label>
62+
<input type="text" placeholder="Type something…">
63+
<span class="help-block">Example block-level help text here.</span>
64+
65+
<label>User</label>
66+
<input type="text" placeholder="Type something…">
67+
<span class="help-block">Example block-level help text here.</span>
68+
69+
<label>Password</label>
70+
<input type="text" placeholder="Type something…">
71+
<span class="help-block">Example block-level help text here.</span>
72+
73+
<label>From Email Address</label>
74+
<input type="text" placeholder="Type something…">
75+
<span class="help-block">Example block-level help text here.</span>
76+
</fieldset>
77+
</form>
78+
</div>
79+
80+
<div class="span6">
81+
<form class="strider-admin">
82+
<fieldset>
83+
<legend>Admin User</legend>
84+
85+
<label>Email</label>
86+
<input type="text" placeholder="Type something…">
87+
<span class="help-block">Example block-level help text here.</span>
88+
89+
<label>Password</label>
90+
<input type="text" placeholder="Type something…">
91+
<span class="help-block">Example block-level help text here.</span>
92+
93+
<label>Password Confirm</label>
94+
<input type="text" placeholder="Type something…">
95+
<span class="help-block">Example block-level help text here.</span>
96+
</fieldset>
97+
</form>
98+
</div>
99+
</div>
100+
101+
<div class="row-fluid">
102+
<div class="span12">
103+
<div class="form-actions">
104+
<button type="submit" class="btn btn-primary">Save changes</button>
105+
</div>
106+
</div>
107+
</div>
108+
</div>
109+
{% endblock %}

0 commit comments

Comments
 (0)