Skip to content

Commit

Permalink
web apple signin logic (#62)
Browse files Browse the repository at this point in the history
  • Loading branch information
Ida631 authored Nov 24, 2024
1 parent 84a63ae commit 14ee20f
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 3 deletions.
2 changes: 2 additions & 0 deletions data/lib/repositories/auth_repository_impl.dart
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import 'package:domain/entities/domain_exceptions.dart';
import 'package:domain/entities/user.dart';
import 'package:domain/repositories_abstract/api_env_repository.dart';
import 'package:domain/repositories_abstract/auth_repository.dart';
import 'package:flutter/foundation.dart';
import 'package:http/http.dart' as http;

import '../data_sources/authenticated_http_client.dart';
Expand Down Expand Up @@ -211,6 +212,7 @@ class AuthRepositoryImpl implements AuthRepository {
},
body: jsonEncode({
'identityToken': identityToken,
'platform': kIsWeb ? 'web' : 'other',
}),
);
if (response.statusCode != 200) {
Expand Down
5 changes: 2 additions & 3 deletions lib/presentation/settings/viewModels/login_view_model.dart
Original file line number Diff line number Diff line change
Expand Up @@ -133,7 +133,6 @@ class LoginViewModel extends ChangeNotifier {
}

Future<void> signInWithApple() async {
String? email;
try {
_isSigningIn = false;
// Request credentials from Apple
Expand All @@ -143,7 +142,7 @@ class LoginViewModel extends ChangeNotifier {
AppleIDAuthorizationScopes.fullName,
],
webAuthenticationOptions: WebAuthenticationOptions(
clientId: 'com.example.swiftcompsignin',
clientId: kIsWeb ? 'com.example.swiftcompsignin' : 'com.cdmHUB.SwiftComp',
redirectUri: kIsWeb //This is where Apple sends the user back after they sign in.
? Uri.parse('https://compositesai.com')
: Uri.parse(
Expand All @@ -160,7 +159,7 @@ class LoginViewModel extends ChangeNotifier {
throw Exception('Identity token not available in Apple credentials');
}
// Validate the token with backend and retrieve email if valid
email = await validateAppleToken(identityToken);
final email = await validateAppleToken(identityToken);

await syncUser(null, email, null);

Expand Down

0 comments on commit 14ee20f

Please sign in to comment.