diff --git a/apps/profile/models.py b/apps/profile/models.py index 4e6585119..0da841d34 100644 --- a/apps/profile/models.py +++ b/apps/profile/models.py @@ -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={ diff --git a/media/js/newsblur/reader.js b/media/js/newsblur/reader.js index 12221c97d..635a7fe0a 100644 --- a/media/js/newsblur/reader.js +++ b/media/js/newsblur/reader.js @@ -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}); } }, diff --git a/media/js/newsblur/reader_account.js b/media/js/newsblur/reader_account.js index 77dd4beec..e6a6e10e2 100644 --- a/media/js/newsblur/reader_account.js +++ b/media/js/newsblur/reader_account.js @@ -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() { diff --git a/templates/mail/email_forgot_password.txt b/templates/mail/email_forgot_password.txt new file mode 100644 index 000000000..64bc4227f --- /dev/null +++ b/templates/mail/email_forgot_password.txt @@ -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 %} \ No newline at end of file diff --git a/templates/mail/email_forgot_password.xhtml b/templates/mail/email_forgot_password.xhtml new file mode 100644 index 000000000..ffc185887 --- /dev/null +++ b/templates/mail/email_forgot_password.xhtml @@ -0,0 +1,14 @@ +{% extends "mail/email_base.xhtml" %} + +{% 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 %}