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:
parent
14d4145514
commit
48d875a2eb
4 changed files with 50 additions and 2 deletions
|
@ -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 () {
|
||||
|
|
9
ghost/admin/tpl/forgotten.hbs
Normal file
9
ghost/admin/tpl/forgotten.hbs
Normal 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>
|
|
@ -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> • <a href="/ghost/signup/">Register new user</a>
|
||||
<a class="forgotten-password" href="/ghost/forgotten/">Forgotten password?</a> • <a href="/ghost/signup/">Register new user</a>
|
||||
</section>
|
||||
</form>
|
||||
|
|
|
@ -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'
|
||||
});
|
||||
}
|
||||
});
|
||||
}
|
||||
});
|
||||
}());
|
||||
|
|
Loading…
Add table
Reference in a new issue