works better
This commit is contained in:
parent
9b2f544063
commit
ec670e90ae
|
|
@ -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"
|
||||||
|
|
|
||||||
|
|
@ -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.
|
||||||
|
|
|
||||||
|
|
@ -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.';
|
||||||
|
|
|
||||||
|
|
@ -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'],
|
||||||
),
|
),
|
||||||
|
|
|
||||||
|
|
@ -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,
|
||||||
|
|
|
||||||
|
|
@ -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);
|
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue