Skip to content

Commit 336610b

Browse files
committed
feat(viewmodel): add oauth logic and improve provider lifecycle
1 parent a0be5d0 commit 336610b

1 file changed

Lines changed: 29 additions & 0 deletions

File tree

src/lib/features/auth/presentation/viewmodels/auth_viewmodels.dart

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -95,8 +95,37 @@ class LoginViewModel extends BaseViewModel {
9595
setLoading(false);
9696
}
9797
}
98+
// 1.1 LOGIN WITH GOOGLE
99+
Future<String?> loginWithGoogle() async {
100+
setLoading(true);
101+
try {
102+
final success = await _authHelper.loginWithGoogle();
103+
if (success) return null; // Thành công (thường Supabase sẽ tự văng ra web browser)
104+
return 'Lỗi khi mở cổng đăng nhập Google!';
105+
} catch (e) {
106+
return handleError(e);
107+
} finally {
108+
setLoading(false);
109+
}
110+
}
111+
112+
// 1.2 LOGIN WITH FACEBOOK
113+
114+
Future<String?> loginWithFacebook() async {
115+
setLoading(true);
116+
try {
117+
final success = await _authHelper.loginWithFacebook();
118+
if (success) return null;
119+
return 'Lỗi khi mở cổng đăng nhập Facebook!';
120+
} catch (e) {
121+
return handleError(e);
122+
} finally {
123+
setLoading(false);
124+
}
125+
}
98126
}
99127

128+
100129
// ==========================================
101130
// 2. REGISTER VIEWMODEL
102131
// ==========================================

0 commit comments

Comments
 (0)