TF-624 Check and get oidc configuration on browser
This commit is contained in:
@@ -37,6 +37,8 @@ abstract class BaseLoginView extends GetWidget<LoginController> {
|
|||||||
return AppLocalizations.of(context).requiredEmail;
|
return AppLocalizations.of(context).requiredEmail;
|
||||||
} else if (failure is LoginMissPasswordAction) {
|
} else if (failure is LoginMissPasswordAction) {
|
||||||
return AppLocalizations.of(context).requiredPassword;
|
return AppLocalizations.of(context).requiredPassword;
|
||||||
|
} else if (failure is LoginSSONotAvailableAction) {
|
||||||
|
return AppLocalizations.of(context).ssoNotAvailable;
|
||||||
} else if (failure is GetOIDCConfigurationFailure
|
} else if (failure is GetOIDCConfigurationFailure
|
||||||
|| failure is LoginCanNotVerifySSOConfigurationAction) {
|
|| failure is LoginCanNotVerifySSOConfigurationAction) {
|
||||||
return AppLocalizations.of(context).canNotVerifySSOConfiguration;
|
return AppLocalizations.of(context).canNotVerifySSOConfiguration;
|
||||||
|
|||||||
@@ -123,6 +123,28 @@ class LoginController extends GetxController {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void handleSSOPressed() async {
|
||||||
|
final baseUri = _parseUri(AppConfig.baseUrl);
|
||||||
|
|
||||||
|
if (baseUri != null) {
|
||||||
|
log('LoginController::handleSSOPressed(): baseUri: ${baseUri.toString()}');
|
||||||
|
loginState.value = LoginState(Right(LoginLoadingAction()));
|
||||||
|
await _checkOIDCIsAvailableInteractor
|
||||||
|
.execute(OIDCRequest(baseUrl: baseUri.toString(), resourceUrl: baseUri.origin))
|
||||||
|
.then((response) => response.fold(
|
||||||
|
(failure) => loginState.value = LoginState(Left(LoginSSONotAvailableAction())),
|
||||||
|
(success) {
|
||||||
|
if (success is CheckOIDCIsAvailableSuccess) {
|
||||||
|
loginState.value = LoginState(Right(success));
|
||||||
|
_oidcResponse = success.oidcResponse;
|
||||||
|
_getOIDCConfiguration();
|
||||||
|
} else {
|
||||||
|
loginState.value = LoginState(Left(LoginSSONotAvailableAction()));
|
||||||
|
}
|
||||||
|
}));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
void _getOIDCConfiguration() async {
|
void _getOIDCConfiguration() async {
|
||||||
loginState.value = LoginState(Right(LoginLoadingAction()));
|
loginState.value = LoginState(Right(LoginLoadingAction()));
|
||||||
if (_oidcResponse != null) {
|
if (_oidcResponse != null) {
|
||||||
|
|||||||
@@ -46,7 +46,8 @@ class LoginView extends BaseLoginView {
|
|||||||
),
|
),
|
||||||
Obx(() => buildLoginMessage(context, loginController.loginState.value)),
|
Obx(() => buildLoginMessage(context, loginController.loginState.value)),
|
||||||
buildInputCredentialForm(context),
|
buildInputCredentialForm(context),
|
||||||
buildLoginButton(context)
|
buildLoginButton(context),
|
||||||
|
buildSSOButton(context),
|
||||||
],
|
],
|
||||||
)
|
)
|
||||||
),
|
),
|
||||||
@@ -161,7 +162,8 @@ class LoginView extends BaseLoginView {
|
|||||||
),
|
),
|
||||||
Obx(() => buildLoginMessage(context, loginController.loginState.value)),
|
Obx(() => buildLoginMessage(context, loginController.loginState.value)),
|
||||||
buildInputCredentialForm(context),
|
buildInputCredentialForm(context),
|
||||||
buildLoginButton(context)
|
buildLoginButton(context),
|
||||||
|
buildSSOButton(context),
|
||||||
],
|
],
|
||||||
)
|
)
|
||||||
)
|
)
|
||||||
@@ -198,4 +200,28 @@ class LoginView extends BaseLoginView {
|
|||||||
]
|
]
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Widget buildSSOButton(BuildContext context) {
|
||||||
|
return Container(
|
||||||
|
margin: const EdgeInsets.only(bottom: 16, left: 24, right: 24),
|
||||||
|
width: responsiveUtils.getDeviceWidth(context),height: 48,
|
||||||
|
child: ElevatedButton(
|
||||||
|
key: const Key('ssoSubmitForm'),
|
||||||
|
style: ButtonStyle(
|
||||||
|
foregroundColor: MaterialStateProperty.resolveWith<Color>((Set<MaterialState> states) => Colors.white),
|
||||||
|
backgroundColor: MaterialStateProperty.resolveWith<Color>((Set<MaterialState> states) => AppColor.textFieldErrorBorderColor),
|
||||||
|
shape: MaterialStateProperty.all(RoundedRectangleBorder(
|
||||||
|
borderRadius: BorderRadius.circular(10),
|
||||||
|
side: const BorderSide(width: 0, color: AppColor.textFieldErrorBorderColor)
|
||||||
|
))
|
||||||
|
),
|
||||||
|
child: Text(AppLocalizations.of(context).singleSignOn,
|
||||||
|
style: const TextStyle(fontSize: 16, color: Colors.white)
|
||||||
|
),
|
||||||
|
onPressed: () {
|
||||||
|
loginController.handleSSOPressed();
|
||||||
|
}
|
||||||
|
)
|
||||||
|
);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
@@ -53,4 +53,9 @@ class LoginCanNotVerifySSOConfigurationAction extends Failure {
|
|||||||
class LoginCanNotGetTokenAction extends Failure {
|
class LoginCanNotGetTokenAction extends Failure {
|
||||||
@override
|
@override
|
||||||
List<Object?> get props => [];
|
List<Object?> get props => [];
|
||||||
|
}
|
||||||
|
|
||||||
|
class LoginSSONotAvailableAction extends Failure {
|
||||||
|
@override
|
||||||
|
List<Object?> get props => [];
|
||||||
}
|
}
|
||||||
@@ -1,5 +1,5 @@
|
|||||||
{
|
{
|
||||||
"@@last_modified": "2022-06-01T17:23:21.677245",
|
"@@last_modified": "2022-06-06T13:32:00.583993",
|
||||||
"initializing_data": "Initializing data...",
|
"initializing_data": "Initializing data...",
|
||||||
"@initializing_data": {
|
"@initializing_data": {
|
||||||
"type": "text",
|
"type": "text",
|
||||||
@@ -1399,5 +1399,17 @@
|
|||||||
"type": "text",
|
"type": "text",
|
||||||
"placeholders_order": [],
|
"placeholders_order": [],
|
||||||
"placeholders": {}
|
"placeholders": {}
|
||||||
|
},
|
||||||
|
"singleSignOn": "Single Sign-On",
|
||||||
|
"@singleSignOn": {
|
||||||
|
"type": "text",
|
||||||
|
"placeholders_order": [],
|
||||||
|
"placeholders": {}
|
||||||
|
},
|
||||||
|
"ssoNotAvailable": "Single sign-on (SSO) is not available",
|
||||||
|
"@ssoNotAvailable": {
|
||||||
|
"type": "text",
|
||||||
|
"placeholders_order": [],
|
||||||
|
"placeholders": {}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -1431,4 +1431,14 @@ class AppLocalizations {
|
|||||||
'All mailboxes',
|
'All mailboxes',
|
||||||
name: 'allMailboxes');
|
name: 'allMailboxes');
|
||||||
}
|
}
|
||||||
|
|
||||||
|
String get singleSignOn {
|
||||||
|
return Intl.message('Single Sign-On',
|
||||||
|
name: 'singleSignOn');
|
||||||
|
}
|
||||||
|
|
||||||
|
String get ssoNotAvailable {
|
||||||
|
return Intl.message('Single sign-on (SSO) is not available',
|
||||||
|
name: 'ssoNotAvailable');
|
||||||
|
}
|
||||||
}
|
}
|
||||||
Reference in New Issue
Block a user