Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix AttributeError in checkout #999

Merged
merged 5 commits into from
Apr 3, 2017

Conversation

szewczykmira
Copy link
Contributor

Fix #998

@patrys
Copy link
Member

patrys commented Mar 21, 2017

It would be nice to know why we no longer try to auth the user.

@szewczykmira
Copy link
Contributor Author

User is authenticated in form's save method - only when we pass request as an argument. We don't need to do it twice.

@patrys
Copy link
Member

patrys commented Mar 21, 2017

Ok, another question then: why do we have a form that accepts request? I think forms are part of the model layer and should not cross into the view/controller territory.

@szewczykmira
Copy link
Contributor Author

It was logic partially taken from previous version of SignupForm (from allauth). Do you want me to remove authentication from form's save method?

@patrys
Copy link
Member

patrys commented Mar 21, 2017

Ideally, yes, I'd like to avoid passing request to forms.

@codecov-io
Copy link

codecov-io commented Mar 22, 2017

Codecov Report

Merging #999 into master will increase coverage by 0.27%.
The diff coverage is 83.33%.

@@            Coverage Diff            @@
##           master    #999      +/-   ##
=========================================
+ Coverage   63.02%   63.3%   +0.27%     
=========================================
  Files         116     116              
  Lines        6088    6088              
  Branches      743     743              
=========================================
+ Hits         3837    3854      +17     
+ Misses       2102    2079      -23     
- Partials      149     155       +6
Impacted Files Coverage Δ
saleor/registration/forms.py 81.25% <ø> (+0.16%) ⬆️
saleor/registration/views.py 87.5% <83.33%> (-1.08%) ⬇️
saleor/order/views.py 62.85% <83.33%> (+11.42%) ⬆️
saleor/order/utils.py 55.73% <0%> (+4.91%) ⬆️
saleor/order/forms.py 54.83% <0%> (+6.45%) ⬆️

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 79f5f26...e35b179. Read the comment docs.

register_form.save()
password = form_data.get('password')
user = auth.authenticate(email=email, password=password)
if user:
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Under what circumstances can we not get an authenticated user here? Shouldn't that result in a form error? How do we attach the order if the user is None?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You're right - user won't be authenticated only when there is an issue with form. I'll remove if user: in a minute.

auth.login(request, auth_user)
attach_order_to_user(order, auth_user)
register_form.save()
password = form_data.get('password')
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Shouldn't we take the password from register_form.cleaned_data?

@maarcingebala maarcingebala merged commit 7123957 into saleor:master Apr 3, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants