Updated pages
This commit is contained in:
parent
5a05058256
commit
fd33a67b47
5 changed files with 226 additions and 114 deletions
|
|
@ -34,23 +34,23 @@ class _LoginPageState extends State<LoginPage> {
|
|||
});
|
||||
}
|
||||
|
||||
Future<bool> _checkConnection() async {
|
||||
try {
|
||||
final connection = await getApi('check-connection', null, null);
|
||||
return connection["result"];
|
||||
} catch (e) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
// Future<bool> _checkConnection() async {
|
||||
// try {
|
||||
// final connection = await getApi('check-connection', null, null);
|
||||
// return connection["result"];
|
||||
// } catch (e) {
|
||||
// return false;
|
||||
// }
|
||||
// }
|
||||
|
||||
Future<String> _getPassword(String employeeid) async {
|
||||
try {
|
||||
final response = await getApi('get-password', employeeid, null);
|
||||
return (response["result"]);
|
||||
} catch (e) {
|
||||
return "0";
|
||||
}
|
||||
}
|
||||
// Future<String> _getPassword(String employeeid) async {
|
||||
// try {
|
||||
// final response = await getApi('get-password', employeeid, null);
|
||||
// return (response["result"]);
|
||||
// } catch (e) {
|
||||
// return "0";
|
||||
// }
|
||||
// }
|
||||
|
||||
Future<String> _securePassword(String password) async {
|
||||
final firstHash = sha1.string(password);
|
||||
|
|
@ -60,23 +60,23 @@ class _LoginPageState extends State<LoginPage> {
|
|||
return thirdHash.toString();
|
||||
}
|
||||
|
||||
void _login() async {
|
||||
final connected = await _checkConnection();
|
||||
// void _login() async {
|
||||
// final connected = await _checkConnection();
|
||||
|
||||
if (connected) {
|
||||
final employeeid = _approverId;
|
||||
final dbpassword = await _getPassword(employeeid);
|
||||
final hashPassword = await _securePassword(_passwordController.text);
|
||||
// if (connected) {
|
||||
// final employeeid = _approverId;
|
||||
// final dbpassword = await _getPassword(employeeid);
|
||||
// final hashPassword = await _securePassword(_passwordController.text);
|
||||
|
||||
if (context.mounted) {
|
||||
if (dbpassword == hashPassword) {
|
||||
_setLogin();
|
||||
} else {
|
||||
_showDialog();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
// if (context.mounted) {
|
||||
// if (dbpassword == hashPassword) {
|
||||
// _setLogin();
|
||||
// } else {
|
||||
// _showDialog();
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
|
||||
void _setLogin() {
|
||||
blocSetUser(context, _approver);
|
||||
|
|
@ -134,16 +134,16 @@ class _LoginPageState extends State<LoginPage> {
|
|||
const Gap(8),
|
||||
InputWidget(controller: _passwordController, password: true),
|
||||
const Gap(24),
|
||||
ValueListenableBuilder<String>(
|
||||
valueListenable: passwordNotifier,
|
||||
builder: (context, password, child) {
|
||||
return ButtonWidget(
|
||||
text: password.isNotEmpty ? 'Login' : 'Required password',
|
||||
onPressed: password.isNotEmpty ? _login : _ignoreButton,
|
||||
disabled: password.isEmpty,
|
||||
);
|
||||
},
|
||||
),
|
||||
// ValueListenableBuilder<String>(
|
||||
// valueListenable: passwordNotifier,
|
||||
// builder: (context, password, child) {
|
||||
// return ButtonWidget(
|
||||
// text: password.isNotEmpty ? 'Login' : 'Required password',
|
||||
// onPressed: password.isNotEmpty ? _login : _ignoreButton,
|
||||
// disabled: password.isEmpty,
|
||||
// );
|
||||
// },
|
||||
// ),
|
||||
],
|
||||
),
|
||||
),
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue