Change PasswordIntegration #1

This commit is contained in:
2025-09-09 12:34:45 +05:30
parent b62b8a157d
commit b3fb387bdd
10 changed files with 72 additions and 42 deletions

View File

@@ -10,6 +10,7 @@
analyzer: analyzer:
errors: errors:
dead_code: ignore dead_code: ignore
non_constant_identifier_names: ignore
include: package:flutter_lints/flutter.yaml include: package:flutter_lints/flutter.yaml
linter: linter:

View File

@@ -0,0 +1,59 @@
import 'package:dio/dio.dart';
class ChangePasswordService {
final Dio _dio;
ChangePasswordService(this._dio);
Future getOtp({
required String mobileNumber,
}) async {
final response = await _dio.post(
'/api/otp/send',
queryParameters: {
'mobileNumber': mobileNumber,
'type': "CHANGE_LPWORD"
},
);
if (response.statusCode != 200) {
throw Exception("Invalid Mobile Number/Type");
}
return response.toString();
}
Future validateOtp({
required String otp,
required String mobileNumber,
}) async {
final response = await _dio.post(
'/api/otp/verify?mobileNumber=$mobileNumber',
queryParameters: {
'otp' : otp,
},
);
if (response.statusCode != 200) {
throw Exception("Wrong OTP");
}
return response.toString();
}
Future validateChangePwd({
required String OldLPsw,
required String newLPsw,
required String confirmLPsw,
}) async {
final response = await _dio.post(
'/api/auth/change/login_password',
queryParameters: {
'OldLPsw': OldLPsw,
'newLPsw': newLPsw,
'confirmLPsw': confirmLPsw,
},
);
if (response.statusCode != 200) {
throw Exception("Wrong OTP");
}
return response.toString();
}
}

View File

@@ -1,16 +0,0 @@
class Otp {
final String mobileNumber;
final String type;
Otp({
required this.mobileNumber,
required this.type,
});
Map<String, dynamic> toJson() {
return {
'mobileNumber': mobileNumber,
'type': type,
};
}
}

View File

@@ -1,14 +0,0 @@
class OtpVerify{
final String otp;
OtpVerify({
required this.otp,
}
);
Map<String, dynamic> toJson() {
return {
'otp': otp,
};
}
}

View File

@@ -1,4 +1,4 @@
import 'dart:developer';
import 'package:dio/dio.dart'; import 'package:dio/dio.dart';
import 'package:intl/intl.dart'; import 'package:intl/intl.dart';

View File

@@ -72,7 +72,7 @@ class _ChangePasswordScreenState extends State<ChangePasswordScreen> {
@override @override
Widget build(BuildContext context) { Widget build(BuildContext context) {
return Scaffold( return Scaffold(
appBar: AppBar(title: Text(AppLocalizations.of(context).changePassword)), appBar: AppBar(title: Text(AppLocalizations.of(context).changeLoginPassword)),
body: Padding( body: Padding(
padding: const EdgeInsets.all(16), padding: const EdgeInsets.all(16),
child: Form( child: Form(

View File

@@ -43,7 +43,7 @@ class ProfileScreen extends StatelessWidget {
), ),
ListTile( ListTile(
leading: const Icon(Icons.password), leading: const Icon(Icons.password),
title: Text(loc.changePassword), title: Text(loc.changeLoginPassword),
onTap: () { onTap: () {
Navigator.push( Navigator.push(
context, context,

View File

@@ -292,5 +292,5 @@
"viewCardDeatils": "View Card Details", "viewCardDeatils": "View Card Details",
"logout": "Logout", "logout": "Logout",
"logoutCheck": "Are you sure you want to logout?", "logoutCheck": "Are you sure you want to logout?",
"changePassword": "Change Password" "changeLoginPassword": "Change Login Password"
} }

View File

@@ -293,5 +293,5 @@
"viewCardDeatils": "कार्ड विवरण देखें", "viewCardDeatils": "कार्ड विवरण देखें",
"logout": "लॉग आउट", "logout": "लॉग आउट",
"logoutCheck": "क्या आप लॉग आउट करना चाहते हैं?", "logoutCheck": "क्या आप लॉग आउट करना चाहते हैं?",
"changePassword": "पासवर्ड बदलें" "changeLoginPassword": "लॉगिन पासवर्ड बदलें"
} }

View File

@@ -17,13 +17,13 @@ void main() async {
]); ]);
// Check for device compromise // Check for device compromise
final compromisedMessage = await SecurityService.deviceCompromisedMessage; // final compromisedMessage = await SecurityService.deviceCompromisedMessage;
if (compromisedMessage != null) { // if (compromisedMessage != null) {
runApp(MaterialApp( // runApp(MaterialApp(
home: SecurityErrorScreen(message: compromisedMessage), // home: SecurityErrorScreen(message: compromisedMessage),
)); // ));
return; // return;
} // }
// Initialize dependencies // Initialize dependencies
await setupDependencies(); await setupDependencies();