0
Fork 0
mirror of https://github.com/TryGhost/Ghost.git synced 2025-02-03 23:00:14 -05:00

Repaired email sending, implement password reset

Closes #288
* I use SendGrid for sending the emails, and it works fine (provided you supply the correct credentials in `config.mail` in `config.js`)
* Generates a random 12 char long alphanumeric password, replaces user's pw, and sends an email about it.
This commit is contained in:
Gabor Javorszky 2013-09-01 00:20:12 +02:00
parent 14d4145514
commit 48d875a2eb
4 changed files with 50 additions and 2 deletions

View file

@ -14,7 +14,8 @@
'debug/' : 'debug',
'register/' : 'register',
'signup/' : 'signup',
'signin/' : 'login'
'signin/' : 'login',
'forgotten/' : 'forgotten'
},
signup: function () {
@ -25,6 +26,10 @@
Ghost.currentView = new Ghost.Views.Login({ el: '.js-login-container' });
},
forgotten: function () {
Ghost.currentView = new Ghost.Views.Forgotten({ el: '.js-login-container' });
},
blog: function () {
var posts = new Ghost.Collections.Posts();
posts.fetch({ data: { status: 'all', orderBy: ['updated_at', 'DESC'] } }).then(function () {

View file

@ -0,0 +1,9 @@
<form id="forgotten" method="post" novalidate="novalidate">
<div class="email-wrap">
<input class="email" type="email" placeholder="Email Address" name="email" autocapitalize="off" autocorrect="off">
</div>
<button class="button-save" type="submit">Send new password</button>
<section class="meta">
<a href="/ghost/login/">Log in</a>
</section>
</form>

View file

@ -7,6 +7,6 @@
</div>
<button class="button-save" type="submit">Log in</button>
<section class="meta">
<a class="forgotten-password" href="#">Forgotten password?</a> &bull; <a href="/ghost/signup/">Register new user</a>
<a class="forgotten-password" href="/ghost/forgotten/">Forgotten password?</a> &bull; <a href="/ghost/signup/">Register new user</a>
</section>
</form>

View file

@ -109,4 +109,38 @@
});
}
});
Ghost.Views.Forgotten = Ghost.SimpleFormView.extend({
templateName: "forgotten",
events: {
'submit #forgotten': 'submitHandler'
},
submitHandler: function (event) {
event.preventDefault();
var email = this.$el.find('.email').val();
$.ajax({
url: '/ghost/forgotten/',
type: 'POST',
data: {
email: email
},
success: function (msg) {
window.location.href = msg.redirect;
},
error: function (xhr) {
Ghost.notifications.addItem({
type: 'error',
message: Ghost.Views.Utils.getRequestErrorMessage(xhr),
status: 'passive'
});
}
});
}
});
}());