Obscure secret key during edit #193 (#218)

This commit is contained in:
Neeraj Gupta 2023-08-22 23:00:23 +05:30 committed by GitHub
commit 8428af3b40
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -10,30 +10,27 @@ class SetupEnterSecretKeyPage extends StatefulWidget {
SetupEnterSecretKeyPage({this.code, Key? key}) : super(key: key);
@override
State<SetupEnterSecretKeyPage> createState() =>
_SetupEnterSecretKeyPageState();
State<SetupEnterSecretKeyPage> createState() => _SetupEnterSecretKeyPageState();
}
class _SetupEnterSecretKeyPageState extends State<SetupEnterSecretKeyPage> {
late TextEditingController _issuerController;
late TextEditingController _accountController;
late TextEditingController _secretController;
late bool _secretKeyObscured;
@override
void initState() {
_issuerController = TextEditingController(
text: widget.code != null
? safeDecode(widget.code!.issuer).trim()
: null,
text: widget.code != null ? safeDecode(widget.code!.issuer).trim() : null,
);
_accountController = TextEditingController(
text: widget.code != null
? safeDecode(widget.code!.account).trim()
: null,
text: widget.code != null ? safeDecode(widget.code!.account).trim() : null,
);
_secretController = TextEditingController(
text: widget.code != null ? widget.code!.secret : null,
);
_secretKeyObscured = widget.code != null;
super.initState();
}
@ -77,7 +74,18 @@ class _SetupEnterSecretKeyPageState extends State<SetupEnterSecretKeyPage> {
},
decoration: InputDecoration(
hintText: l10n.codeSecretKeyHint,
suffixIcon: IconButton(
onPressed: () {
setState(() {
_secretKeyObscured = !_secretKeyObscured;
});
},
icon: _secretKeyObscured
? const Icon(Icons.visibility_off_rounded)
: const Icon(Icons.visibility_rounded),
),
),
obscureText: _secretKeyObscured,
controller: _secretController,
),
const SizedBox(
@ -118,8 +126,7 @@ class _SetupEnterSecretKeyPageState extends State<SetupEnterSecretKeyPage> {
try {
final account = _accountController.text.trim();
final issuer = _issuerController.text.trim();
final secret =
_secretController.text.trim().replaceAll(' ', '');
final secret = _secretController.text.trim().replaceAll(' ', '');
final Code newCode = widget.code == null
? Code.fromAccountAndSecret(
account,