Skip to content

Commit

Permalink
Merge pull request #962 from deregs/toggle-scramble-pin
Browse files Browse the repository at this point in the history
add scramble pin toggle
  • Loading branch information
kaloudis authored Apr 27, 2022
2 parents 3aa1929 + 0b1b0c7 commit beb6886
Show file tree
Hide file tree
Showing 13 changed files with 258 additions and 141 deletions.
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(
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

0 comments on commit beb6886

Please sign in to comment.