Skip to content

Commit

Permalink
Docs revision
Browse files Browse the repository at this point in the history
  • Loading branch information
na-stewart committed Jun 23, 2024
1 parent a396584 commit 4b5e151
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 12 deletions.
18 changes: 7 additions & 11 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ pip3 install sanic-security

If you are planning on encoding or decoding JWTs using certain digital signature algorithms (like RSA or ECDSA which use
the public secret and private secret), you will need to install the `cryptography` library. This can be installed explicitly, or
as a required extra in the `sanic-security` requirement.
as an extra requirement.

```shell
pip3 install sanic-security[crypto]
Expand Down Expand Up @@ -165,11 +165,9 @@ Phone can be null or empty.
@app.post("api/security/register")
async def on_register(request):
account = await register(request)
two_step_session = await request_two_step_verification(
request, account
) # Code = 197251
two_step_session = await request_two_step_verification(request, account)
await email_code(
account.email, two_step_session.code
account.email, two_step_session.code # Code = 197251
) # Custom method for emailing verification code.
response = json(
"Registration successful! Email verification required.",
Expand Down Expand Up @@ -206,11 +204,9 @@ You can use a username as well as an email for login if `ALLOW_LOGIN_WITH_USERNA
@app.post("api/security/login")
async def on_login(request):
authentication_session = await login(request, require_second_factor=True)
two_step_session = await request_two_step_verification(
request, authentication_session.bearer
) # Code = 197251
two_step_session = await request_two_step_verification(request, authentication_session.bearer)
await email_code(
authentication_session.bearer.email, two_step_session.code
authentication_session.bearer.email, two_step_session.code # Code = 197251
) # Custom method for emailing verification code.
response = json(
"Login successful! Two-factor authentication required.",
Expand Down Expand Up @@ -326,8 +322,8 @@ downloading a .ttf font and defining the file's path in the configuration.
```python
@app.get("api/security/captcha")
async def on_captcha_img_request(request):
captcha_session = await request_captcha(request) # Captcha: 192731
response = captcha_session.get_image()
captcha_session = await request_captcha(request)
response = captcha_session.get_image() # Captcha: 192731
captcha_session.encode(response)
return response
```
Expand Down
2 changes: 1 addition & 1 deletion sanic_security/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -549,7 +549,7 @@ def validate(self) -> None:

async def refresh(self, request: Request):
"""
Seamlessly creates new session if within refresh date.
Refreshes session if expired and within refresh date.
Raises:
DeletedError
Expand Down

0 comments on commit 4b5e151

Please sign in to comment.