Skip to content

Commit d4fdfe6

Browse files
committed
feat(auth): update oauth methods with redirect url and signout
1 parent 1503c7f commit d4fdfe6

1 file changed

Lines changed: 34 additions & 0 deletions

File tree

src/lib/features/auth/data/auth_helper.dart

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,30 @@ class AuthHelper {
4040
}
4141
}
4242

43+
Future<bool> loginWithGoogle() async {
44+
try {
45+
return await supabase.auth.signInWithOAuth(
46+
OAuthProvider.google,
47+
redirectTo: 'taskapp://login-callback', // back to app
48+
);
49+
} on AuthException catch (e) {
50+
print('Lỗi đăng nhập Google: ${e.message}');
51+
return false;
52+
}
53+
}
54+
55+
Future<bool> loginWithFacebook() async {
56+
try {
57+
return await supabase.auth.signInWithOAuth(
58+
OAuthProvider.facebook,
59+
redirectTo: 'taskapp://login-callback', // back to app
60+
);
61+
} on AuthException catch (e) {
62+
print('Lỗi đăng nhập Facebook: ${e.message}');
63+
return false;
64+
}
65+
}
66+
4367
Future<UserModel?> register(String email, String password, String username) async {
4468
try {
4569
final timezoneObj = await FlutterTimezone.getLocalTimezone();
@@ -106,4 +130,14 @@ class AuthHelper {
106130
rethrow;
107131
}
108132
}
133+
}
134+
135+
// SignOut session
136+
Future<void> signOut() async {
137+
try {
138+
await supabase.auth.signOut();
139+
} catch (e) {
140+
print('Lỗi đăng xuất: $e');
141+
rethrow;
142+
}
109143
}

0 commit comments

Comments
 (0)