@@ -41,23 +41,23 @@ class AuthService {
41
41
42
42
/// Initiates the email sign-in process.
43
43
///
44
- /// For standard sign-in (user-facing app), it generates a verification code,
45
- /// stores it, and sends it via email without checking for user existence.
44
+ /// This method is context-aware based on the [isDashboardLogin] flag.
46
45
///
47
- /// For dashboard login (`isDashboardLogin: true` ), it first verifies that a
48
- /// user with the given [email] exists and has either the 'admin' or
49
- /// 'publisher' role before sending the code.
46
+ /// - For the user-facing app (`isDashboardLogin: false` ), it generates and
47
+ /// sends a verification code to the given [email] without pre-validation,
48
+ /// supporting a unified sign-in/sign-up flow.
49
+ /// - For the dashboard (`isDashboardLogin: true` ), it performs a strict
50
+ /// login-only check. It verifies that a user with the given [email] exists
51
+ /// and has either the 'admin' or 'publisher' role *before* sending a code.
50
52
///
51
53
/// - [email] : The email address to send the code to.
52
54
/// - [isDashboardLogin] : A flag to indicate if this is a login attempt from
53
55
/// the dashboard, which enforces stricter checks.
54
56
///
55
- /// Throws [InvalidInputException] for invalid email format (via email client).
56
57
/// Throws [UnauthorizedException] if `isDashboardLogin` is true and the user
57
58
/// does not exist.
58
59
/// Throws [ForbiddenException] if `isDashboardLogin` is true and the user
59
60
/// exists but lacks the required roles.
60
- /// Throws [OperationFailedException] if code generation/storage/email fails.
61
61
Future <void > initiateEmailSignIn (
62
62
String email, {
63
63
bool isDashboardLogin = false ,
@@ -123,19 +123,15 @@ class AuthService {
123
123
///
124
124
/// This method is context-aware based on the [isDashboardLogin] flag.
125
125
///
126
- /// - If `isDashboardLogin` is `true` , it validates the code and logs in the
127
- /// existing user. It will not create a new user.
128
- /// - If `isDashboardLogin` is `false` (default), it validates the code and
129
- /// either logs in the existing user or creates a new one if they don't
130
- /// exist.
131
- /// New users are created with the 'standardUser' role.
126
+ /// - For the dashboard (`isDashboardLogin: true` ), it validates the code and
127
+ /// logs in the existing user. It will not create a new user in this flow.
128
+ /// - For the user-facing app (`isDashboardLogin: false` ), it validates the
129
+ /// code and either logs in the existing user or creates a new one with a
130
+ /// 'standardUser' role if they don't exist.
132
131
///
133
132
/// Returns the authenticated [User] and a new authentication token.
134
133
///
135
134
/// Throws [InvalidInputException] if the code is invalid or expired.
136
- /// Throws [UnauthorizedException] if `isDashboardLogin` is true and the user
137
- /// is not found (as a safeguard).
138
- /// Throws [OperationFailedException] for user lookup/creation or token errors.
139
135
Future <({User user, String token})> completeEmailSignIn (
140
136
String email,
141
137
String code, {
@@ -187,7 +183,7 @@ class AuthService {
187
183
print ('User not found for $email , creating new user.' );
188
184
189
185
// All new users created via the public API get the standard role.
190
- // Admin users must be provisioned out-of-band (e.g., via databse seed ).
186
+ // Admin users must be provisioned out-of-band (e.g., via fixtures ).
191
187
final roles = [UserRoles .standardUser];
192
188
193
189
user = User (
0 commit comments