import 'package:diplomaticquarterapp/config/shared_pref_kay.dart';
import 'package:diplomaticquarterapp/models/Authentication/authenticated_user.dart';
import 'package:diplomaticquarterapp/uitl/app_shared_preferences.dart';

class AuthenticatedUserObject {
  AuthenticatedUser user;
  AppSharedPreferences sharedPref = AppSharedPreferences();
  bool isLogin = false;

  AuthenticatedUserObject() {
    getUser();
  }

  getUser({bool getUser = false}) async {
    if (getUser) {
      var userData = await sharedPref.getObject(USER_PROFILE);
      if (userData != null) user = AuthenticatedUser.fromJson(userData);
    } else if (user == null) {
      var userData = await sharedPref.getObject(USER_PROFILE);
      if (userData != null) user = AuthenticatedUser.fromJson(userData);
    }
  }

  logout() async {
    isLogin = false;
  }
}
