Refactor into model

It’s generally an antipattern for the view layer code to be calling the
API client directly.
This commit is contained in:
Chris Hill-Scott
2021-06-07 13:51:39 +01:00
parent 1b459d6692
commit 45645728c7
2 changed files with 6 additions and 3 deletions

View File

@@ -52,9 +52,7 @@ def webauthn_complete_register():
current_app.logger.info(f'User {current_user.id} could not register a new webauthn token - {e}')
return cbor.encode(str(e)), 400
user_api_client.create_webauthn_credential_for_user(
current_user.id, credential
)
current_user.create_webauthn_credential(credential)
flash((
'Registration complete. Next time you sign in to Notify '

View File

@@ -360,6 +360,11 @@ class User(JSONModel, UserMixin):
for credential in self.webauthn_credentials
]
def create_webauthn_credential(self, credential):
user_api_client.create_webauthn_credential_for_user(
self.id, credential
)
def serialize(self):
dct = {
"id": self.id,