fix logout issue
This commit is contained in:
@@ -4,7 +4,6 @@ import 'package:fcs/pages/widgets/display_text.dart';
|
||||
import 'package:fcs/pages/widgets/fcs_id_icon.dart';
|
||||
import 'package:fcs/pages/widgets/local_app_bar.dart';
|
||||
import 'package:fcs/pages/widgets/local_text.dart';
|
||||
import 'package:flutter/cupertino.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:provider/provider.dart';
|
||||
|
||||
|
||||
@@ -77,7 +77,7 @@ class _CustomerListState extends State<CustomerList> {
|
||||
children: <Widget>[
|
||||
Expanded(
|
||||
child: new Padding(
|
||||
padding: const EdgeInsets.symmetric(vertical: 5.0),
|
||||
padding: const EdgeInsets.symmetric(vertical: 8.0),
|
||||
child: new Row(
|
||||
children: <Widget>[
|
||||
InkWell(
|
||||
|
||||
@@ -1,5 +1,3 @@
|
||||
import 'dart:ui';
|
||||
|
||||
import 'package:country_code_picker/country_code_picker.dart';
|
||||
import 'package:fcs/helpers/theme.dart';
|
||||
import 'package:fcs/pages/customer/model/customer_model.dart';
|
||||
|
||||
@@ -2,7 +2,6 @@ import 'package:fcs/domain/entities/shipment.dart';
|
||||
import 'package:fcs/helpers/theme.dart';
|
||||
import 'package:fcs/pages/widgets/local_app_bar.dart';
|
||||
import 'package:fcs/pages/widgets/local_text.dart';
|
||||
import 'package:flutter/cupertino.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
|
||||
typedef OnAdd(Shipment shipment);
|
||||
|
||||
@@ -10,7 +10,7 @@ abstract class BaseModel extends ChangeNotifier {
|
||||
Setting? setting;
|
||||
MainModel? mainModel;
|
||||
|
||||
void initUser(User user) async {
|
||||
void initUser(User? user) async {
|
||||
this.user = user;
|
||||
}
|
||||
|
||||
|
||||
@@ -87,23 +87,6 @@ class MainModel extends ChangeNotifier {
|
||||
userListener?.cancel();
|
||||
userListener =
|
||||
Services.instance.authService.getUserStream().listen((_user) {
|
||||
// if (_user != null) {
|
||||
// models.forEach((m) => m.initUser(_user));
|
||||
// // call diffPrivileges if privilege changed or first time login
|
||||
// if (this.user == null || _user.diffPrivileges(this.user!)) {
|
||||
// models.forEach((m) => m.privilegeChanged());
|
||||
// }
|
||||
// if (this.user == null) {
|
||||
// uploadMsgToken();
|
||||
// }
|
||||
// } else {
|
||||
// if (this.user != null) {
|
||||
// models.forEach((m) => m.logout());
|
||||
// }
|
||||
// }
|
||||
// this.user = _user;
|
||||
// isLoaded = true;
|
||||
|
||||
bool isFirstTime = user == null && _user != null;
|
||||
bool diffPrivilege =
|
||||
_user != null && (user == null || user!.diffPrivileges(_user));
|
||||
@@ -163,24 +146,28 @@ class MainModel extends ChangeNotifier {
|
||||
}
|
||||
|
||||
Future<void> _uploadMsgToken() {
|
||||
log.info("messagingToken:$messagingToken::user:$user");
|
||||
if (messagingToken == null || user == null) return Future.value();
|
||||
if (messagingToken == null || user == null) return Future.value();
|
||||
return Services.instance.userService.uploadMsgToken(messagingToken!);
|
||||
}
|
||||
|
||||
Future<void> _removeMsgToken() {
|
||||
if (messagingToken == null || user == null) return Future.value();
|
||||
if (messagingToken == null || user == null) return Future.value();
|
||||
return Services.instance.userService.removeMsgToken(messagingToken!);
|
||||
}
|
||||
|
||||
Future<void> signout() async {
|
||||
try {
|
||||
await Services.instance.authService.signoutStart();
|
||||
await _removeMsgToken();
|
||||
for (var i = 0; i < models.length; i++) {
|
||||
models[i].initUser(null);
|
||||
models[i].logout();
|
||||
}
|
||||
|
||||
await Services.instance.authService.signoutEnd();
|
||||
} catch (e) {
|
||||
log.info(e.toString());
|
||||
log.info("signout:${e.toString()}");
|
||||
}
|
||||
await Services.instance.authService.signout();
|
||||
models.forEach((m) => m.logout());
|
||||
}
|
||||
|
||||
Future<bool> hasInvite() async {
|
||||
|
||||
@@ -10,7 +10,6 @@ import 'package:fcs/pages/widgets/local_app_bar.dart';
|
||||
import 'package:fcs/pages/widgets/local_dropdown.dart';
|
||||
import 'package:fcs/pages/widgets/local_text.dart';
|
||||
import 'package:fcs/pages/widgets/progress.dart';
|
||||
import 'package:flutter/cupertino.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:flutter_icons_null_safety/flutter_icons_null_safety.dart';
|
||||
import 'package:provider/provider.dart';
|
||||
|
||||
@@ -81,7 +81,7 @@ class StaffModel extends BaseModel {
|
||||
Future<void> updatePin(
|
||||
{required String userID,
|
||||
required bool enablePin,
|
||||
required int pin}) async {
|
||||
required int? pin}) async {
|
||||
// await request("/employee/pin", "PUT",
|
||||
// payload: {
|
||||
// "id": userID,
|
||||
|
||||
@@ -39,7 +39,7 @@ class _StaffPinEditorState extends State<StaffPinEditor> {
|
||||
_staff = widget.staff;
|
||||
_enablePinLogin = _staff.enablePinLogin;
|
||||
_newPin = _staff.pinDigit ?? "";
|
||||
_confirmPin = _staff.confirmPinDigit ?? "";
|
||||
_confirmPin = _staff.pinDigit ?? "";
|
||||
_newPinCtl.text = _newPin;
|
||||
_confirmPinCtl.text = _confirmPin;
|
||||
_checkFocusNode();
|
||||
@@ -298,7 +298,9 @@ class _StaffPinEditorState extends State<StaffPinEditor> {
|
||||
}
|
||||
|
||||
_save() async {
|
||||
if (!_formKey.currentState!.validate()) return;
|
||||
if (_enablePinLogin) {
|
||||
if (!_formKey.currentState!.validate()) return;
|
||||
}
|
||||
|
||||
setState(() {
|
||||
_isLoading = true;
|
||||
@@ -308,7 +310,7 @@ class _StaffPinEditorState extends State<StaffPinEditor> {
|
||||
await context.read<StaffModel>().updatePin(
|
||||
userID: _staff.id!,
|
||||
enablePin: _enablePinLogin,
|
||||
pin: int.parse(_confirmPin));
|
||||
pin: _enablePinLogin ? int.parse(_confirmPin) : null);
|
||||
Navigator.pop(context, true);
|
||||
} catch (e) {
|
||||
showMsgDialog(context, "Error", e.toString());
|
||||
|
||||
@@ -1,5 +1,4 @@
|
||||
import 'package:fcs/helpers/theme.dart';
|
||||
import 'package:flutter/cupertino.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
|
||||
import 'callbacks.dart';
|
||||
|
||||
@@ -1,6 +1,5 @@
|
||||
import 'dart:io';
|
||||
|
||||
import 'package:flutter/cupertino.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
|
||||
import 'show_img.dart';
|
||||
|
||||
@@ -1,7 +1,6 @@
|
||||
import 'package:fcs/helpers/theme.dart';
|
||||
import 'package:fcs/localization/app_translations.dart';
|
||||
import 'package:fcs/pages/main/model/language_model.dart';
|
||||
import 'package:flutter/cupertino.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:intl/intl.dart';
|
||||
import 'package:provider/provider.dart';
|
||||
|
||||
@@ -1,7 +1,6 @@
|
||||
import 'dart:io';
|
||||
|
||||
import 'package:fcs/helpers/theme.dart';
|
||||
import 'package:flutter/cupertino.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:photo_view/photo_view.dart';
|
||||
|
||||
|
||||
Reference in New Issue
Block a user