reset password dialog + bug fix
This commit is contained in:
parent
643b499a95
commit
0a99267d60
|
|
@ -3,7 +3,7 @@ name: app-test
|
||||||
spec:
|
spec:
|
||||||
allow_http: false
|
allow_http: false
|
||||||
disable_default_domains: true
|
disable_default_domains: true
|
||||||
image: app:1.1.3
|
image: app:1.1.4
|
||||||
image_pull_policy: IfNotPresent
|
image_pull_policy: IfNotPresent
|
||||||
path: /
|
path: /
|
||||||
replicas: 1
|
replicas: 1
|
||||||
|
|
|
||||||
|
|
@ -24,13 +24,16 @@ class UserProvider extends CoreProvier {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
Future<void> getUserInfo() async {
|
Future<bool> getUserInfo() async {
|
||||||
isAuthenticated = true;
|
isAuthenticated = true;
|
||||||
final RequestService service = RequestService(RequestHelper.userInfo);
|
final RequestService service = RequestService(RequestHelper.userInfo);
|
||||||
await service.httpGet();
|
await service.httpGet();
|
||||||
if (service.isSuccess) {
|
if (service.isSuccess) {
|
||||||
user = User.fromJson(service.result['user']);
|
user = User.fromJson(service.result['user']);
|
||||||
return;
|
return true;
|
||||||
|
}
|
||||||
|
if (service.statusCode == 401) {
|
||||||
|
return false;
|
||||||
}
|
}
|
||||||
throw 'Getting user from API failed!';
|
throw 'Getting user from API failed!';
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -5,6 +5,7 @@ import 'package:http_parser/http_parser.dart' as parser;
|
||||||
|
|
||||||
class RequestService {
|
class RequestService {
|
||||||
static late String token;
|
static late String token;
|
||||||
|
int? statusCode;
|
||||||
|
|
||||||
Map<String, dynamic> get result => _body?['result'] ?? const {};
|
Map<String, dynamic> get result => _body?['result'] ?? const {};
|
||||||
Map<String, dynamic> get errors => _body?['errors'] ?? const {};
|
Map<String, dynamic> get errors => _body?['errors'] ?? const {};
|
||||||
|
|
@ -162,6 +163,7 @@ class RequestService {
|
||||||
}
|
}
|
||||||
|
|
||||||
void _handleResponse(http.Response? response) {
|
void _handleResponse(http.Response? response) {
|
||||||
|
statusCode = response?.statusCode;
|
||||||
if (_handleError(response)) {
|
if (_handleError(response)) {
|
||||||
if (response!.body.isNotEmpty) {
|
if (response!.body.isNotEmpty) {
|
||||||
_body = json.decode(response.body);
|
_body = json.decode(response.body);
|
||||||
|
|
|
||||||
|
|
@ -1,8 +1,10 @@
|
||||||
import 'dart:developer';
|
import 'dart:developer';
|
||||||
|
|
||||||
|
import 'package:didvan/models/view/action_sheet_data.dart';
|
||||||
import 'package:didvan/providers/server_data_provider.dart';
|
import 'package:didvan/providers/server_data_provider.dart';
|
||||||
import 'package:didvan/providers/user_provider.dart';
|
import 'package:didvan/providers/user_provider.dart';
|
||||||
import 'package:didvan/routes/routes.dart';
|
import 'package:didvan/routes/routes.dart';
|
||||||
|
import 'package:didvan/utils/action_sheet.dart';
|
||||||
import 'package:didvan/views/authentication/authentication_state.dart';
|
import 'package:didvan/views/authentication/authentication_state.dart';
|
||||||
import 'package:didvan/views/authentication/widgets/authentication_layout.dart';
|
import 'package:didvan/views/authentication/widgets/authentication_layout.dart';
|
||||||
import 'package:didvan/views/widgets/didvan/button.dart';
|
import 'package:didvan/views/widgets/didvan/button.dart';
|
||||||
|
|
@ -76,6 +78,25 @@ class _PasswordInputState extends State<PasswordInput> {
|
||||||
log(token);
|
log(token);
|
||||||
await ServerDataProvider.getData();
|
await ServerDataProvider.getData();
|
||||||
Navigator.of(context).pushReplacementNamed(Routes.home);
|
Navigator.of(context).pushReplacementNamed(Routes.home);
|
||||||
|
_showResetPasswordDialog();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void _showResetPasswordDialog() {
|
||||||
|
ActionSheetUtils.openDialog(
|
||||||
|
data: ActionSheetData(
|
||||||
|
content: const DidvanText(
|
||||||
|
'خوش آمدید!\nبرای امنیت بیشتر، رمز عبور خود را تغییر دهید.',
|
||||||
|
),
|
||||||
|
title: 'تغییر رمز عبور',
|
||||||
|
onConfirmed: () => Navigator.of(ActionSheetUtils.context).pushNamed(
|
||||||
|
Routes.authenticaion,
|
||||||
|
arguments: true,
|
||||||
|
),
|
||||||
|
confrimTitle: 'تغییر رمز عبور',
|
||||||
|
onDismissed: Navigator.of(ActionSheetUtils.context).pop,
|
||||||
|
dismissTitle: 'بعدا',
|
||||||
|
),
|
||||||
|
);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -87,7 +87,7 @@ class Settings extends StatelessWidget {
|
||||||
MenuItem(
|
MenuItem(
|
||||||
icon: DidvanIcons.didvan_solid,
|
icon: DidvanIcons.didvan_solid,
|
||||||
title: 'معرفی دیدوان',
|
title: 'معرفی دیدوان',
|
||||||
onTap: () => Navigator.of(context).pushNamed(Routes.aboutUs),
|
onTap: () => launch('https://didvan.app/'),
|
||||||
),
|
),
|
||||||
const DidvanDivider(),
|
const DidvanDivider(),
|
||||||
MenuItem(
|
MenuItem(
|
||||||
|
|
@ -101,14 +101,14 @@ class Settings extends StatelessWidget {
|
||||||
MenuItem(
|
MenuItem(
|
||||||
icon: DidvanIcons.alert_regular,
|
icon: DidvanIcons.alert_regular,
|
||||||
title: 'حریم خصوصی',
|
title: 'حریم خصوصی',
|
||||||
onTap: () => {},
|
onTap: () => launch('https://didvan.app/'),
|
||||||
),
|
),
|
||||||
],
|
],
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
const SizedBox(height: 16),
|
const SizedBox(height: 16),
|
||||||
DidvanText(
|
DidvanText(
|
||||||
'نسخه نرمافزار: آزمایشی',
|
'نسخه نرمافزار: 1.1.4',
|
||||||
style: Theme.of(context).textTheme.caption,
|
style: Theme.of(context).textTheme.caption,
|
||||||
),
|
),
|
||||||
],
|
],
|
||||||
|
|
|
||||||
|
|
@ -110,7 +110,15 @@ class _SplashState extends State<Splash> {
|
||||||
if (token != null) {
|
if (token != null) {
|
||||||
log(token);
|
log(token);
|
||||||
RequestService.token = token;
|
RequestService.token = token;
|
||||||
await userProvider.getUserInfo();
|
final result = await userProvider.getUserInfo();
|
||||||
|
if (!result) {
|
||||||
|
StorageService.delete(key: 'token');
|
||||||
|
Navigator.of(context).pushNamedAndRemoveUntil(
|
||||||
|
Routes.splash,
|
||||||
|
(_) => false,
|
||||||
|
);
|
||||||
|
return;
|
||||||
|
}
|
||||||
await ServerDataProvider.getData();
|
await ServerDataProvider.getData();
|
||||||
}
|
}
|
||||||
Navigator.of(context).pushReplacementNamed(
|
Navigator.of(context).pushReplacementNamed(
|
||||||
|
|
|
||||||
|
|
@ -15,7 +15,7 @@ publish_to: 'none' # Remove this line if you wish to publish to pub.dev
|
||||||
# In iOS, build-name is used as CFBundleShortVersionString while build-number used as CFBundleVersion.
|
# In iOS, build-name is used as CFBundleShortVersionString while build-number used as CFBundleVersion.
|
||||||
# Read more about iOS versioning at
|
# Read more about iOS versioning at
|
||||||
# https://developer.apple.com/library/archive/documentation/General/Reference/InfoPlistKeyReference/Articles/CoreFoundationKeys.html
|
# https://developer.apple.com/library/archive/documentation/General/Reference/InfoPlistKeyReference/Articles/CoreFoundationKeys.html
|
||||||
version: 1.1.3+3
|
version: 1.1.4+4
|
||||||
|
|
||||||
environment:
|
environment:
|
||||||
sdk: ">=2.12.0 <3.0.0"
|
sdk: ">=2.12.0 <3.0.0"
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue