login method
Implementation
Future<BaseUserModel?> login() async {
BaseUserModel? sqlUser;
String uidPhone = '';
String phone = '';
if (this is CachedLoginMixin) {
Map<String, String>? map =
await (this as CachedLoginMixin).loadCachedLogin();
if (map == null) {
if (kDebugMode) {
print('$runtimeType.loadCachedLogin failed');
}
}
phone = map?[CachedLoginMixin.phoneKey] ?? phone;
uidPhone = map?[CachedLoginMixin.uidPhoneKey] ?? uidPhone;
}
if (this is FirebaseLoginMixin) {
User? firebaseUser = await (this as FirebaseLoginMixin).loginFirebase();
if (firebaseUser == null) {
if (kDebugMode) {
print('$runtimeType.loginFirebase failed');
}
}
phone = firebaseUser?.phoneNumber ?? phone;
uidPhone = firebaseUser?.uid ?? uidPhone;
}
if (this is FakeLoginMixin &&
(this as FakeLoginMixin).fakePhones.contains(Common.phoneNumberInput)) {
phone = Common.phoneNumberInput;
uidPhone = (this as FakeLoginMixin).fakeUidPhone;
if (kDebugMode) {
print('$runtimeType.fakeLogin with phone: $phone, uidPhone: $uidPhone');
}
}
if (this is SQLLoginMixin) {
sqlUser = await (this as SQLLoginMixin).loginSQL(
phone: phone,
uidPhone: uidPhone,
);
if (sqlUser == null) {
if (kDebugMode) {
print('$runtimeType loginSQL failed');
}
}
}
if (sqlUser != null) {
if (this is CachedLoginMixin) {
await (this as CachedLoginMixin).saveCachedLogin(
map: {
CachedLoginMixin.phoneKey: phone,
CachedLoginMixin.uidPhoneKey: uidPhone,
},
);
}
}
return sqlUser;
}