Fixing bug in registration

Switching over to abstracted data provider meant that email_address
accidentally got passed to the model as email and therefore could not
be found. This is now resolved.
Also, added trailing slash to register route, which I believe should be there
This commit is contained in:
ErisDS 2013-05-26 12:38:14 +00:00
parent c605c90d71
commit 37d86e07bb
3 changed files with 9 additions and 7 deletions

2
app.js Normal file → Executable file
View File

@ -91,7 +91,7 @@
ghost.app().get('/ghost/login/', admin.login);
ghost.app().get('/ghost/register/', admin.register);
ghost.app().post('/ghost/login/', admin.auth);
ghost.app().post('/ghost/register', admin.doRegister);
ghost.app().post('/ghost/register/', admin.doRegister);
ghost.app().get('/ghost/editor/:id', auth, admin.editor);
ghost.app().get('/ghost/editor', auth, admin.editor);
ghost.app().get('/ghost/blog', auth, admin.blog);

12
core/admin/controllers/index.js Normal file → Executable file
View File

@ -80,17 +80,19 @@
});
},
'doRegister': function (req, res) {
// console.log(req.body);
if (req.body.email !== '' && req.body.password.length > 5) {
// console.log(req.body);
if (req.body.email_address !== '' && req.body.password.length > 5) {
// console.log('okay, this is happening');
api.users.add({email: req.body.email, password: req.body.password}).then(function (user) {
api.users.add({email_address: req.body.email_address, password: req.body.password}).then(function (user) {
console.log('user added', user);
res.redirect('/ghost/login/');
},
function(error) {
console.log('there was an error', error);
});
} else {
req.flash('error', "The password is too short. Have at least 6 characters in there");
res.redirect('/ghost/register/');
res.redirect('back');
}
},
'logout': function (req, res) {

2
core/admin/views/register.hbs Normal file → Executable file
View File

@ -2,7 +2,7 @@
<img class="login-logo" src="/core/admin/assets/img/logo.png" alt="" />
<form id="register" method="post">
<div class="email-wrap">
<input class="email" type="text" placeholder="Email Address" name="email">
<input class="email_address" type="text" placeholder="Email Address" name="email_address">
</div>
<div class="password-wrap">
<input class="password" type="password" placeholder="Password" name="password">