mirror of
https://github.com/GSA/notifications-admin.git
synced 2026-09-06 16:58:25 -04:00
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:
@@ -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}')
|
current_app.logger.info(f'User {current_user.id} could not register a new webauthn token - {e}')
|
||||||
return cbor.encode(str(e)), 400
|
return cbor.encode(str(e)), 400
|
||||||
|
|
||||||
user_api_client.create_webauthn_credential_for_user(
|
current_user.create_webauthn_credential(credential)
|
||||||
current_user.id, credential
|
|
||||||
)
|
|
||||||
|
|
||||||
flash((
|
flash((
|
||||||
'Registration complete. Next time you sign in to Notify '
|
'Registration complete. Next time you sign in to Notify '
|
||||||
|
|||||||
@@ -360,6 +360,11 @@ class User(JSONModel, UserMixin):
|
|||||||
for credential in self.webauthn_credentials
|
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):
|
def serialize(self):
|
||||||
dct = {
|
dct = {
|
||||||
"id": self.id,
|
"id": self.id,
|
||||||
|
|||||||
Reference in New Issue
Block a user