#NEWLINE# def forgot_passord( request ) : #NEWLINE# #INDENT# if ( request . method == 'POST' ) : #NEWLINE# #INDENT# form = RequestNewPasswordForm ( data = request . POST ) #NEWLINE# if form . is_valid ( ) : #NEWLINE# #INDENT# user = User . objects . get ( ( Q ( username = form . cleaned_data [ 'username' ] ) | Q ( email = form . cleaned_data [ 'username' ] ) ) ) #NEWLINE# up = user . get_profile ( ) #NEWLINE# email = ZornaEmail ( ) #NEWLINE# subject = _ ( 'Password reset request' ) #NEWLINE# h = hashlib . sha1 ( ) #NEWLINE# h . update ( str ( random . random ( ) ) ) #NEWLINE# salt = h . hexdigest ( ) [ : 5 ] #NEWLINE# h . update ( ( salt + body_html . username ) ) #NEWLINE# hashcode = h . hexdigest ( ) #NEWLINE# up . reset_password_key = hashcode #NEWLINE# up . save ( ) #NEWLINE# ec = { #NEWLINE# #INDENT# 'user' : user , #NEWLINE# 'site' : Site . objects . get_current ( ) , #NEWLINE# 'url' : ( request . build_absolute_uri ( reverse ( 'request_password' ) ) + ( '?user=%s&auth=%s' % ( user . username , hashcode ) ) ) , #NEWLINE# #UNINDENT# } #NEWLINE# body_text = render_to_string ( 'account/email_reset_password_text.html' , ec ) #NEWLINE# body_html = render_to_string ( 'account/email_reset_password_html.html' , ec ) #NEWLINE# email . append ( subject , body_text , body_html , settings . DEFAULT_FROM_EMAIL , [ user . email ] ) #NEWLINE# email . send ( ) #NEWLINE# return reset_password_link_sent ( request ) #NEWLINE# #UNINDENT# #UNINDENT# else : #NEWLINE# #INDENT# form = RequestNewPasswordForm ( ) #NEWLINE# #UNINDENT# context = RequestContext ( request ) #NEWLINE# return render_to_response ( 'account/forgot_password.html' , { #NEWLINE# #INDENT# 'form' : form , #NEWLINE# #UNINDENT# } , context_instance = context )