Skip to content

Commit

Permalink
clean up
Browse files Browse the repository at this point in the history
  • Loading branch information
dnys1 committed Mar 7, 2024
1 parent 7413956 commit 392a00c
Show file tree
Hide file tree
Showing 4 changed files with 19 additions and 26 deletions.
20 changes: 7 additions & 13 deletions packages/celest_auth/lib/src/auth.dart
Original file line number Diff line number Diff line change
@@ -1,6 +1,10 @@
import 'package:celest_auth/src/flows/auth_flow.dart';
import 'package:celest_auth/src/platform/auth_platform.dart';
import 'package:celest_core/celest_core.dart';
// ignore: implementation_imports
import 'package:celest_core/src/storage/secure/secure_storage.dart';
// ignore: implementation_imports
import 'package:celest_core/src/storage/storage.dart';
import 'package:http/http.dart' as http;
import 'package:meta/meta.dart';

Expand All @@ -9,10 +13,7 @@ import 'package:meta/meta.dart';
///
/// Generated Celest clients extend this class and mix in the various
/// [AuthFlow]s supported by the backend.
abstract interface class Auth {
/// Whether the user is currently authenticated.
bool get isAuthenticated;
}
abstract interface class Auth {}

abstract base class AuthImpl implements Auth {
AuthImpl({
Expand All @@ -26,18 +27,11 @@ abstract base class AuthImpl implements Auth {
///
/// Must be called before any other getters or methods are accessed.
@mustCallSuper
void init() {
final cork = secureStorage.read('cork');
_isAuthenticated = cork != null;
}

@override
bool get isAuthenticated => _isAuthenticated;
late bool _isAuthenticated;
void init() {}

final Uri baseUri;
final http.Client httpClient;
final SecureStorage secureStorage = SecureStorage();
final Storage secureStorage = SecureStorage();

late final AuthClient protocol = AuthClient(
baseUri: baseUri,
Expand Down
3 changes: 3 additions & 0 deletions packages/celest_auth/lib/src/state/auth_state.dart
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
sealed class AuthState {
const AuthState();
}
4 changes: 0 additions & 4 deletions packages/celest_core/lib/celest_core.dart
Original file line number Diff line number Diff line change
Expand Up @@ -15,10 +15,6 @@ export 'src/exception/celest_exception.dart';
export 'src/exception/cloud_exception.dart';
export 'src/exception/serialization_exception.dart';

/// Secure Storage
export 'src/secure_storage/secure_storage.dart';
export 'src/secure_storage/secure_storage_exception.dart';

/// Serialization
export 'src/serialization/json_value.dart';
export 'src/serialization/serializer.dart';
18 changes: 9 additions & 9 deletions packages/celest_core/lib/src/auth/user.dart
Original file line number Diff line number Diff line change
Expand Up @@ -27,34 +27,34 @@ final class AuthenticatedUser {

final class User {
const User({
required this.id,
this.organizationId,
required this.userId,
this.displayName,
required this.email,
bool? emailVerified,
}) : emailVerified = emailVerified ?? false;

factory User.fromJson(Map<String, Object?> json) {
return User(
id: json['id'] as String,
organizationId: json['organizationId'] as String?,
userId: json['userId'] as String,
displayName: json['displayName'] as String?,
email: json['email'] as String,
emailVerified: json['emailVerified'] as bool?,
);
}

final String id;
final String? organizationId;
final String userId;
final String? displayName;
final String email;
final bool emailVerified;

Map<String, Object?> toJson() => {
'id': id,
if (organizationId != null) 'organizationId': organizationId,
'userId': userId,
if (displayName != null) 'displayName': displayName,
'email': email,
'emailVerified': emailVerified,
};

@override
String toString() => 'User(id: $id, orgId: $organizationId, '
String toString() => 'User(userId: $userId, displayName: $displayName, '
'email: $email, emailVerified: $emailVerified)';
}

0 comments on commit 392a00c

Please sign in to comment.