-
Notifications
You must be signed in to change notification settings - Fork 10
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #406 from Foundation-Devices/SFT-36-device-names
SFT-36: device names
- Loading branch information
Showing
8 changed files
with
61 additions
and
3 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
40 changes: 40 additions & 0 deletions
40
ports/stm32/boards/Passport/modules/flows/rename_device_flow.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
# SPDX-FileCopyrightText: © 2023 Foundation Devices, Inc. <[email protected]> | ||
# SPDX-License-Identifier: GPL-3.0-or-later | ||
# | ||
# name_device_flow.py - Name or rename the device | ||
|
||
from flows import Flow | ||
from serializations import sha256 | ||
from pages import TextInputPage, ErrorPage | ||
from common import settings | ||
from constants import MAX_ACCOUNT_NAME_LEN | ||
import microns | ||
|
||
|
||
class RenameDeviceFlow(Flow): | ||
def __init__(self): | ||
super().__init__(initial_state=self.rename_device, name='NameDeviceFLow') | ||
|
||
async def rename_device(self): | ||
name = settings.get('device_name', None) or '' | ||
result = await TextInputPage(initial_text=name, | ||
max_length=MAX_ACCOUNT_NAME_LEN, | ||
left_micron=microns.Cancel, | ||
right_micron=microns.Checkmark).show() | ||
if result is None: | ||
self.set_result(False) | ||
return | ||
|
||
if len(result) == 0: | ||
settings.set('device_name', None) | ||
self.set_result(True) | ||
return | ||
|
||
prefix = result[:4] | ||
hashes = [sha256(prefix), sha256(prefix.upper()), sha256(prefix.lower())] | ||
if settings.get('pin_prefix_hash') in hashes: | ||
await ErrorPage("Don't use your pin as the device name, because it will be shown on the login page.").show() | ||
return | ||
|
||
settings.set('device_name', result) | ||
self.set_result(True) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters