Skip to content

Commit

Permalink
Test revision
Browse files Browse the repository at this point in the history
  • Loading branch information
na-stewart committed Jun 23, 2024
1 parent 4b5e151 commit e9c79d0
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 8 deletions.
14 changes: 8 additions & 6 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -165,9 +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)
two_step_session = await request_two_step_verification(request, account)
await email_code(
account.email, two_step_session.code # Code = 197251
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 @@ -204,9 +204,11 @@ 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)
two_step_session = await request_two_step_verification(
request, authentication_session.bearer
)
await email_code(
authentication_session.bearer.email, two_step_session.code # Code = 197251
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 @@ -322,8 +324,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)
response = captcha_session.get_image() # Captcha: 192731
captcha_session = await request_captcha(request)
response = captcha_session.get_image() # Captcha: 192731
captcha_session.encode(response)
return response
```
Expand Down
4 changes: 2 additions & 2 deletions sanic_security/test/server.py
Original file line number Diff line number Diff line change
Expand Up @@ -110,7 +110,7 @@ async def on_login(request):
)
two_step_session.encode(response)
else:
response = json("Login successful!", authentication_session.bearer.json)
response = json("Login successful!", authentication_session.json)
authentication_session.encode(response)
return response

Expand Down Expand Up @@ -148,7 +148,7 @@ async def on_logout(request):
Logout of currently logged in account.
"""
authentication_session = await logout(request)
response = json("Logout successful!", authentication_session.bearer.json)
response = json("Logout successful!", authentication_session.json)
return response


Expand Down
2 changes: 2 additions & 0 deletions sanic_security/test/tests.py
Original file line number Diff line number Diff line change
Expand Up @@ -306,6 +306,8 @@ def test_anonymous_login(self):
"http://127.0.0.1:8000/api/test/auth",
)
assert authenticate_response.status_code == 200, authenticate_response.text
logout_response = self.client.post("http://127.0.0.1:8000/api/test/auth/logout")
assert logout_response.status_code == 200, logout_response.text


class VerificationTest(TestCase):
Expand Down

0 comments on commit e9c79d0

Please sign in to comment.