mirror of
https://github.com/viq/NewsBlur.git
synced 2025-09-18 21:43:31 +00:00
Adding forgot password email with conveniences.
This commit is contained in:
parent
3b38be1676
commit
f29266d707
5 changed files with 77 additions and 3 deletions
|
@ -131,6 +131,28 @@ NewsBlur""" % {'user': self.user.username, 'feeds': subs.count()}
|
|||
to=['%s <%s>' % (user, user.email)])
|
||||
msg.attach_alternative(html, "text/html")
|
||||
msg.send()
|
||||
|
||||
def send_forgot_password_email(self, email=None):
|
||||
if not self.user.email and not email:
|
||||
print "Please provide an email address."
|
||||
return
|
||||
|
||||
if not self.user.email and email:
|
||||
self.user.email = email
|
||||
self.user.save()
|
||||
|
||||
user = self.user
|
||||
text = render_to_string('mail/email_forgot_password.txt', locals())
|
||||
html = render_to_string('mail/email_forgot_password.xhtml', locals())
|
||||
subject = "Forgot your password on NewsBlur?"
|
||||
msg = EmailMultiAlternatives(subject, text,
|
||||
from_email='NewsBlur <%s>' % settings.HELLO_EMAIL,
|
||||
to=['%s <%s>' % (user, user.email)])
|
||||
msg.attach_alternative(html, "text/html")
|
||||
msg.send()
|
||||
|
||||
user.set_password('')
|
||||
user.save()
|
||||
|
||||
def autologin_url(self, next=None):
|
||||
return reverse('autologin', kwargs={
|
||||
|
|
|
@ -315,6 +315,8 @@
|
|||
this.open_account_modal({'animate_email': true});
|
||||
} else if (next == 'goodies') {
|
||||
this.open_goodies_modal();
|
||||
} else if (next == 'password') {
|
||||
this.open_account_modal({'change_password': true});
|
||||
}
|
||||
},
|
||||
|
||||
|
|
|
@ -1,8 +1,9 @@
|
|||
NEWSBLUR.ReaderAccount = function(options) {
|
||||
var defaults = {
|
||||
'animate_email': false,
|
||||
'change_password': false,
|
||||
'onOpen': _.bind(function() {
|
||||
this.animate_email();
|
||||
this.animate_fields();
|
||||
}, this)
|
||||
};
|
||||
|
||||
|
@ -59,7 +60,7 @@ _.extend(NEWSBLUR.ReaderAccount.prototype, {
|
|||
]),
|
||||
$.make('div', { className: 'NB-preference NB-preference-password' }, [
|
||||
$.make('div', { className: 'NB-preference-options' }, [
|
||||
$.make('div', { className: 'NB-preference-option' }, [
|
||||
$.make('div', { className: 'NB-preference-option', style: (this.options.change_password ? 'opacity: .2' : '') }, [
|
||||
$.make('label', { 'for': 'NB-preference-password-old' }, 'Old password'),
|
||||
$.make('input', { id: 'NB-preference-password-old', type: 'password', name: 'old_password', value: '' })
|
||||
]),
|
||||
|
@ -127,7 +128,7 @@ _.extend(NEWSBLUR.ReaderAccount.prototype, {
|
|||
]);
|
||||
},
|
||||
|
||||
animate_email: function() {
|
||||
animate_fields: function() {
|
||||
if (this.options.animate_email) {
|
||||
_.delay(_.bind(function() {
|
||||
var $emails = $('.NB-preference-emails', this.$modal);
|
||||
|
@ -149,7 +150,29 @@ _.extend(NEWSBLUR.ReaderAccount.prototype, {
|
|||
}
|
||||
});
|
||||
}, this), 200);
|
||||
} else if (this.options.change_password) {
|
||||
_.delay(_.bind(function() {
|
||||
var $emails = $('.NB-preference-password', this.$modal);
|
||||
var bgcolor = $emails.css('backgroundColor');
|
||||
$emails.css('backgroundColor', bgcolor).animate({
|
||||
'backgroundColor': 'orange'
|
||||
}, {
|
||||
'queue': false,
|
||||
'duration': 1200,
|
||||
'easing': 'easeInQuad',
|
||||
'complete': function() {
|
||||
$emails.animate({
|
||||
'backgroundColor': bgcolor
|
||||
}, {
|
||||
'queue': false,
|
||||
'duration': 650,
|
||||
'easing': 'easeOutQuad'
|
||||
});
|
||||
}
|
||||
});
|
||||
}, this), 200);
|
||||
}
|
||||
|
||||
},
|
||||
|
||||
close_and_load_preferences: function() {
|
||||
|
|
13
templates/mail/email_forgot_password.txt
Normal file
13
templates/mail/email_forgot_password.txt
Normal file
|
@ -0,0 +1,13 @@
|
|||
{% extends "mail/email_base.txt" %}
|
||||
|
||||
{% block body %}Forgot your password? No problem.
|
||||
|
||||
You can change your password by visiting this link:
|
||||
|
||||
http://www.newsblur.com{{ user.profile.autologin_url }}?next=password
|
||||
|
||||
You will be auto-logged into your account and presented with a form to change your password.
|
||||
|
||||
Hope everything on NewsBlur is working well for you. Let me know if you see any issues. I rely on folks like you who know how to email me to be my eyes and ears on the site.
|
||||
|
||||
{% if not user.profile.is_premium %}And if you like using NewsBlur, consider going premium to help fund further development. I'm a solo developer, so it goes a long way.{% else %}And a huge thanks for going premium. I'm a solo developer, so it goes a long way.{% endif %}{% endblock body %}
|
14
templates/mail/email_forgot_password.xhtml
Normal file
14
templates/mail/email_forgot_password.xhtml
Normal file
|
@ -0,0 +1,14 @@
|
|||
{% extends "mail/email_base.xhtml" %}
|
||||
|
||||
{% block body %}
|
||||
<p style="font-size: 37px; color:#555555; margin-top: 18px;margin-bottom: 10px;padding-top:6px;">Forgot your password? No problem.</p>
|
||||
<p style="line-height: 20px;">You can change your password by visiting this link:</p>
|
||||
<p style="line-height: 20px;"><a href="http://www.newsblur.com{{ user.profile.autologin_url }}?next=password">http://www.newsblur.com{{ user.profile.autologin_url }}?next=password</a></p>
|
||||
<p style="line-height: 20px;">You will be auto-logged into your account and presented with a form to change your password.</p>
|
||||
<p style="line-height: 20px;">Hope everything on NewsBlur is working well for you. Let me know if you see any issues. I rely on folks like you who know how to email me to be my eyes and ears on the site.</p>
|
||||
{% if not user.profile.is_premium %}
|
||||
<p style="line-height: 20px;">And if you like using NewsBlur, consider going premium to help fund further development. I'm a solo developer, so it goes a long way.</p>
|
||||
{% else %}
|
||||
<p style="line-height: 20px;">And a huge thanks for going premium. I'm a solo developer, so it goes a long way.</p>
|
||||
{% endif %}
|
||||
{% endblock %}
|
Loading…
Add table
Reference in a new issue