Compare commits
No commits in common. "a1484c6d4fccff0c76cdf80827095ddb18b46611" and "7fadc0c64dbb6e38b2461aea99a9a744e8b45d71" have entirely different histories.
a1484c6d4f
...
7fadc0c64d
|
@ -2,7 +2,7 @@ import 'package:shared_preferences/shared_preferences.dart';
|
||||||
|
|
||||||
class SessionManager {
|
class SessionManager {
|
||||||
static final SessionManager _instance = SessionManager._();
|
static final SessionManager _instance = SessionManager._();
|
||||||
static const String _loggedInKey = 'isloggedin';
|
static const String _loggedInKey = 'loggedIn';
|
||||||
|
|
||||||
factory SessionManager() {
|
factory SessionManager() {
|
||||||
return _instance;
|
return _instance;
|
||||||
|
@ -27,10 +27,6 @@ class SessionManager {
|
||||||
|
|
||||||
Future<void> logoutSession(bool value) async {
|
Future<void> logoutSession(bool value) async {
|
||||||
final prefs = await SharedPreferences.getInstance();
|
final prefs = await SharedPreferences.getInstance();
|
||||||
//secretkey
|
|
||||||
|
|
||||||
await prefs.setBool("isloggedin", value);
|
await prefs.setBool("isloggedin", value);
|
||||||
await prefs.setBool("isloggedout", true);
|
|
||||||
await prefs.setBool(_loggedInKey, value);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -38,7 +38,6 @@ class _LoginScreenState extends State<LoginScreen> {
|
||||||
late Future<String> _domain;
|
late Future<String> _domain;
|
||||||
late Future<String> _key;
|
late Future<String> _key;
|
||||||
late Future<bool> _login;
|
late Future<bool> _login;
|
||||||
late Future<bool> _logout;
|
|
||||||
String platform = "android";
|
String platform = "android";
|
||||||
var provider;
|
var provider;
|
||||||
@override
|
@override
|
||||||
|
@ -64,16 +63,13 @@ class _LoginScreenState extends State<LoginScreen> {
|
||||||
// _domain = _prefs.then((SharedPreferences prefs) {
|
// _domain = _prefs.then((SharedPreferences prefs) {
|
||||||
// return prefs.getString('domain') ?? "";
|
// return prefs.getString('domain') ?? "";
|
||||||
// });
|
// });
|
||||||
// _key = _prefs.then((SharedPreferences prefs) {
|
_key = _prefs.then((SharedPreferences prefs) {
|
||||||
// secretKeyTextConrtroller.text = prefs.getString('secretkey') ?? "";
|
secretKeyTextConrtroller.text = prefs.getString('secretkey') ?? "";
|
||||||
// return prefs.getString('secretkey') ?? "";
|
return prefs.getString('secretkey') ?? "";
|
||||||
// });
|
});
|
||||||
_login = _prefs.then((SharedPreferences prefs) {
|
_login = _prefs.then((SharedPreferences prefs) {
|
||||||
return prefs.getBool('isloggedin') ?? false;
|
return prefs.getBool('isloggedin') ?? false;
|
||||||
});
|
});
|
||||||
_logout = _prefs.then((SharedPreferences prefs) {
|
|
||||||
return prefs.getBool('isloggedout') ?? false;
|
|
||||||
});
|
|
||||||
}
|
}
|
||||||
|
|
||||||
init() async {
|
init() async {
|
||||||
|
@ -244,29 +240,6 @@ class _LoginScreenState extends State<LoginScreen> {
|
||||||
|
|
||||||
if (textFieldsValidation(provider).isEmpty) {
|
if (textFieldsValidation(provider).isEmpty) {
|
||||||
print("email:${emailTextController.text}");
|
print("email:${emailTextController.text}");
|
||||||
// if (await _logout) {
|
|
||||||
// print("LOGOUT");
|
|
||||||
// provider.code = secretKeyTextConrtroller.text;
|
|
||||||
// Map<String, dynamic> resp = await provider.verifyCode(
|
|
||||||
// emailTextController.text, secretKeyTextConrtroller.text);
|
|
||||||
// if (resp["code"] == "1200") {
|
|
||||||
// provider.loading = false;
|
|
||||||
// provider.showCodeField = false;
|
|
||||||
// provider.showMessage = true;
|
|
||||||
// _displaySnackBar("You have logged in successfully");
|
|
||||||
// _saveprefs(resp["token"], emailTextController.text,
|
|
||||||
// secretKeyTextConrtroller.text, true)
|
|
||||||
// .then((value) {
|
|
||||||
// Navigator.of(context).pushReplacement(
|
|
||||||
// MaterialPageRoute(
|
|
||||||
// builder: (context) => NavigationHomeScreen()),
|
|
||||||
// );
|
|
||||||
// });
|
|
||||||
// } else {
|
|
||||||
// provider.message = resp["message"];
|
|
||||||
// }
|
|
||||||
// } else {
|
|
||||||
print("FIRST LOGIN");
|
|
||||||
if (!provider.showCodeField) {
|
if (!provider.showCodeField) {
|
||||||
provider.email = emailTextController.text;
|
provider.email = emailTextController.text;
|
||||||
String encoded =
|
String encoded =
|
||||||
|
@ -318,7 +291,6 @@ class _LoginScreenState extends State<LoginScreen> {
|
||||||
secretKeyTextConrtroller.text = provider.code!;
|
secretKeyTextConrtroller.text = provider.code!;
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
// }
|
|
||||||
|
|
||||||
//_joinMeeting(roomText.text, "demo meet2");
|
//_joinMeeting(roomText.text, "demo meet2");
|
||||||
// _saveprefs(
|
// _saveprefs(
|
||||||
|
@ -362,7 +334,6 @@ class _LoginScreenState extends State<LoginScreen> {
|
||||||
|
|
||||||
final String secretkey = (prefs.getString('secretkey') ?? '');
|
final String secretkey = (prefs.getString('secretkey') ?? '');
|
||||||
final bool isloggedin = (prefs.getBool('isloggedin') ?? false);
|
final bool isloggedin = (prefs.getBool('isloggedin') ?? false);
|
||||||
final bool isloggedout = (prefs.getBool('isloggedout') ?? false);
|
|
||||||
setState(() {
|
setState(() {
|
||||||
_useremail = prefs.setString('useremail', email).then((bool success) {
|
_useremail = prefs.setString('useremail', email).then((bool success) {
|
||||||
return useremail;
|
return useremail;
|
||||||
|
@ -377,11 +348,8 @@ class _LoginScreenState extends State<LoginScreen> {
|
||||||
_login = prefs.setBool('isloggedin', login).then((bool success) {
|
_login = prefs.setBool('isloggedin', login).then((bool success) {
|
||||||
return isloggedin;
|
return isloggedin;
|
||||||
});
|
});
|
||||||
_logout = prefs.setBool('isloggedout', false).then((bool success) {
|
SessionManager().setLoggedIn(isloggedin);
|
||||||
return isloggedout;
|
|
||||||
});
|
|
||||||
});
|
});
|
||||||
await SessionManager().setLoggedIn(isloggedin);
|
|
||||||
// UserData userData =
|
// UserData userData =
|
||||||
// UserData(email: email, name: token, domainUrl: domain, secretkey: key);
|
// UserData(email: email, name: token, domainUrl: domain, secretkey: key);
|
||||||
// await provider.saveUserData(userData);
|
// await provider.saveUserData(userData);
|
||||||
|
|
Loading…
Reference in New Issue