works better
This commit is contained in:
parent
9b2f544063
commit
ec670e90ae
|
|
@ -5,7 +5,7 @@
|
|||
"welcomeTitle": "Welcome",
|
||||
"emailLabel": "Email",
|
||||
"passwordLabel": "Password",
|
||||
"loginButton": "Login",
|
||||
"loginButton": "Sign in with Keycloak",
|
||||
"loginRequired": "Email and password are required.",
|
||||
"signedInMessage": "You are signed in.",
|
||||
"logoutTooltip": "Logout"
|
||||
|
|
|
|||
|
|
@ -127,7 +127,7 @@ abstract class AppLocalizations {
|
|||
/// No description provided for @loginButton.
|
||||
///
|
||||
/// In en, this message translates to:
|
||||
/// **'Login'**
|
||||
/// **'Sign in with Keycloak'**
|
||||
String get loginButton;
|
||||
|
||||
/// No description provided for @loginRequired.
|
||||
|
|
|
|||
|
|
@ -24,7 +24,7 @@ class AppLocalizationsEn extends AppLocalizations {
|
|||
String get passwordLabel => 'Password';
|
||||
|
||||
@override
|
||||
String get loginButton => 'Login';
|
||||
String get loginButton => 'Sign in with Keycloak';
|
||||
|
||||
@override
|
||||
String get loginRequired => 'Email and password are required.';
|
||||
|
|
|
|||
|
|
@ -25,7 +25,7 @@ class AuthRemoteDataSource {
|
|||
_config.keycloakRedirectUrl,
|
||||
discoveryUrl: _config.keycloakDiscoveryUrl,
|
||||
allowInsecureConnections: _config.allowInsecureConnections,
|
||||
loginHint: email,
|
||||
loginHint: email.isNotEmpty ? email : null,
|
||||
promptValues: const ['login'],
|
||||
scopes: const ['openid', 'profile'],
|
||||
),
|
||||
|
|
|
|||
|
|
@ -12,27 +12,10 @@ class LoginPage extends ConsumerStatefulWidget {
|
|||
}
|
||||
|
||||
class _LoginPageState extends ConsumerState<LoginPage> {
|
||||
final _emailController = TextEditingController();
|
||||
final _passwordController = TextEditingController();
|
||||
|
||||
@override
|
||||
void dispose() {
|
||||
_emailController.dispose();
|
||||
_passwordController.dispose();
|
||||
super.dispose();
|
||||
}
|
||||
|
||||
Future<void> _submit() async {
|
||||
final email = _emailController.text.trim();
|
||||
final password = _passwordController.text;
|
||||
final l10n = AppLocalizations.of(context)!;
|
||||
|
||||
if (email.isEmpty || password.isEmpty) {
|
||||
ScaffoldMessenger.of(context).showSnackBar(
|
||||
SnackBar(content: Text(l10n.loginRequired)),
|
||||
);
|
||||
return;
|
||||
}
|
||||
final config = ref.read(appConfigProvider);
|
||||
final email = config.useLocalAuth ? 'local@user' : '';
|
||||
final password = config.useLocalAuth ? 'local' : '';
|
||||
|
||||
await ref
|
||||
.read(authControllerProvider.notifier)
|
||||
|
|
@ -66,24 +49,6 @@ class _LoginPageState extends ConsumerState<LoginPage> {
|
|||
l10n.welcomeTitle,
|
||||
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),
|
||||
SizedBox(
|
||||
width: double.infinity,
|
||||
|
|
|
|||
|
|
@ -19,7 +19,6 @@ void main() {
|
|||
|
||||
// Verify that login page is shown.
|
||||
expect(find.text('Sign in'), findsOneWidget);
|
||||
expect(find.text('Email'), findsOneWidget);
|
||||
expect(find.text('Password'), findsOneWidget);
|
||||
expect(find.text('Sign in with Keycloak'), findsOneWidget);
|
||||
});
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in a new issue