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() {}
|
||||
|
|
|
|||
|
|
@ -43,11 +43,20 @@ class _BarcodeScannerScreenState extends State<BarcodeScannerScreen> {
|
|||
),
|
||||
child: Center(
|
||||
child: Padding(
|
||||
padding: const EdgeInsets.only(top: 64, left: 16, right: 16),
|
||||
padding: const EdgeInsets.only(top: 88, left: 16, right: 16),
|
||||
child: Column(
|
||||
children: [
|
||||
Expanded(
|
||||
flex: 2,
|
||||
Container(
|
||||
padding: EdgeInsets.only(top: 8, bottom: 8, left: 20, right: 20),
|
||||
decoration: BoxDecoration(
|
||||
color: Color.fromARGB(149, 16, 22, 28),
|
||||
borderRadius: BorderRadius.circular(8),
|
||||
),
|
||||
child: TextWidget(text: 'Scan OCBO e-Sign QR Code', size: 14, bold: true),
|
||||
),
|
||||
Gap(50),
|
||||
SizedBox(
|
||||
height: 350,
|
||||
child: ClipRRect(
|
||||
borderRadius: BorderRadius.circular(20), // Adjust the radius as needed
|
||||
child: MobileScanner(
|
||||
|
|
@ -63,15 +72,6 @@ class _BarcodeScannerScreenState extends State<BarcodeScannerScreen> {
|
|||
),
|
||||
),
|
||||
),
|
||||
Expanded(
|
||||
flex: 2,
|
||||
child: Column(
|
||||
children: [
|
||||
Gap(20),
|
||||
TextWidget(text: 'Scan OCBO e-Sign QR', size: 20, bold: true),
|
||||
],
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue