From faa8f310db8bb3ac7054d9d462465c233f4eae1e Mon Sep 17 00:00:00 2001 From: "mr.mojtaba" Date: Mon, 2 Jun 2025 10:30:19 +0330 Subject: [PATCH] fix : obscure password in auth --- .../lib/presentation/pages/auth/logic.dart | 4 +- .../lib/presentation/pages/auth/view.dart | 2 +- packages/auth/pubspec.yaml | 2 +- .../presentation/widget/inputs/r_input.dart | 48 +++++++------------ 4 files changed, 21 insertions(+), 35 deletions(-) diff --git a/packages/auth/lib/presentation/pages/auth/logic.dart b/packages/auth/lib/presentation/pages/auth/logic.dart index 37b2e2e..68fc5eb 100644 --- a/packages/auth/lib/presentation/pages/auth/logic.dart +++ b/packages/auth/lib/presentation/pages/auth/logic.dart @@ -24,7 +24,7 @@ class AuthLogic extends GetxController { Rx> formKeyOtp = GlobalKey().obs; Rx> formKeySentOtp = GlobalKey().obs; - Rx phoneNumberController = TextEditingController().obs; + Rx usernameController = TextEditingController().obs; Rx passwordController = TextEditingController().obs; Rx phoneOtpNumberController = TextEditingController().obs; @@ -95,7 +95,7 @@ class AuthLogic extends GetxController { } LoginRequestModel _buildLoginRequest() { - final phone = phoneNumberController.value.text; + final phone = usernameController.value.text; final pass = passwordController.value.text; final code = captchaController.textController.value.text; final key = captchaController.captchaKey.value; diff --git a/packages/auth/lib/presentation/pages/auth/view.dart b/packages/auth/lib/presentation/pages/auth/view.dart index 343c050..aae44e6 100644 --- a/packages/auth/lib/presentation/pages/auth/view.dart +++ b/packages/auth/lib/presentation/pages/auth/view.dart @@ -144,7 +144,7 @@ class AuthPage extends GetView { minWidth: 40, ), ), - controller.phoneNumberController, + controller.usernameController, ), const SizedBox(height: 26), ObxValue( diff --git a/packages/auth/pubspec.yaml b/packages/auth/pubspec.yaml index 11617ca..09c3e4f 100644 --- a/packages/auth/pubspec.yaml +++ b/packages/auth/pubspec.yaml @@ -1,6 +1,6 @@ name: rasadyar_auth description: "A new Flutter project." -version: 0.0.1 +version: 1.0.2 publish_to: 'none' diff --git a/packages/core/lib/presentation/widget/inputs/r_input.dart b/packages/core/lib/presentation/widget/inputs/r_input.dart index 2780b59..37ec8ff 100644 --- a/packages/core/lib/presentation/widget/inputs/r_input.dart +++ b/packages/core/lib/presentation/widget/inputs/r_input.dart @@ -2,12 +2,7 @@ import 'package:flutter/cupertino.dart'; import 'package:flutter/material.dart'; import 'package:rasadyar_core/core.dart'; -enum RTextFieldVariant { - normal, - noBorder, - password, - passwordNoBorder, -} +enum RTextFieldVariant { normal, noBorder, password, passwordNoBorder } class RTextField extends StatefulWidget { final TextEditingController controller; @@ -69,29 +64,21 @@ class RTextField extends StatefulWidget { this.onSubmitted, }); - @override State createState() => _RTextFieldState(); bool get _isPassword => variant == RTextFieldVariant.password; + bool get _noBorder => variant == RTextFieldVariant.noBorder; + bool get _passwordNoBorder => variant == RTextFieldVariant.passwordNoBorder; - - InputBorder get _inputBorder => - _noBorder || _passwordNoBorder ? InputBorder.none : OutlineInputBorder( - borderRadius: BorderRadius.circular(8), - borderSide: BorderSide( - color: AppColor.lightGreyDarkActive, - width: 1, - ), - ); - - - - - - + InputBorder get _inputBorder => _noBorder || _passwordNoBorder + ? InputBorder.none + : OutlineInputBorder( + borderRadius: BorderRadius.circular(8), + borderSide: BorderSide(color: AppColor.lightGreyDarkActive, width: 1), + ); } class _RTextFieldState extends State { @@ -103,7 +90,11 @@ class _RTextFieldState extends State { if (widget.initText != null) { widget.controller.text = widget.initText!; } - obscure = widget.obscure; + if (widget._isPassword) { + obscure = true; + } else { + obscure = widget.obscure; + } } @override @@ -126,10 +117,7 @@ class _RTextFieldState extends State { obscure = !obscure; }); }, - child: Icon( - obscure ? CupertinoIcons.eye : CupertinoIcons.eye_slash, - color: AppColor.darkGreyDarkActive, - ), + child: Icon(obscure ? CupertinoIcons.eye : CupertinoIcons.eye_slash, color: AppColor.darkGreyDarkActive), ), ); } @@ -165,9 +153,7 @@ class _RTextFieldState extends State { hintText: widget.hintText, labelText: widget.label, alignLabelWithHint: true, - labelStyle: AppFonts.yekan14 - .copyWith(color: AppColor.lightGreyDarkActive) - .merge(widget.labelStyle), + labelStyle: AppFonts.yekan14.copyWith(color: AppColor.lightGreyDarkActive).merge(widget.labelStyle), filled: widget.filled || widget._noBorder || widget._passwordNoBorder, fillColor: widget.filledColor, counter: widget.showCounter ? null : const SizedBox(), @@ -179,4 +165,4 @@ class _RTextFieldState extends State { ), ); } -} \ No newline at end of file +}