Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

add scramble pin toggle #962

Merged
merged 2 commits into from
Apr 27, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 4 additions & 2 deletions components/Pin.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -9,14 +9,16 @@ interface PinProps {
hidePinLength: boolean;
pinLength?: number;
pinConfirm?: boolean;
shuffle?: boolean;
}

export default function Pin({
onSubmit,
onPinChange = () => void 0,
hidePinLength,
pinLength = 4,
pinConfirm = false
pinConfirm = false,
shuffle = true
}: PinProps) {
const [pinValue, setPinValue] = useState('');
const maxLength = 8;
Expand Down Expand Up @@ -84,7 +86,7 @@ export default function Pin({
clearValue={clearValue}
deleteValue={deleteValue}
submitValue={submitValue}
shuffle={true}
shuffle={shuffle}
hidePinLength={hidePinLength}
minLength={minLength}
maxLength={maxLength}
Expand Down
1 change: 1 addition & 0 deletions locales/en.json
Original file line number Diff line number Diff line change
Expand Up @@ -131,6 +131,7 @@
"views.Settings.Security.title": "Security settings",
"views.Settings.Security.deletePIN": "Delete PIN",
"views.Settings.Security.deleteDuressPIN": "Delete Duress PIN",
"views.Settings.Security.scramblePIN": "Scramble PIN numbers",
"views.ImportAccount.title": "Import account",
"views.ImportAccount.name": "Account Name",
"views.ImportAccount.extendedPubKey": "Extended Public Key (Xpub)",
Expand Down
4 changes: 3 additions & 1 deletion stores/SettingsStore.ts
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@ interface Settings {
duressPassphrase?: string;
pin?: string;
duressPin?: string;
scramblePin?: boolean;
authenticationAttempts?: number;
fiat?: string;
locale?: string;
Expand Down Expand Up @@ -137,7 +138,8 @@ export default class SettingsStore {
clipboard: true,
lurkerMode: false,
enableMempoolRates: true
}
},
scramblePin: true
};
@observable public loading = false;
@observable btcPayError: string | null;
Expand Down
11 changes: 9 additions & 2 deletions views/Lockscreen.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,6 @@ export default class Lockscreen extends React.Component<
UNSAFE_componentWillMount() {
const { SettingsStore, navigation } = this.props;
const { settings } = SettingsStore;

const modifySecurityScreen: string = navigation.getParam(
'modifySecurityScreen'
);
Expand Down Expand Up @@ -185,6 +184,7 @@ export default class Lockscreen extends React.Component<
duressPassphrase: updatedSettings?.duressPassphrase,
pin: updatedSettings?.pin,
duressPin: updatedSettings?.duressPin,
scramblePin: updatedSettings?.scramblePin,
authenticationAttempts,
fiat: updatedSettings?.fiat,
locale: updatedSettings?.locale,
Expand Down Expand Up @@ -220,6 +220,7 @@ export default class Lockscreen extends React.Component<
duressPassphrase: settings.duressPassphrase,
pin: '',
duressPin: '',
scramblePin: settings.scramblePin,
authenticationAttempts: 0,
fiat: settings.fiat,
locale: settings.locale,
Expand All @@ -243,6 +244,7 @@ export default class Lockscreen extends React.Component<
duressPassphrase: settings.duressPassphrase,
pin: settings.pin,
duressPin: '',
scramblePin: settings.scramblePin,
authenticationAttempts: 0,
fiat: settings.fiat,
locale: settings.locale,
Expand All @@ -266,6 +268,7 @@ export default class Lockscreen extends React.Component<
duressPassphrase: settings.duressPassphrase,
pin: settings.pin,
duressPin: settings.duressPin,
scramblePin: settings.scramblePin,
authenticationAttempts: 0,
fiat: settings.fiat,
locale: settings.locale,
Expand All @@ -289,6 +292,7 @@ export default class Lockscreen extends React.Component<
duressPassphrase: '',
pin: '',
duressPin: '',
scramblePin: settings.scramblePin,
authenticationAttempts: 0,
fiat: settings.fiat,
locale: settings.locale,
Expand All @@ -312,6 +316,7 @@ export default class Lockscreen extends React.Component<
duressPassphrase: settings.duressPassphrase,
pin: settings.pin,
duressPin: settings.duressPin,
scramblePin: settings.scramblePin,
authenticationAttempts: 0,
fiat: settings.fiat,
locale: settings.locale,
Expand Down Expand Up @@ -340,7 +345,8 @@ export default class Lockscreen extends React.Component<
};

render() {
const { navigation } = this.props;
const { navigation, SettingsStore } = this.props;
const { settings } = SettingsStore;
const {
passphrase,
passphraseAttempt,
Expand Down Expand Up @@ -492,6 +498,7 @@ export default class Lockscreen extends React.Component<
}
hidePinLength={true}
pinLength={pin.length}
shuffle={settings.scramblePin}
/>
</View>
</>
Expand Down
30 changes: 10 additions & 20 deletions views/Settings/AddEditNode.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -285,6 +285,7 @@ export default class AddEditNode extends React.Component<
duressPassphrase: settings.duressPassphrase,
pin: settings.pin,
duressPin: settings.duressPin,
scramblePin: settings.scramblePin,
authenticationAttempts:
settings.authenticationAttempts,
privacy: settings.privacy
Expand All @@ -306,7 +307,7 @@ export default class AddEditNode extends React.Component<

copyNodeConfig = () => {
const { SettingsStore, navigation } = this.props;
const { setSettings, settings } = SettingsStore;
const { settings } = SettingsStore;
const {
nickname,
host,
Expand All @@ -322,7 +323,7 @@ export default class AddEditNode extends React.Component<
implementation,
certVerification
} = this.state;
const { nodes, lurkerMode, passphrase, fiat, locale } = settings;
const { nodes } = settings;

const node = {
nickname: `${nickname} copy`,
Expand All @@ -340,24 +341,11 @@ export default class AddEditNode extends React.Component<
enableTor
};

setSettings(
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

why is setSettings ripped out here?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There's no purpose to this call as far as I can see, we're just getting the settings and setting it to the exact same settings. Which makes sense, when copying the node config nothing in the settings changes. The copied node is only added to settings once save node config is pressed on the copied configuration.

JSON.stringify({
nodes,
theme: settings.theme,
selectedNode: settings.selectedNode,
fiat,
locale,
lurkerMode,
passphrase,
privacy: settings.privacy
})
).then(() => {
navigation.navigate('AddEditNode', {
node,
newEntry: true,
saved: false,
index: Number(nodes.length)
});
navigation.navigate('AddEditNode', {
node,
newEntry: true,
saved: false,
index: Number(nodes.length)
});
};

Expand Down Expand Up @@ -386,6 +374,7 @@ export default class AddEditNode extends React.Component<
duressPassphrase: settings.duressPassphrase,
pin: settings.pin,
duressPin: settings.duressPin,
scramblePin: settings.scramblePin,
authenticationAttempts: settings.authenticationAttempts,
privacy: settings.privacy
})
Expand All @@ -411,6 +400,7 @@ export default class AddEditNode extends React.Component<
duressPassphrase: settings.duressPassphrase,
pin: settings.pin,
duressPin: settings.duressPin,
scramblePin: settings.scramblePin,
authenticationAttempts: settings.authenticationAttempts,
privacy: settings.privacy
})
Expand Down
2 changes: 2 additions & 0 deletions views/Settings/Currency.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -143,6 +143,8 @@ export default class Currency extends React.Component<
pin: settings.pin,
duressPin:
settings.duressPin,
scramblePin:
settings.scramblePin,
authenticationAttempts:
settings.authenticationAttempts,
locale: settings.locale,
Expand Down
2 changes: 2 additions & 0 deletions views/Settings/Language.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -135,6 +135,8 @@ export default class Language extends React.Component<
pin: settings.pin,
duressPin:
settings.duressPin,
scramblePin:
settings.scramblePin,
authenticationAttempts:
settings.authenticationAttempts,
locale: item.value,
Expand Down
2 changes: 2 additions & 0 deletions views/Settings/Nodes.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -140,6 +140,8 @@ export default class Nodes extends React.Component<NodesProps, NodesState> {
settings.duressPassphrase,
pin: settings.pin,
duressPin: settings.duressPin,
scramblePin:
settings.scramblePin,
authenticationAttempts:
settings.authenticationAttempts,
privacy: settings.privacy
Expand Down
10 changes: 10 additions & 0 deletions views/Settings/Privacy.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -147,6 +147,8 @@ export default class Privacy extends React.Component<
settings.duressPassphrase,
pin: settings.pin,
duressPin: settings.duressPin,
scramblePin:
settings.scramblePin,
authenticationAttempts:
settings.authenticationAttempts,
locale: settings.locale,
Expand Down Expand Up @@ -211,6 +213,8 @@ export default class Privacy extends React.Component<
pin: settings.pin,
duressPin:
settings.duressPin,
scramblePin:
settings.scramblePin,
authenticationAttempts:
settings.authenticationAttempts,
locale: settings.locale,
Expand Down Expand Up @@ -287,6 +291,8 @@ export default class Privacy extends React.Component<
pin: settings.pin,
duressPin:
settings.duressPin,
scramblePin:
settings.scramblePin,
authenticationAttempts:
settings.authenticationAttempts,
locale: settings.locale,
Expand Down Expand Up @@ -366,6 +372,8 @@ export default class Privacy extends React.Component<
pin: settings.pin,
duressPin:
settings.duressPin,
scramblePin:
settings.scramblePin,
authenticationAttempts:
settings.authenticationAttempts,
locale: settings.locale,
Expand Down Expand Up @@ -446,6 +454,8 @@ export default class Privacy extends React.Component<
pin: settings.pin,
duressPin:
settings.duressPin,
scramblePin:
settings.scramblePin,
authenticationAttempts:
settings.authenticationAttempts,
locale: settings.locale,
Expand Down
Loading