Exemplo n.º 1
0
def forgotPassword(bundle):
	try:
		#find user from post request
		userObj = User.objects.get(username__iexact=bundle.data.get('user'))
	except Exception:
		raise Http404('Username does not Exist')

	#create new reset code object, using the API Key generator (will be a different hash due to different current system time)
	newCode = AuthLinkCode(user=userObj, code=auth.genApiKey(userObj.username))
	newCode.save()

	#create email string
	emailStr = 'Dear ' + userObj.username + ',\n\n'
	emailStr += 'We have received a request to reset your Ramble Online password.\n\n'
	emailStr += 'Please visit the following link to reset your password:\n'
	emailStr += 'http://www.rambleonline.com/resetPassword.html?code=' + newCode.code+'\n\n'
	emailStr += 'If you did not request this email, there is no need to do anything.\n\n'
	emailStr += 'Regards,\nRamble Online Support'

	#send email with django.core.send_mail function, using SMTP settings from the settings.py file in ./server/
	try:
		send_mail('Ramble Online Password Reset Request', emailStr, '*****@*****.**',
	 [userObj.email], fail_silently=False)
	except Exception:
		raise Http404('Email could not be sent at this time, please try later')

	bundle.obj = userObj

	return bundle
Exemplo n.º 2
0
def forgotPassword(bundle):
    try:
        #find user from post request
        userObj = User.objects.get(username__iexact=bundle.data.get('user'))
    except Exception:
        raise Http404('Username does not Exist')

    #create new reset code object, using the API Key generator (will be a different hash due to different current system time)
    newCode = AuthLinkCode(user=userObj, code=auth.genApiKey(userObj.username))
    newCode.save()

    #create email string
    emailStr = 'Dear ' + userObj.username + ',\n\n'
    emailStr += 'We have received a request to reset your Ramble Online password.\n\n'
    emailStr += 'Please visit the following link to reset your password:\n'
    emailStr += 'http://www.rambleonline.com/resetPassword.html?code=' + newCode.code + '\n\n'
    emailStr += 'If you did not request this email, there is no need to do anything.\n\n'
    emailStr += 'Regards,\nRamble Online Support'

    #send email with django.core.send_mail function, using SMTP settings from the settings.py file in ./server/
    try:
        send_mail('Ramble Online Password Reset Request',
                  emailStr,
                  '*****@*****.**', [userObj.email],
                  fail_silently=False)
    except Exception:
        raise Http404('Email could not be sent at this time, please try later')

    bundle.obj = userObj

    return bundle
Exemplo n.º 3
0
 def testApiKeyGen(self):
     self.assertNotEqual(auth.genApiKey('james'), auth.genApiKey('james'))
Exemplo n.º 4
0
	def testApiKeyGen(self):
		self.assertNotEqual(auth.genApiKey('james'), auth.genApiKey('james'))