-
Notifications
You must be signed in to change notification settings - Fork 13
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
6 changed files
with
192 additions
and
35 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,53 @@ | ||
import 'package:celest_auth/src/flows/auth_flow.dart'; | ||
import 'package:celest_auth/src/flows/email_flow.dart'; | ||
import 'package:celest_core/celest_core.dart'; | ||
|
||
sealed class AuthState { | ||
const AuthState(); | ||
} | ||
|
||
final class AuthInitializing extends AuthState { | ||
const AuthInitializing(); | ||
} | ||
|
||
final class Unauthenticated extends AuthState { | ||
const Unauthenticated(); | ||
} | ||
|
||
final class NeedsReauthentication extends AuthState { | ||
const NeedsReauthentication({ | ||
required this.userId, | ||
}); | ||
|
||
final String userId; | ||
} | ||
|
||
sealed class AuthFlowState<Flow extends AuthFlow> extends AuthState { | ||
const AuthFlowState({ | ||
required this.flow, | ||
}); | ||
|
||
final Flow flow; | ||
|
||
void cancel() => flow.cancel(); | ||
} | ||
|
||
class EmailFlowState extends AuthFlowState<EmailFlow> { | ||
const EmailFlowState({required super.flow}); | ||
} | ||
|
||
final class EmailAuthenticated extends EmailFlowState implements Authenticated { | ||
const EmailAuthenticated({ | ||
required super.flow, | ||
required this.user, | ||
}); | ||
|
||
@override | ||
final User user; | ||
} | ||
|
||
final class Authenticated extends AuthState { | ||
const Authenticated(this.user); | ||
|
||
final User user; | ||
} |