Forget Password issue fixed

fatima
devmirza121 4 years ago
parent 47f10738d7
commit 44475599da

@ -1,5 +1,5 @@
buildscript { buildscript {
ext.kotlin_version = '1.3.50' ext.kotlin_version = '1.6.10'
repositories { repositories {
google() google()
mavenCentral() mavenCentral()

@ -13,6 +13,8 @@ import 'package:car_provider_app/models/surah_model.dart';
import 'package:car_provider_app/models/user/basic_otp.dart'; import 'package:car_provider_app/models/user/basic_otp.dart';
import 'package:car_provider_app/models/user/register_user.dart'; import 'package:car_provider_app/models/user/register_user.dart';
import '../../classes/app_state.dart';
import '../../models/m_response.dart';
import '../api_client.dart'; import '../api_client.dart';
@ -107,12 +109,16 @@ class UserApiClent {
//return await ApiClient().postJsonForObject((json) => ConfirmPassword.fromJson(json), ApiConsts.ForgetPassword, postParams); //return await ApiClient().postJsonForObject((json) => ConfirmPassword.fromJson(json), ApiConsts.ForgetPassword, postParams);
} }
Future<Response> ChangePassword(String currentPasswor, String newPassword) async { Future<MResponse> ChangePassword(String currentPasswor, String newPassword) async {
var postParams = { var postParams = {
"currentPasswor": currentPasswor, "currentPassword": currentPasswor,
"newPassword": newPassword, "newPassword": newPassword,
}; };
return await ApiClient().postJsonForResponse(ApiConsts.ChangePassword, postParams); // return await ApiClient().postJsonForResponse(ApiConsts.ChangePassword, postParams);
String t = AppState().getUser.data!.accessToken ?? "";
print("tokeen " + t);
return await ApiClient().postJsonForObject((json) => MResponse.fromJson(json), ApiConsts.ChangePassword, postParams, token: t);
} }

@ -66,7 +66,7 @@ class AppRoutes {
defineLicense: (context) => DefineLicensePage(), defineLicense: (context) => DefineLicensePage(),
vertifyPassword: (context) => VerifyPasswordPage(), vertifyPassword: (context) => VerifyPasswordPage(),
confirmNewPasswordPage: (context) => ConfirmNewPasswordPage(ModalRoute.of(context)!.settings.arguments as String), confirmNewPasswordPage: (context) => ConfirmNewPasswordPage(ModalRoute.of(context)!.settings.arguments as String),
changePassword: (context) => ChangePasswordPage(ModalRoute.of(context)!.settings.arguments as String), changePassword: (context) => ChangePasswordPage(),
//Home page //Home page
dashboard: (context) => DashboardPage(), dashboard: (context) => DashboardPage(),

@ -18,10 +18,10 @@ import 'package:flutter/material.dart';
import 'dart:convert'; import 'dart:convert';
import 'package:http/http.dart'; import 'package:http/http.dart';
class ChangePasswordPage extends StatefulWidget { import '../../models/m_response.dart';
String userToken;
ChangePasswordPage(this.userToken, {Key? key}) : super(key: key); class ChangePasswordPage extends StatefulWidget {
ChangePasswordPage({Key? key}) : super(key: key);
@override @override
State<ChangePasswordPage> createState() => _ChangePasswordPageState(); State<ChangePasswordPage> createState() => _ChangePasswordPageState();
@ -48,7 +48,7 @@ class _ChangePasswordPageState extends State<ChangePasswordPage> {
decoration: InputDecoration( decoration: InputDecoration(
hintText: "Enter Old Password", hintText: "Enter Old Password",
hintStyle: TextStyle(color: Colors.grey), hintStyle: TextStyle(color: Colors.grey),
border: OutlineInputBorder( border: OutlineInputBorder(
borderRadius: const BorderRadius.all( borderRadius: const BorderRadius.all(
const Radius.circular(5.0), const Radius.circular(5.0),
), ),
@ -62,7 +62,7 @@ class _ChangePasswordPageState extends State<ChangePasswordPage> {
decoration: InputDecoration( decoration: InputDecoration(
hintText: "Inter New Password", hintText: "Inter New Password",
hintStyle: TextStyle(color: Colors.grey), hintStyle: TextStyle(color: Colors.grey),
border: OutlineInputBorder( border: OutlineInputBorder(
borderRadius: const BorderRadius.all( borderRadius: const BorderRadius.all(
const Radius.circular(5.0), const Radius.circular(5.0),
), ),
@ -75,7 +75,8 @@ class _ChangePasswordPageState extends State<ChangePasswordPage> {
ShowFillButton( ShowFillButton(
title: "Confirm", title: "Confirm",
width: double.infinity, width: double.infinity,
onPressed: () {changePassword(context); onPressed: () {
changePassword(context);
}, },
), ),
], ],
@ -86,25 +87,25 @@ class _ChangePasswordPageState extends State<ChangePasswordPage> {
} }
Future<void> changePassword(BuildContext context) async { Future<void> changePassword(BuildContext context) async {
if(validateStructure(newPassword??"")){ if (validateStructure(newPassword ?? "")) {
Utils.showLoading(context); Utils.showLoading(context);
Response res = await UserApiClent().ChangePassword(currentPasswor, newPassword); MResponse res = await UserApiClent().ChangePassword(currentPasswor, newPassword);
Utils.hideLoading(context); Utils.hideLoading(context);
ChangePassword data = ChangePassword.fromJson(jsonDecode(res.body)); if (res.messageStatus == 1) {
if (data.messageStatus == 1) {
Utils.showToast("Password is Updated"); Utils.showToast("Password is Updated");
navigateWithName(context, AppRoutes.loginWithPassword); // navigateWithName(context, AppRoutes.loginWithPassword);
Navigator.of(context)
.pushNamedAndRemoveUntil(AppRoutes.loginWithPassword, (Route<dynamic> route) => false);
} else { } else {
Utils.showToast(data.message ?? ""); Utils.showToast(res.message ?? "");
} }
}else{ } else {
Utils.showToast("Password Should contains Character, Number, Capital and small letters"); Utils.showToast("Password Should contains Character, Number, Capital and small letters");
} }
} }
bool validateStructure(String value) {
bool validateStructure(String value){ String pattern = r'^(?=.*?[A-Z])(?=.*?[a-z])(?=.*?[0-9])(?=.*?[!@#\$&*~]).{6,}$';
String pattern = r'^(?=.*?[A-Z])(?=.*?[a-z])(?=.*?[0-9])(?=.*?[!@#\$&*~]).{6,}$';
RegExp regExp = new RegExp(pattern); RegExp regExp = new RegExp(pattern);
return regExp.hasMatch(value); return regExp.hasMatch(value);
} }

@ -43,7 +43,7 @@ class _CompleteProfilePageState extends State<CompleteProfilePage> {
height: double.infinity, height: double.infinity,
child: SingleChildScrollView( child: SingleChildScrollView(
child: Padding( child: Padding(
padding: EdgeInsets.all(40), padding: EdgeInsets.all(20),
child: Column( child: Column(
children: [ children: [
"Complete Profile".toText24(), "Complete Profile".toText24(),

@ -301,6 +301,13 @@ packages:
url: "https://pub.dartlang.org" url: "https://pub.dartlang.org"
source: hosted source: hosted
version: "0.12.11" version: "0.12.11"
material_color_utilities:
dependency: transitive
description:
name: material_color_utilities
url: "https://pub.dartlang.org"
source: hosted
version: "0.1.3"
meta: meta:
dependency: transitive dependency: transitive
description: description:
@ -571,7 +578,7 @@ packages:
name: test_api name: test_api
url: "https://pub.dartlang.org" url: "https://pub.dartlang.org"
source: hosted source: hosted
version: "0.4.3" version: "0.4.8"
typed_data: typed_data:
dependency: transitive dependency: transitive
description: description:

Loading…
Cancel
Save