works better

This commit is contained in:
oskar 2026-01-12 22:39:32 +01:00
parent 9b2f544063
commit ec670e90ae
6 changed files with 8 additions and 44 deletions

View file

@ -5,7 +5,7 @@
"welcomeTitle": "Welcome", "welcomeTitle": "Welcome",
"emailLabel": "Email", "emailLabel": "Email",
"passwordLabel": "Password", "passwordLabel": "Password",
"loginButton": "Login", "loginButton": "Sign in with Keycloak",
"loginRequired": "Email and password are required.", "loginRequired": "Email and password are required.",
"signedInMessage": "You are signed in.", "signedInMessage": "You are signed in.",
"logoutTooltip": "Logout" "logoutTooltip": "Logout"

View file

@ -127,7 +127,7 @@ abstract class AppLocalizations {
/// No description provided for @loginButton. /// No description provided for @loginButton.
/// ///
/// In en, this message translates to: /// In en, this message translates to:
/// **'Login'** /// **'Sign in with Keycloak'**
String get loginButton; String get loginButton;
/// No description provided for @loginRequired. /// No description provided for @loginRequired.

View file

@ -24,7 +24,7 @@ class AppLocalizationsEn extends AppLocalizations {
String get passwordLabel => 'Password'; String get passwordLabel => 'Password';
@override @override
String get loginButton => 'Login'; String get loginButton => 'Sign in with Keycloak';
@override @override
String get loginRequired => 'Email and password are required.'; String get loginRequired => 'Email and password are required.';

View file

@ -25,7 +25,7 @@ class AuthRemoteDataSource {
_config.keycloakRedirectUrl, _config.keycloakRedirectUrl,
discoveryUrl: _config.keycloakDiscoveryUrl, discoveryUrl: _config.keycloakDiscoveryUrl,
allowInsecureConnections: _config.allowInsecureConnections, allowInsecureConnections: _config.allowInsecureConnections,
loginHint: email, loginHint: email.isNotEmpty ? email : null,
promptValues: const ['login'], promptValues: const ['login'],
scopes: const ['openid', 'profile'], scopes: const ['openid', 'profile'],
), ),

View file

@ -12,27 +12,10 @@ class LoginPage extends ConsumerStatefulWidget {
} }
class _LoginPageState extends ConsumerState<LoginPage> { class _LoginPageState extends ConsumerState<LoginPage> {
final _emailController = TextEditingController();
final _passwordController = TextEditingController();
@override
void dispose() {
_emailController.dispose();
_passwordController.dispose();
super.dispose();
}
Future<void> _submit() async { Future<void> _submit() async {
final email = _emailController.text.trim(); final config = ref.read(appConfigProvider);
final password = _passwordController.text; final email = config.useLocalAuth ? 'local@user' : '';
final l10n = AppLocalizations.of(context)!; final password = config.useLocalAuth ? 'local' : '';
if (email.isEmpty || password.isEmpty) {
ScaffoldMessenger.of(context).showSnackBar(
SnackBar(content: Text(l10n.loginRequired)),
);
return;
}
await ref await ref
.read(authControllerProvider.notifier) .read(authControllerProvider.notifier)
@ -66,24 +49,6 @@ class _LoginPageState extends ConsumerState<LoginPage> {
l10n.welcomeTitle, l10n.welcomeTitle,
style: const TextStyle(fontSize: 24, fontWeight: FontWeight.w600), style: const TextStyle(fontSize: 24, fontWeight: FontWeight.w600),
), ),
const SizedBox(height: 12),
TextField(
controller: _emailController,
keyboardType: TextInputType.emailAddress,
autofillHints: const [AutofillHints.username],
decoration: InputDecoration(
labelText: l10n.emailLabel,
),
),
const SizedBox(height: 16),
TextField(
controller: _passwordController,
obscureText: true,
autofillHints: const [AutofillHints.password],
decoration: InputDecoration(
labelText: l10n.passwordLabel,
),
),
const SizedBox(height: 24), const SizedBox(height: 24),
SizedBox( SizedBox(
width: double.infinity, width: double.infinity,

View file

@ -19,7 +19,6 @@ void main() {
// Verify that login page is shown. // Verify that login page is shown.
expect(find.text('Sign in'), findsOneWidget); expect(find.text('Sign in'), findsOneWidget);
expect(find.text('Email'), findsOneWidget); expect(find.text('Sign in with Keycloak'), findsOneWidget);
expect(find.text('Password'), findsOneWidget);
}); });
} }