TF-624 Hide credential form when oidc is available on browser
This commit is contained in:
@@ -49,7 +49,7 @@ abstract class BaseLoginView extends GetWidget<LoginController> {
|
||||
}
|
||||
},
|
||||
(success) {
|
||||
if (loginController.loginFormType.value == LoginFormType.credentialForm || kIsWeb) {
|
||||
if (loginController.loginFormType.value == LoginFormType.credentialForm) {
|
||||
return AppLocalizations.of(context).loginInputCredentialMessage;
|
||||
} else if (loginController.loginFormType.value == LoginFormType.ssoForm) {
|
||||
return AppLocalizations.of(context).loginInputSSOMessage;
|
||||
|
||||
@@ -20,6 +20,7 @@ import 'package:tmail_ui_user/features/login/domain/usecases/get_oidc_configurat
|
||||
import 'package:tmail_ui_user/features/login/domain/usecases/get_stored_oidc_configuration_interactor.dart';
|
||||
import 'package:tmail_ui_user/features/login/domain/usecases/get_token_oidc_interactor.dart';
|
||||
import 'package:tmail_ui_user/features/login/presentation/login_form_type.dart';
|
||||
import 'package:tmail_ui_user/features/login/presentation/model/login_arguments.dart';
|
||||
import 'package:tmail_ui_user/features/login/presentation/state/login_state.dart';
|
||||
import 'package:tmail_ui_user/main/routes/app_routes.dart';
|
||||
import 'package:tmail_ui_user/main/routes/route_navigation.dart';
|
||||
@@ -85,10 +86,21 @@ class LoginController extends GetxController {
|
||||
super.onInit();
|
||||
}
|
||||
|
||||
@override
|
||||
void onReady() {
|
||||
if (BuildUtils.isWeb) {
|
||||
final arguments = Get.arguments;
|
||||
if (arguments is LoginArguments) {
|
||||
loginFormType.value = arguments.loginFormType;
|
||||
}
|
||||
}
|
||||
super.onReady();
|
||||
}
|
||||
|
||||
void _getAuthenticationInfo() async {
|
||||
await _getAuthenticationInfoInteractor.execute()
|
||||
.then((result) => result.fold(
|
||||
(failure) => null,
|
||||
(failure) => {},
|
||||
(success) {
|
||||
if (success is GetAuthenticationInfoSuccess) {
|
||||
_getStoredOidcConfiguration();
|
||||
@@ -99,7 +111,7 @@ class LoginController extends GetxController {
|
||||
void _getStoredOidcConfiguration() async {
|
||||
await _getStoredOidcConfigurationInteractor.execute()
|
||||
.then((result) => result.fold(
|
||||
(failure) => null,
|
||||
(failure) => {},
|
||||
(success) {
|
||||
if (success is GetStoredOidcConfigurationSuccess) {
|
||||
_getTokenOIDCAction(success.oidcConfiguration);
|
||||
@@ -141,6 +153,7 @@ class LoginController extends GetxController {
|
||||
}
|
||||
|
||||
void _showFormLoginWithCredentialAction() {
|
||||
log('LoginController::_showFormLoginWithCredentialAction()');
|
||||
loginState.value = LoginState(Right(InputUrlCompletion()));
|
||||
loginFormType.value = LoginFormType.credentialForm;
|
||||
}
|
||||
|
||||
@@ -3,6 +3,7 @@ import 'package:flutter/material.dart';
|
||||
import 'package:flutter_svg/flutter_svg.dart';
|
||||
import 'package:get/get_state_manager/src/rx_flutter/rx_obx_widget.dart';
|
||||
import 'package:tmail_ui_user/features/login/presentation/base_login_view.dart';
|
||||
import 'package:tmail_ui_user/features/login/presentation/login_form_type.dart';
|
||||
import 'package:tmail_ui_user/features/login/presentation/state/login_state.dart';
|
||||
import 'package:tmail_ui_user/main/localizations/app_localizations.dart';
|
||||
|
||||
@@ -46,13 +47,40 @@ class LoginView extends BaseLoginView {
|
||||
)
|
||||
),
|
||||
Obx(() => buildLoginMessage(context, loginController.loginState.value)),
|
||||
buildInputCredentialForm(context),
|
||||
buildLoginButton(context),
|
||||
Obx(() => loginController.loginState.value.viewState.fold(
|
||||
(failure) => _buildSSOButton(context),
|
||||
(success) => success is LoginLoadingAction
|
||||
? buildLoadingCircularProgress()
|
||||
: _buildSSOButton(context))),
|
||||
Obx(() {
|
||||
switch (controller.loginFormType.value) {
|
||||
case LoginFormType.credentialForm:
|
||||
return buildInputCredentialForm(context);
|
||||
case LoginFormType.ssoForm:
|
||||
return const SizedBox(height: 150);
|
||||
default:
|
||||
return const SizedBox.shrink();
|
||||
}
|
||||
}),
|
||||
Obx(() {
|
||||
switch (controller.loginFormType.value) {
|
||||
case LoginFormType.baseUrlForm:
|
||||
return Obx(() => loginController.loginState.value.viewState.fold(
|
||||
(failure) => const SizedBox.shrink(),
|
||||
(success) => success is LoginLoadingAction
|
||||
? buildLoadingCircularProgress()
|
||||
: const SizedBox.shrink()));
|
||||
case LoginFormType.credentialForm:
|
||||
return Obx(() => loginController.loginState.value.viewState.fold(
|
||||
(failure) => buildLoginButton(context),
|
||||
(success) => success is LoginLoadingAction
|
||||
? buildLoadingCircularProgress()
|
||||
: buildLoginButton(context)));
|
||||
case LoginFormType.ssoForm:
|
||||
return Obx(() => loginController.loginState.value.viewState.fold(
|
||||
(failure) => _buildSSOButton(context),
|
||||
(success) => success is LoginLoadingAction
|
||||
? buildLoadingCircularProgress()
|
||||
: _buildSSOButton(context)));
|
||||
default:
|
||||
return const SizedBox.shrink();
|
||||
}
|
||||
})
|
||||
],
|
||||
)
|
||||
),
|
||||
@@ -166,13 +194,40 @@ class LoginView extends BaseLoginView {
|
||||
)
|
||||
),
|
||||
Obx(() => buildLoginMessage(context, loginController.loginState.value)),
|
||||
buildInputCredentialForm(context),
|
||||
buildLoginButton(context),
|
||||
Obx(() => loginController.loginState.value.viewState.fold(
|
||||
(failure) => _buildSSOButton(context),
|
||||
(success) => success is LoginLoadingAction
|
||||
? buildLoadingCircularProgress()
|
||||
: _buildSSOButton(context))),
|
||||
Obx(() {
|
||||
switch (controller.loginFormType.value) {
|
||||
case LoginFormType.credentialForm:
|
||||
return buildInputCredentialForm(context);
|
||||
case LoginFormType.ssoForm:
|
||||
return const SizedBox(height: 150);
|
||||
default:
|
||||
return const SizedBox.shrink();
|
||||
}
|
||||
}),
|
||||
Obx(() {
|
||||
switch (controller.loginFormType.value) {
|
||||
case LoginFormType.baseUrlForm:
|
||||
return Obx(() => loginController.loginState.value.viewState.fold(
|
||||
(failure) => const SizedBox.shrink(),
|
||||
(success) => success is LoginLoadingAction
|
||||
? buildLoadingCircularProgress()
|
||||
: const SizedBox.shrink()));
|
||||
case LoginFormType.credentialForm:
|
||||
return Obx(() => loginController.loginState.value.viewState.fold(
|
||||
(failure) => buildLoginButton(context),
|
||||
(success) => success is LoginLoadingAction
|
||||
? buildLoadingCircularProgress()
|
||||
: buildLoginButton(context)));
|
||||
case LoginFormType.ssoForm:
|
||||
return Obx(() => loginController.loginState.value.viewState.fold(
|
||||
(failure) => _buildSSOButton(context),
|
||||
(success) => success is LoginLoadingAction
|
||||
? buildLoadingCircularProgress()
|
||||
: _buildSSOButton(context)));
|
||||
default:
|
||||
return const SizedBox.shrink();
|
||||
}
|
||||
})
|
||||
],
|
||||
)
|
||||
)
|
||||
@@ -218,10 +273,10 @@ class LoginView extends BaseLoginView {
|
||||
key: const Key('ssoSubmitForm'),
|
||||
style: ButtonStyle(
|
||||
foregroundColor: MaterialStateProperty.resolveWith<Color>((Set<MaterialState> states) => Colors.white),
|
||||
backgroundColor: MaterialStateProperty.resolveWith<Color>((Set<MaterialState> states) => AppColor.textFieldErrorBorderColor),
|
||||
backgroundColor: MaterialStateProperty.resolveWith<Color>((Set<MaterialState> states) => AppColor.primaryColor),
|
||||
shape: MaterialStateProperty.all(RoundedRectangleBorder(
|
||||
borderRadius: BorderRadius.circular(10),
|
||||
side: const BorderSide(width: 0, color: AppColor.textFieldErrorBorderColor)
|
||||
side: const BorderSide(width: 0, color: AppColor.primaryColor)
|
||||
))
|
||||
),
|
||||
child: Text(AppLocalizations.of(context).singleSignOn,
|
||||
|
||||
@@ -0,0 +1,13 @@
|
||||
|
||||
import 'package:tmail_ui_user/features/login/presentation/login_form_type.dart';
|
||||
import 'package:tmail_ui_user/main/routes/router_arguments.dart';
|
||||
|
||||
class LoginArguments extends RouterArguments {
|
||||
|
||||
final LoginFormType loginFormType;
|
||||
|
||||
LoginArguments(this.loginFormType);
|
||||
|
||||
@override
|
||||
List<Object?> get props => [loginFormType];
|
||||
}
|
||||
Reference in New Issue
Block a user