def test_success_url(self): request = RequestFactory() setattr(request, 'REQUEST', {}) self.assertEqual(helpers.success_url(request), reverse('home')) url = 'https://www.my.jobs/' setattr(request, 'REQUEST', {'next': url}) self.assertEqual(helpers.success_url(request), url)
def handle_post(self, request): """ Registers a user if it was a request to register a user and the registration form was correctly completed. """ # Confirm that the requst is a post, and that this form is # the intended recipient of the posted data. if not request.POST or self.submit_btn_name() not in request.POST: return None form = RegistrationForm(request.POST, auto_id=False) if form.is_valid(): # Create a user, log them in, and redirect based on the # success_url rules. user, created = User.objects.create_user(request=request, send_email=True, **form.cleaned_data) user_cache = authenticate( username=form.cleaned_data['email'], password=form.cleaned_data['password1']) expire_login(request, user_cache) response = HttpResponseRedirect(success_url(request)) response.set_cookie('myguid', user.user_guid, expires=365*24*60*60, domain='.my.jobs') return response return None
def handle_post(self, request): """ Registers a user if it was a request to register a user and the registration form was correctly completed. """ # Confirm that the requst is a post, and that this form is # the intended recipient of the posted data. if not request.POST or self.submit_btn_name() not in request.POST: return None form = RegistrationForm(request.POST, auto_id=False) if form.is_valid(): # Create a user, log them in, and redirect based on the # success_url rules. user, created = User.objects.create_user(request=request, send_email=True, **form.cleaned_data) user_cache = authenticate(username=form.cleaned_data['email'], password=form.cleaned_data['password1']) expire_login(request, user_cache) response = HttpResponseRedirect(success_url(request)) response.set_cookie('myguid', user.user_guid, expires=365 * 24 * 60 * 60, domain='.my.jobs') return response return None
def handle_post(self, request): """ Logs a user in if it was a request to log a user in and the login attempt was successful. """ # Confirm that the requst is a post, and that this form is # the intended recipient of the posted data. if not request.POST or self.submit_btn_name() not in request.POST: return None form = CustomAuthForm(data=request.POST) if form.is_valid(): # Log in the user and redirect based on the success_url rules. expire_login(request, form.get_user()) response = HttpResponseRedirect(success_url(request)) response.set_cookie('myguid', form.get_user().user_guid, expires=365*24*60*60, domain='.my.jobs') return response return None
def handle_post(self, request): """ Logs a user in if it was a request to log a user in and the login attempt was successful. """ # Confirm that the requst is a post, and that this form is # the intended recipient of the posted data. if not request.POST or self.submit_btn_name() not in request.POST: return None form = CustomAuthForm(data=request.POST) if form.is_valid(): # Log in the user and redirect based on the success_url rules. expire_login(request, form.get_user()) response = HttpResponseRedirect(success_url(request)) response.set_cookie('myguid', form.get_user().user_guid, expires=365 * 24 * 60 * 60, domain='.my.jobs') return response return None