mirror of
https://github.com/TryGhost/Ghost-Admin.git
synced 2023-12-14 02:33:04 +01:00
Prevent loading setup screen if already setup
Closes #3145 - Prevent navigation to the setup screen if Ghost setup has previously been completed. - Fix templates that were incorrectly using foreach instead of each. - Add validation for minimum password length. - Fix up functional tests and split out tests for setup to a separate instance of casper because setup requires a new database. - Add a cleanDatabase task to grunt which resets the database to new.
This commit is contained in:
parent
f4d60c2bde
commit
db2abf188c
4 changed files with 28 additions and 9 deletions
|
@ -3,10 +3,29 @@ import loadingIndicator from 'ghost/mixins/loading-indicator';
|
||||||
|
|
||||||
var SetupRoute = Ember.Route.extend(styleBody, loadingIndicator, {
|
var SetupRoute = Ember.Route.extend(styleBody, loadingIndicator, {
|
||||||
classNames: ['ghost-setup'],
|
classNames: ['ghost-setup'],
|
||||||
|
|
||||||
|
// use the beforeModel hook to check to see whether or not setup has been
|
||||||
|
// previously completed. If it has, stop the transition into the setup page.
|
||||||
|
|
||||||
beforeModel: function () {
|
beforeModel: function () {
|
||||||
|
var self = this;
|
||||||
|
|
||||||
|
// If user is logged in, setup has already been completed.
|
||||||
if (this.get('session').isAuthenticated) {
|
if (this.get('session').isAuthenticated) {
|
||||||
this.transitionTo(Ember.SimpleAuth.routeAfterAuthentication);
|
this.transitionTo(Ember.SimpleAuth.routeAfterAuthentication);
|
||||||
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// If user is not logged in, check the state of the setup process via the API
|
||||||
|
return ic.ajax.request(this.get('ghostPaths.url').api('authentication/setup'), {
|
||||||
|
type: 'GET'
|
||||||
|
}).then(function (result) {
|
||||||
|
var setup = result.setup[0].status;
|
||||||
|
|
||||||
|
if (setup) {
|
||||||
|
return self.transitionTo('signin');
|
||||||
|
}
|
||||||
|
});
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
|
@ -16,13 +16,13 @@
|
||||||
<h3>Stack Trace</h3>
|
<h3>Stack Trace</h3>
|
||||||
<p><strong>{{message}}</strong></p>
|
<p><strong>{{message}}</strong></p>
|
||||||
<ul class="error-stack-list">
|
<ul class="error-stack-list">
|
||||||
{{#foreach stack}}
|
{{#each stack}}
|
||||||
<li>
|
<li>
|
||||||
at
|
at
|
||||||
{{#if function}}<em class="error-stack-function">{{function}}</em>{{/if}}
|
{{#if function}}<em class="error-stack-function">{{function}}</em>{{/if}}
|
||||||
<span class="error-stack-file">({{at}})</span>
|
<span class="error-stack-file">({{at}})</span>
|
||||||
</li>
|
</li>
|
||||||
{{/foreach}}
|
{{/each}}
|
||||||
</ul>
|
</ul>
|
||||||
</section>
|
</section>
|
||||||
{{/if}}
|
{{/if}}
|
||||||
|
|
|
@ -3,13 +3,13 @@ var SetupValidator = Ember.Object.create({
|
||||||
var data = model.getProperties('blogTitle', 'name', 'email', 'password'),
|
var data = model.getProperties('blogTitle', 'name', 'email', 'password'),
|
||||||
validationErrors = [];
|
validationErrors = [];
|
||||||
|
|
||||||
if (!validator.isLength(data.blogTitle || '', 1)) {
|
if (!validator.isLength(data.blogTitle, 1)) {
|
||||||
validationErrors.push({
|
validationErrors.push({
|
||||||
message: 'Please enter a blog title.'
|
message: 'Please enter a blog title.'
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!validator.isLength(data.name || '', 1)) {
|
if (!validator.isLength(data.name, 1)) {
|
||||||
validationErrors.push({
|
validationErrors.push({
|
||||||
message: 'Please enter a name.'
|
message: 'Please enter a name.'
|
||||||
});
|
});
|
||||||
|
@ -21,9 +21,9 @@ var SetupValidator = Ember.Object.create({
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!validator.isLength(data.password || '', 1)) {
|
if (!validator.isLength(data.password, 8)) {
|
||||||
validationErrors.push({
|
validationErrors.push({
|
||||||
message: 'Please enter a password.'
|
message: 'Password must be at least 8 characters long.'
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -3,7 +3,7 @@ var SignupValidator = Ember.Object.create({
|
||||||
var data = model.getProperties('name', 'email', 'password'),
|
var data = model.getProperties('name', 'email', 'password'),
|
||||||
validationErrors = [];
|
validationErrors = [];
|
||||||
|
|
||||||
if (!validator.isLength(data.name || '', 1)) {
|
if (!validator.isLength(data.name, 1)) {
|
||||||
validationErrors.push({
|
validationErrors.push({
|
||||||
message: 'Please enter a name.'
|
message: 'Please enter a name.'
|
||||||
});
|
});
|
||||||
|
@ -15,9 +15,9 @@ var SignupValidator = Ember.Object.create({
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!validator.isLength(data.password || '', 1)) {
|
if (!validator.isLength(data.password, 8)) {
|
||||||
validationErrors.push({
|
validationErrors.push({
|
||||||
message: 'Please enter a password.'
|
message: 'Password must be at least 8 characters long.'
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue