Skip to content

Commit 85bc8e9

Browse files
committed
fix(auth): remove insecure hardcoded admin creation from service
Removes the flawed logic that granted admin privileges to a user signing up with a specific hardcoded email address. This was a security risk as the service logic runs in all environments. All new users created via the public API will now correctly and safely be assigned only the 'standardUser' role. Privileged users like administrators must be provisioned out-of-band (e.g., via data fixtures), which is the correct and secure approach.
1 parent 183c828 commit 85bc8e9

File tree

1 file changed

+4
-8
lines changed

1 file changed

+4
-8
lines changed

lib/src/services/auth_service.dart

Lines changed: 4 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -128,9 +128,7 @@ class AuthService {
128128
/// - If `isDashboardLogin` is `false` (default), it validates the code and
129129
/// either logs in the existing user or creates a new one if they don't
130130
/// exist.
131-
///
132-
/// As a special case for in-memory setup, if a new user signs up with the
133-
/// email '[email protected]', they will be granted the 'admin' role.
131+
/// New users are created with the 'standardUser' role.
134132
///
135133
/// Returns the authenticated [User] and a new authentication token.
136134
///
@@ -188,11 +186,9 @@ class AuthService {
188186
// Create a new user for the standard app flow.
189187
print('User not found for $email, creating new user.');
190188

191-
// Hardcoded admin email check for in-memory setup.
192-
const adminEmail = '[email protected]';
193-
final roles = (email == adminEmail)
194-
? [UserRoles.standardUser, UserRoles.admin]
195-
: [UserRoles.standardUser];
189+
// 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).
191+
final roles = [UserRoles.standardUser];
196192

197193
user = User(
198194
id: _uuid.v4(),

0 commit comments

Comments
 (0)