def register(request): if request.method == 'POST': registration = RegistrationForm(request.POST) if registration.is_valid(): username = registration.cleaned_data['username'] password = registration.cleaned_data['password'] password_verify = registration.cleaned_data['password_verify'] if password == password_verify: user_class = get_user_model() user = user_class.objects.create_user(username, None, password) user.bcc_id = binascii.hexlify(get_random_bytes(64)) user.save() if not vault.create_new_user(user.bcc_id, dbconf.FRONTEND_USER, dbconf.FRONTEND_PASS): messages.error(request, 'Failed to fully create user' + ' account') user = authenticate(username=username, password=password) if user is not None: if user.is_active: login(request, user) return HttpResponseRedirect( reverse('bcc.views.profile')) else: messages.error(request, 'Unable to log in') else: messages.error(request, 'An error occurred creating a ' + 'new user account') else: registration = RegistrationForm() return render_to_response('registration.html', {'form': registration}, context_instance=RequestContext(request))
def get_seed(self): """Return a random seed for the table's rounds""" return get_random_bytes(256)