def post_register(request): form = RegisterForm(request.POST) if not form.is_valid(): return get_register(request, errors=form.errors) user = form.save() if user: # 注册成功,发送邮件到用户邮箱 mail_title = u"前端社区(F2E.im)注册成功通知" mail_content = loader.get_template("user/register_mail.html").render(Context({})) sendmail(mail_title, mail_content, user.email) return redirect(settings.LOGIN_URL)
def post_register(request): form = RegisterForm(request.POST) if not form.is_valid(): return get_register(request, errors=form.errors) user = form.save() if user: # 注册成功,发送邮件到用户邮箱 mail_title = u'前端社区(F2E.im)注册成功通知' mail_content = loader.get_template('user/register_mail.html').render( Context({})) sendmail(mail_title, mail_content, user.email) return redirect(settings.LOGIN_URL)
def post_register(request): form = RegisterForm(request.POST) if not form.is_valid(): return get_register(request, errors=form.errors) user = form.save() if user: # 注册成功,发送邮件到用户邮箱 mail_title = u'RDPSite 注册成功通知' #mail_content = loader.get_template('user/register_mail.html') mail_content = loader.render_to_string('user/register_mail.html',{}) sendmail(mail_title, mail_content, user.email) return redirect(settings.LOGIN_URL)
def post_register(request): form = RegisterForm(request.POST) if not form.is_valid(): return get_register(request, errors=form.errors) user = form.save() if user: # 注册成功,发送邮件到用户邮箱 mail_title = u'RDPSite 注册成功通知' #mail_content = loader.get_template('user/register_mail.html') mail_content = loader.render_to_string('user/register_mail.html', {}) sendmail(mail_title, mail_content, user.email) return redirect(settings.LOGIN_URL)
def post_forgotpwd(request): form = ForgotPasswordForm(request.POST) if not form.is_valid(): return get_login(request, errors=form.errors) user = form.get_user() new_password = uuid.uuid1().hex user.set_password(new_password) user.updated = timezone.now() user.save() # 给用户发送新密码 mail_title = u"前端社区(F2E.im)找回密码" var = {"email": user.email, "new_password": new_password} mail_content = loader.get_template("user/forgot_password_mail.html").render(Context(var)) sendmail(mail_title, mail_content, user.email) return get_forgotpwd(request, success_message=u"新密码已发送至您的注册邮箱")
def post_forgotpwd(request): form = ForgotPasswordForm(request.POST) if not form.is_valid(): return get_login(request, errors=form.errors) user = form.get_user() new_password = uuid.uuid1().hex user.set_password(new_password) user.updated = timezone.now() user.save() # 给用户发送新密码 mail_title = u'前端社区(F2E.im)找回密码' var = {'email': user.email, 'new_password': new_password} mail_content = loader.get_template('user/forgot_password_mail.html').render(Context(var)) sendmail(mail_title, mail_content, user.email) return get_forgotpwd(request, success_message=u'新密码已发送至您的注册邮箱')
def post_forgotpassword(request): form = ForgotPasswordForm(request.POST) if not form.is_valid(): return get_login(request, errors=form.errors) user = form.get_user() new_password = uuid.uuid1().hex user.set_password(new_password) user.updated = timezone.now() user.save() # 给用户发送新密码 mail_title = u'RDPSite 找回密码' var = {'email': user.email, 'new_password': new_password} mail_content = loader.render_to_string('user/forgot_password_mail.html', var) sendmail(mail_title, mail_content, user.email) return get_forgotpassword(request, success_message=u'新密码已发送至您的注册邮箱')
def post(self): import common username = self.get_argument('username', '') if not username: self.flash(u'请输入用户名') self.redirect('') else: user = BlogUser.get_user_by_username(username) if not user: self.flash(u'用户名不存在') self.redirect('') else: kvdata = {"user": username, "email": user.email} key = common.md5(common.randomstr(20)) common.set_kvdb_value(key, kvdata) url = 'http://%s/reset/%s/' % (self.request.host, key) common.sendmail(user.email, u'重置密码', url) self.flash(u'邮件发送成功') self.redirect('')