Пример #1
0
def sendResetEmailPost(handler, p_username):
	handler.title('Reset password')
	user = User.load(username = p_username)
	if not user:
		ErrorBox.die("Invalid User", "No user named <b>%s</b>" % stripTags(p_username))

	user.resetkey = "%x" % random.randint(0x10000000, 0xffffffff)
	try:
		sendmail(user.getEmail(), "Sprint - Password Reset", "Someone (hopefully you) requested a Sprint password reset. You can follow this link to reset your password: http://%s:%d/resetpw/%s?key=%s. If you didn't request this or no longer need it, it will expire in a day or two." % (gethostname(), PORT, user.safe.username, user.resetkey))
	except Exception:
		Event.error(handler, "<div style=\"white-space: normal\">%s</div>" % formatException())
		ErrorBox.die("Reset failed", "Unable to send password reset e-mail")

	user.save()
	print SuccessBox("A password reset e-mail has been sent")
Пример #2
0
	def unhandledError(self):
		super(HTTPHandler, self).unhandledError()
		Event.error(self, "<div style=\"white-space: normal\">%s</div>" % formatException())