mirror of
https://github.com/trezor/trezor-firmware.git
synced 2025-04-20 00:59:02 +00:00
refactor(core): convert parts of apps.webauthn to layouts
This commit is contained in:
parent
ffe6d65f72
commit
01900b8536
@ -1,8 +1,8 @@
|
||||
import storage.device
|
||||
from trezor import ui, wire
|
||||
from trezor import wire
|
||||
from trezor.messages.Success import Success
|
||||
from trezor.messages.WebAuthnAddResidentCredential import WebAuthnAddResidentCredential
|
||||
from trezor.ui.components.tt.text import Text
|
||||
from trezor.ui.layouts import require, show_error
|
||||
|
||||
from apps.common.confirm import require_confirm
|
||||
|
||||
@ -41,14 +41,16 @@ async def add_resident_credential(
|
||||
try:
|
||||
cred = Fido2Credential.from_cred_id(bytes(msg.credential_id), None)
|
||||
except Exception:
|
||||
text = Text("Import credential", ui.ICON_WRONG, ui.RED)
|
||||
text.normal(
|
||||
"The credential you are",
|
||||
"trying to import does",
|
||||
"not belong to this",
|
||||
"authenticator.",
|
||||
await require(
|
||||
show_error(
|
||||
ctx,
|
||||
"warning_credential",
|
||||
header="Import credential",
|
||||
button="Close",
|
||||
content="The credential you are trying to import does\nnot belong to this authenticator.",
|
||||
red=True,
|
||||
)
|
||||
)
|
||||
await require_confirm(ctx, text, confirm=None, cancel="Close")
|
||||
raise wire.ActionCancelled
|
||||
|
||||
content = ConfirmContent(ConfirmAddCredential(cred))
|
||||
|
@ -4,9 +4,7 @@ from trezor.messages.WebAuthnCredentials import WebAuthnCredentials
|
||||
from trezor.messages.WebAuthnListResidentCredentials import (
|
||||
WebAuthnListResidentCredentials,
|
||||
)
|
||||
from trezor.ui.components.tt.text import Text
|
||||
|
||||
from apps.common.confirm import require_confirm
|
||||
from trezor.ui.layouts import confirm_action, require
|
||||
|
||||
from . import resident_credentials
|
||||
|
||||
@ -14,14 +12,14 @@ from . import resident_credentials
|
||||
async def list_resident_credentials(
|
||||
ctx: wire.Context, msg: WebAuthnListResidentCredentials
|
||||
) -> WebAuthnCredentials:
|
||||
text = Text("List credentials")
|
||||
text.normal(
|
||||
"Do you want to export",
|
||||
"information about the",
|
||||
"resident credentials",
|
||||
"stored on this device?",
|
||||
await require(
|
||||
confirm_action(
|
||||
ctx,
|
||||
"credentials_list",
|
||||
title="List credentials",
|
||||
description="Do you want to export information about the resident credentials stored on this device?",
|
||||
)
|
||||
)
|
||||
await require_confirm(ctx, text)
|
||||
creds = [
|
||||
WebAuthnCredential(
|
||||
index=cred.index,
|
||||
|
@ -358,6 +358,7 @@ def show_error(
|
||||
header: str = "Error",
|
||||
subheader: Optional[str] = None,
|
||||
button: str = "Close",
|
||||
red: bool = False,
|
||||
) -> Awaitable[bool]:
|
||||
return _show_modal(
|
||||
ctx,
|
||||
@ -369,7 +370,7 @@ def show_error(
|
||||
button_confirm=None,
|
||||
button_cancel=button,
|
||||
icon=ui.ICON_WRONG,
|
||||
icon_color=ui.ORANGE_ICON,
|
||||
icon_color=ui.RED if red else ui.ORANGE_ICON,
|
||||
)
|
||||
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user