Exemple #1
0
def edituser(request):
	if request.method == 'POST':
		u_email = request.POST['email']
		u_pass = request.POST['password2']
		u_pass_en = encrypt(u_pass)
		u_ptype = request.POST['phoneType']
		u_pnumber = request.POST['cellPhone']
		user_obj = CiviguardUsersModel.objects.get(emailAdd=u_email)
		reg = re.compile('^[*]+$')
		user_obj.phoneType = u_ptype
		if bool(reg.match(u_pass)) | (user_obj.password2 == u_pass_en):
			pass
		else:
			user_obj.password2 = u_pass
		if user_obj.cellPhone != u_pnumber:
			user_obj.cellPhone = u_pnumber
			user_obj.save()
			notice = 'Since your mobile number has been changed we need to confirm it'
			return render_to_response('signup5.html', {'activated': notice, 'code': 'code', 'npnumber': u_pnumber, 'userEmail': u_email}, context_instance=RequestContext(request))			
		else:
			user_obj.save()
			notice = 'Changes have been made successfully'
			return render_to_response('editinfo.html', {'tpNum': u_pnumber, 'pt': u_ptype, 'email': u_email, 'notice': notice}, context_instance=RequestContext(request))
	else:
		return HttpResponse('Error')	
Exemple #2
0
def user_login(request):
	if (request.method == 'POST') | (request.method == 'GET'):
		form = CiviguardUsersLogin(request.POST)
		if form.is_valid():
			errMsg = 'The Email ID or Password you entered is incorrect'
			cd = form.cleaned_data
			try:
				uemail = cd['emailAdd']
				upass = encrypt(cd['password'])
				cUser = CiviguardUsersModel.objects.get(emailAdd=uemail)
				pNumber = cUser.cellPhone
				pType = cUser.phoneType	
				if (cUser.password2 == upass) & (cUser.emailAdd == uemail):			
					if cUser.activated == 1:
						request.session['u_id'] = cUser.userKey
						return render_to_response('editinfo.html', {'tpNum': pNumber, 'pt': pType, 'email': uemail}, context_instance=RequestContext(request))
					else:
						actError = 'Your account is not activated'
						return render_to_response('signup4.html', {'lgerror': actError}, context_instance=RequestContext(request))
				else:
					return render_to_response('signup4.html', {'lgerror': errMsg}, context_instance=RequestContext(request))									
			except Exception, ex:
				return render_to_response('signup4.html', {'lgerror': str(ex)}, context_instance=RequestContext(request))									
		elif request.session.get('u_id'):
			u_id = request.session.get('u_id')
			civ_user = CiviguardUsersModel.objects.get(userKey=u_id)
			pNumber = civ_user.cellPhone
			pType = civ_user.phoneType
			uemail = civ_user.emailAdd
			return render_to_response('editinfo.html', {'tpNum': pNumber, 'pt': pType, 'email': uemail}, context_instance=RequestContext(request))
		else:
			form = CiviguardUsersLogin()
		return render_to_response('signup4.html', {'form': form}, context_instance=RequestContext(request))
Exemple #3
0
def resetpassword(request):
	if request.method == 'POST':
		upass = request.POST['password2']
		userVal = request.POST['reqval']
		user_obj = CiviguardUsersModel.objects.get(passResetCode=userVal)
		user_obj.password2 = encrypt(upass)
		user_obj.save()
		return HttpResponseRedirect('/login/')
	else:
		return HttpResponseRedirect('/resetpassword/')
Exemple #4
0
def check_form(request):
	if request.method == 'POST':
		form = CiviguardUsers(request.POST)
		if form.is_valid():
			cd = form.cleaned_data
			try:
				name = cd['fullName']
				email = cd['emailAdd']
				password2 = encrypt(cd['password2'])
				phone = cd['cellPhone']
				phoneType = cd['phoneType']
				region = ''
				res = domain(request)
				if res[0] == True:
					region = res[1]
				else:
					region = 'None'
				return render_to_response('signup2.html', {'name': name, 'email': email, 'password2': password2, 'phone': phone, 'pt': phoneType, 'rg': region})
			except Exception, ex:
				# sys.stderr.write('Value error: %s\n' % str(ex)
				return HttpResponse("Error %s" % str(ex))
		else:
			return HttpResponse('Error')