Update pages
This commit is contained in:
parent
3709e06ed6
commit
4a522a38d9
2 changed files with 58 additions and 15 deletions
|
|
@ -1,5 +1,10 @@
|
|||
import 'dart:developer';
|
||||
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:flutter_dotenv/flutter_dotenv.dart';
|
||||
import 'package:gap/gap.dart';
|
||||
import 'package:hashlib/hashlib.dart';
|
||||
import 'package:ocbo_esign_validator/functions/get_api.dart';
|
||||
import 'package:ocbo_esign_validator/widgets/box_widget.dart';
|
||||
import 'package:ocbo_esign_validator/widgets/button_widget.dart';
|
||||
import 'package:ocbo_esign_validator/widgets/image_widget.dart';
|
||||
|
|
@ -15,7 +20,8 @@ class LoginPage extends StatefulWidget {
|
|||
|
||||
class _LoginPageState extends State<LoginPage> {
|
||||
final _passwordController = TextEditingController();
|
||||
final _approver = "ARCH. KHASHAYAR L. TOGHYANI";
|
||||
final _approver = dotenv.env['HEAD']!;
|
||||
final _approverId = dotenv.env['HEADID']!;
|
||||
late ValueNotifier<String> passwordNotifier;
|
||||
|
||||
@override
|
||||
|
|
@ -27,8 +33,45 @@ class _LoginPageState extends State<LoginPage> {
|
|||
});
|
||||
}
|
||||
|
||||
void _login() {
|
||||
debugPrint("Login button clicked");
|
||||
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> _securePassword(String password) async {
|
||||
final firstHash = sha1.string(password);
|
||||
final secondHash = sha384.string(firstHash.toString());
|
||||
final thirdHash = sha1.string(secondHash.toString());
|
||||
|
||||
return thirdHash.toString();
|
||||
}
|
||||
|
||||
void _login() async {
|
||||
final connected = await _checkConnection();
|
||||
|
||||
if (connected) {
|
||||
final employeeid = _approverId;
|
||||
final dbpassword = await _getPassword(employeeid);
|
||||
final hashPassword = await _securePassword(_passwordController.text);
|
||||
if (dbpassword == hashPassword) {
|
||||
log('yeah');
|
||||
} else {
|
||||
log('no');
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void _ignoreButton() {}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue