PedroBern / django-graphql-auth

Django registration and authentication with GraphQL.
https://django-graphql-auth.readthedocs.io/en/latest/
MIT License
329 stars 106 forks source link

Fix for register mutation in case username not included #81

Closed imsheldon closed 3 years ago

imsheldon commented 3 years ago

If you omit the username field from 'REGISTER_MUTATION_FIELDS': ["email", "first_name"], and set username with signal, the login fails after registration, since we don't have username detail. This is an attempt to fix the same if username is generated with the help of some signal.

codecov-io commented 3 years ago

Codecov Report

Merging #81 into master will decrease coverage by 0.12%. The diff coverage is 50.00%.

Impacted file tree graph

@@            Coverage Diff             @@
##           master      #81      +/-   ##
==========================================
- Coverage   92.52%   92.39%   -0.13%     
==========================================
  Files          11       11              
  Lines         682      684       +2     
==========================================
+ Hits          631      632       +1     
- Misses         51       52       +1     
Impacted Files Coverage Δ
graphql_auth/mixins.py 90.15% <50.00%> (-0.25%) :arrow_down:

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 b15856d...29e2500. Read the comment docs.

PedroBern commented 3 years ago

Hi @imsheldon, thanks for the PR! I see your point and agree with the changes, but I think it would be better if we toggle this option as a new boolean flag setting, so everybody could be aware of this, preventing unaware registering without a username. Can you make this?

Here is the summary:

  1. Create a new boolean setting, defaulting to false, something like HANDLED_USERNAME, or whatever you find more appropriate.
  2. Check for the setting and proceed with the code.
  3. Update the docs for the new setting.
imsheldon commented 3 years ago

Ok, I will work on it and create the PR.