diff --git a/.fandogh/fandogh.yaml b/.fandogh/fandogh.yaml index f3e17d1..fa91faa 100644 --- a/.fandogh/fandogh.yaml +++ b/.fandogh/fandogh.yaml @@ -3,7 +3,7 @@ name: app-test spec: allow_http: false disable_default_domains: true - image: app:1.1.3 + image: app:1.1.4 image_pull_policy: IfNotPresent path: / replicas: 1 diff --git a/lib/providers/user_provider.dart b/lib/providers/user_provider.dart index 65aeacf..f53d0ac 100644 --- a/lib/providers/user_provider.dart +++ b/lib/providers/user_provider.dart @@ -24,13 +24,16 @@ class UserProvider extends CoreProvier { return null; } - Future getUserInfo() async { + Future getUserInfo() async { isAuthenticated = true; final RequestService service = RequestService(RequestHelper.userInfo); await service.httpGet(); if (service.isSuccess) { user = User.fromJson(service.result['user']); - return; + return true; + } + if (service.statusCode == 401) { + return false; } throw 'Getting user from API failed!'; } diff --git a/lib/services/network/request.dart b/lib/services/network/request.dart index 1614cbc..67ac373 100644 --- a/lib/services/network/request.dart +++ b/lib/services/network/request.dart @@ -5,6 +5,7 @@ import 'package:http_parser/http_parser.dart' as parser; class RequestService { static late String token; + int? statusCode; Map get result => _body?['result'] ?? const {}; Map get errors => _body?['errors'] ?? const {}; @@ -162,6 +163,7 @@ class RequestService { } void _handleResponse(http.Response? response) { + statusCode = response?.statusCode; if (_handleError(response)) { if (response!.body.isNotEmpty) { _body = json.decode(response.body); diff --git a/lib/views/authentication/screens/password.dart b/lib/views/authentication/screens/password.dart index 391556b..69cdc42 100644 --- a/lib/views/authentication/screens/password.dart +++ b/lib/views/authentication/screens/password.dart @@ -1,8 +1,10 @@ import 'dart:developer'; +import 'package:didvan/models/view/action_sheet_data.dart'; import 'package:didvan/providers/server_data_provider.dart'; import 'package:didvan/providers/user_provider.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/widgets/authentication_layout.dart'; import 'package:didvan/views/widgets/didvan/button.dart'; @@ -76,6 +78,25 @@ class _PasswordInputState extends State { log(token); await ServerDataProvider.getData(); 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: 'بعدا', + ), + ); + } } diff --git a/lib/views/home/settings/settings.dart b/lib/views/home/settings/settings.dart index 7753d26..63c4439 100644 --- a/lib/views/home/settings/settings.dart +++ b/lib/views/home/settings/settings.dart @@ -87,7 +87,7 @@ class Settings extends StatelessWidget { MenuItem( icon: DidvanIcons.didvan_solid, title: 'معرفی دیدوان', - onTap: () => Navigator.of(context).pushNamed(Routes.aboutUs), + onTap: () => launch('https://didvan.app/'), ), const DidvanDivider(), MenuItem( @@ -101,14 +101,14 @@ class Settings extends StatelessWidget { MenuItem( icon: DidvanIcons.alert_regular, title: 'حریم خصوصی', - onTap: () => {}, + onTap: () => launch('https://didvan.app/'), ), ], ), ), const SizedBox(height: 16), DidvanText( - 'نسخه نرم‌افزار: آزمایشی', + 'نسخه نرم‌افزار: 1.1.4', style: Theme.of(context).textTheme.caption, ), ], diff --git a/lib/views/splash/splash.dart b/lib/views/splash/splash.dart index c0d05cd..72e3b26 100644 --- a/lib/views/splash/splash.dart +++ b/lib/views/splash/splash.dart @@ -110,7 +110,15 @@ class _SplashState extends State { if (token != null) { log(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(); } Navigator.of(context).pushReplacementNamed( diff --git a/pubspec.yaml b/pubspec.yaml index 44c80b2..c685dfc 100644 --- a/pubspec.yaml +++ b/pubspec.yaml @@ -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. # Read more about iOS versioning at # https://developer.apple.com/library/archive/documentation/General/Reference/InfoPlistKeyReference/Articles/CoreFoundationKeys.html -version: 1.1.3+3 +version: 1.1.4+4 environment: sdk: ">=2.12.0 <3.0.0"