step 18 : perbaikan login pada useeffect dan logout pada mutation
This commit is contained in:
@@ -36,7 +36,7 @@ class AuthRepository extends BaseRepository {
|
||||
Future<LogoutResponseModel> logout(
|
||||
String email, String idGoogleSignIn) async {
|
||||
const String query =
|
||||
r'''mutation($emailParam:String!, $id_google_sign_in_Param:String!){ logoutAttendance(email:$emailParam, id_google_sign_in:$id_google_sign_in_Param){ staff_id nip name email phone_number token id_google_sign_in company_id company_name } }''';
|
||||
r'''mutation($emailParam:String!, $id_google_sign_in_Param:String!){ logoutAttendance(email:$emailParam, id_google_sign_in:$id_google_sign_in_Param){ status message } }''';
|
||||
|
||||
Map<String, dynamic> inpVariables = {
|
||||
"emailParam": email,
|
||||
|
||||
@@ -55,12 +55,51 @@ class LoginScreen extends HookConsumerWidget {
|
||||
),
|
||||
);
|
||||
|
||||
if (xmodel != null) {
|
||||
// NEW
|
||||
// if (xmodel != null) {
|
||||
// ref.read(loginProvider.notifier).login(
|
||||
// authModel.model.email ?? "",
|
||||
// authModel.model.idGoogleSignIn ?? "",
|
||||
// );
|
||||
// }
|
||||
|
||||
// OLD
|
||||
await googleSignIn.signInSilently();
|
||||
googleSignIn.onCurrentUserChanged.listen((account) {
|
||||
// ref
|
||||
// .read(currentUserGoogleProvider.notifier)
|
||||
// .update((state) => account);
|
||||
ref.read(currentUserProvider.notifier).state = authModel;
|
||||
ref.read(currentPageProvider.state).update((state) => 0);
|
||||
|
||||
if (account != null &&
|
||||
ref.read(currentUserProvider)?.model.staffId == "0") {
|
||||
// Lakukan login
|
||||
ref.read(loginProvider.notifier).login(
|
||||
account.email,
|
||||
account.id,
|
||||
);
|
||||
}
|
||||
});
|
||||
|
||||
// kalau sudah pernah login
|
||||
if (googleSignIn.currentUser?.email != null) {
|
||||
googleSignIn.signInSilently();
|
||||
// ref.read(currentUserGoogleProvider.notifier).update(
|
||||
// (state) => googleSignIn.currentUser,
|
||||
// );
|
||||
ref.read(loginProvider.notifier).login(
|
||||
authModel.model.email ?? "",
|
||||
authModel.model.idGoogleSignIn ?? "",
|
||||
googleSignIn.currentUser?.email ?? "",
|
||||
googleSignIn.currentUser?.id ?? "",
|
||||
);
|
||||
}
|
||||
|
||||
// ref.read(currentUserProvider.notifier).state = authModel;
|
||||
|
||||
// Navigator.of(context).pushNamedAndRemoveUntil(
|
||||
// homeRoute,
|
||||
// (route) => false,
|
||||
// );
|
||||
});
|
||||
return () {};
|
||||
}, []);
|
||||
|
||||
Reference in New Issue
Block a user