Skip to content

Commit ac42030

Browse files
Update docs
1 parent b689954 commit ac42030

File tree

7 files changed

+172
-0
lines changed

7 files changed

+172
-0
lines changed

README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -64,6 +64,7 @@ class AuthMutation(graphene.ObjectType):
6464
resend_activation_email = mutations.ResendActivationEmail.Field()
6565
send_password_reset_email = mutations.SendPasswordResetEmail.Field()
6666
password_reset = mutations.PasswordReset.Field()
67+
password_set = mutations.PasswordSet.Field() # For passwordless registration
6768
password_change = mutations.PasswordChange.Field()
6869
update_account = mutations.UpdateAccount.Field()
6970
archive_account = mutations.ArchiveAccount.Field()

docs/api.md

Lines changed: 124 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -351,6 +351,130 @@ mutation {
351351
}
352352
```
353353

354+
---
355+
#### PasswordSet
356+
357+
{{ api.PasswordSet }}
358+
359+
```bash tab="graphql"
360+
mutation {
361+
passwordSet(
362+
token: "1eyJ1c2VybmFtZSI6InNreXdhbGtlciIsImFjdGlvbiI6InBhc3N3b3JkX3Jlc2V0In0:1itExL:op0roJi-ZbO9cszNEQMs5mX3c6s",
363+
newPassword1: "supersecretpassword",
364+
newPassword2: "supersecretpassword"
365+
) {
366+
success,
367+
errors
368+
}
369+
}
370+
```
371+
372+
```bash tab="success"
373+
{
374+
"data": {
375+
"passwordSet": {
376+
"success": true,
377+
"errors": null
378+
}
379+
}
380+
}
381+
```
382+
383+
```bash tab="relay"
384+
mutation {
385+
passwordSet(
386+
input: {
387+
token: "1eyJ1c2VybmFtZSI6InNreXdhbGtlciIsImFjdGlvbiI6InBhc3N3b3JkX3Jlc2V0In0:1itExL:op0roJi-ZbO9cszNEQMs5mX3c6s",
388+
newPassword1: "supersecretpassword",
389+
newPassword2: "supersecretpassword"
390+
}
391+
) {
392+
success,
393+
errors
394+
}
395+
}
396+
```
397+
398+
```bash tab="Invalid token"
399+
{
400+
"data": {
401+
"passwordSet": {
402+
"success": false,
403+
"errors": {
404+
"nonFieldErrors": [
405+
{
406+
"message": "Invalid token.",
407+
"code": "invalid_token"
408+
}
409+
]
410+
}
411+
}
412+
}
413+
}
414+
```
415+
416+
```bash tab="Password mismatch"
417+
{
418+
"data": {
419+
"passwordSet": {
420+
"success": false,
421+
"errors": {
422+
"newPassword2": [
423+
{
424+
"message": "The two password fields didn’t match.",
425+
"code": "password_mismatch"
426+
}
427+
]
428+
}
429+
}
430+
}
431+
}
432+
```
433+
434+
```bash tab="Password validators"
435+
{
436+
"data": {
437+
"passwordSet": {
438+
"success": false,
439+
"errors": {
440+
"newPassword2": [
441+
{
442+
"message": "This password is too short. It must contain at least 8 characters.",
443+
"code": "password_too_short"
444+
},
445+
{
446+
"message": "This password is too common.",
447+
"code": "password_too_common"
448+
},
449+
{
450+
"message": "This password is entirely numeric.",
451+
"code": "password_entirely_numeric"
452+
}
453+
]
454+
}
455+
}
456+
}
457+
}
458+
```
459+
460+
```bash tab="Password Set"
461+
{
462+
"data": {
463+
"passwordSet": {
464+
"success": false,
465+
"errors": {
466+
"nonFieldErrors": [
467+
{
468+
"message": "Password already set for account.",
469+
"code": "password_already_set"
470+
}
471+
]
472+
}
473+
}
474+
}
475+
}
476+
```
477+
354478
---
355479

356480
#### PasswordReset

docs/data/api.yml

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -73,6 +73,17 @@ PasswordReset: |
7373
7474
Also, if user has not been verified yet, verify it.
7575
76+
PasswordSet: |
77+
Set user password - for passwordless registration
78+
79+
Receive the token that was sent by email.
80+
81+
If token and new passwords are valid, set
82+
user password and in case of using refresh
83+
tokens, revoke all of them.
84+
85+
Also, if user has not been verified yet, verify it.
86+
7687
ObtainJSONWebToken: |
7788
Obtain JSON web token for given user.
7889

docs/index.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,7 @@ your implementation^^.
4646
* [x] All mutations return `success` and `errors`
4747
* [x] Default email templates <small>(you will customize though)</small>
4848
* [x] Customizable, no lock-in
49+
* [x] Passwordless registration
4950

5051
---
5152

docs/installation.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -65,6 +65,7 @@ class AuthMutation(graphene.ObjectType):
6565
resend_activation_email = mutations.ResendActivationEmail.Field()
6666
send_password_reset_email = mutations.SendPasswordResetEmail.Field()
6767
password_reset = mutations.PasswordReset.Field()
68+
password_set = mutations.PasswordSet.Field() # For passwordless registration
6869
password_change = mutations.PasswordChange.Field()
6970
update_account = mutations.UpdateAccount.Field()
7071
archive_account = mutations.ArchiveAccount.Field()
@@ -105,6 +106,7 @@ class AuthRelayMutation(graphene.ObjectType):
105106
resend_activation_email = relay.ResendActivationEmail.Field()
106107
send_password_reset_email = relay.SendPasswordResetEmail.Field()
107108
password_reset = relay.PasswordReset.Field()
109+
password_set = relay.PasswordSet.Field() # For passwordless registration
108110
password_change = relay.PasswordChange.Field()
109111
update_account = relay.UpdateAccount.Field()
110112
archive_account = relay.ArchiveAccount.Field()

docs/settings.md

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,14 @@ If a user has a secondary email set, he can use to login.
3232

3333
default: `#!python True`
3434

35+
### ALLOW_PASSWORDLESS_REGISTRATION
36+
37+
To allow registration with no password; Django `set_unusable_password()` will be used in setting the default password.
38+
39+
- User cannot login until they set their password
40+
41+
default: `#!python False`
42+
3543
### ALLOW_DELETE_ACCOUNT
3644

3745
Instead of deleting the account, make `#!python user.is_active=False`.
@@ -48,6 +56,12 @@ Note that users will still have an `#!python verified=False` status.
4856

4957
default: `#!python True`
5058

59+
### SEND_PASSWORD_SET_EMAIL
60+
61+
If set to `#!python True`, user will be notified to set their password after registration - dependent on `ALLOW_PASSWORDLESS_REGISTRATION`.
62+
63+
default: `#!python False`
64+
5165
---
5266

5367
## Dynamic Fields
@@ -158,6 +172,10 @@ default: `#!python timedelta(hours=1)`
158172

159173
default: `#!python timedelta(hours=1)`
160174

175+
### EXPIRATION_PASSWORD_SET_TOKEN
176+
177+
default: `#!python timedelta(days=7)`
178+
161179
---
162180

163181
## Email
@@ -180,6 +198,12 @@ Path [variable](overriding-email-templates.md) used in password reset email.
180198

181199
default: `#!python "password-reset"`
182200

201+
### PASSWORD_SET_PATH_ON_EMAIL
202+
203+
Path [variable](overriding-email-templates.md) used in password set email.
204+
205+
default: `#!python "password-set"`
206+
183207
### ACTIVATION_SECONDARY_EMAIL_PATH_ON_EMAIL
184208

185209
Path [variable](overriding-email-templates.md) used in secondary email activation email.
@@ -237,6 +261,10 @@ default: `#!python "email/activation_subject.txt"`
237261

238262
default: `#!python "email/password_reset_subject.txt"`
239263

264+
### EMAIL_SUBJECT_PASSWORD_SET
265+
266+
default: `#!python "email/password_set_subject.txt"`
267+
240268

241269
---
242270

@@ -261,6 +289,10 @@ default: `#!python "email/activation_email.html"`
261289

262290
default: `#!python "email/password_reset_email.html"`
263291

292+
### EMAIL_TEMPLATE_PASSWORD_SET
293+
294+
default: `#!python "email/password_set_email.html"`
295+
264296
### EMAIL_TEMPLATE_VARIABLES
265297

266298
default: `#!python {}`

quickstart/quickstart/schema.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ class AuthMutation(graphene.ObjectType):
1212
resend_activation_email = mutations.ResendActivationEmail.Field()
1313
send_password_reset_email = mutations.SendPasswordResetEmail.Field()
1414
password_reset = mutations.PasswordReset.Field()
15+
password_set = mutations.PasswordSet.Field()
1516
password_change = mutations.PasswordChange.Field()
1617
archive_account = mutations.ArchiveAccount.Field()
1718
delete_account = mutations.DeleteAccount.Field()

0 commit comments

Comments
 (0)