Skip to content

Commit

Permalink
Swap client id and endpoint fields
Browse files Browse the repository at this point in the history
  • Loading branch information
IniZio committed Apr 19, 2024
1 parent 7fe0b69 commit 778fd56
Show file tree
Hide file tree
Showing 3 changed files with 31 additions and 18 deletions.
19 changes: 16 additions & 3 deletions example/lib/main.dart
Original file line number Diff line number Diff line change
Expand Up @@ -227,6 +227,8 @@ class _MyAppState extends State<MyApp> {
late SharedPreferences _sharedPreferences;
final TextEditingController _endpointController = TextEditingController();
final TextEditingController _clientIDController = TextEditingController();
final TextEditingController _authenticationFlowGroupController =
TextEditingController();
StreamSubscription<SessionStateChangeEvent>? _sub;
bool _loading = false;
bool _useTransientTokenStorage = false;
Expand Down Expand Up @@ -299,6 +301,15 @@ class _MyAppState extends State<MyApp> {
),
body: ListView(
children: [
Container(
padding:
const EdgeInsets.symmetric(vertical: 8, horizontal: 16),
child: TextFieldWithLabel(
label: "Client ID",
hintText: "Enter client ID",
controller: _clientIDController,
),
),
Container(
padding:
const EdgeInsets.symmetric(vertical: 8, horizontal: 16),
Expand All @@ -312,9 +323,9 @@ class _MyAppState extends State<MyApp> {
padding:
const EdgeInsets.symmetric(vertical: 8, horizontal: 16),
child: TextFieldWithLabel(
label: "Client ID",
hintText: "Enter client ID",
controller: _clientIDController,
label: "Authentication Flow Group",
hintText: "Enter flow group",
controller: _authenticationFlowGroupController,
),
),
RadioGroup<AuthenticationPage>(
Expand Down Expand Up @@ -570,6 +581,7 @@ class _MyAppState extends State<MyApp> {
page: _page,
colorScheme: _getColorScheme(context),
wechatRedirectURI: wechatRedirectURI,
authenticationFlowGroup: _authenticationFlowGroupController.text,
);
setState(() {
_userInfo = userInfo;
Expand Down Expand Up @@ -656,6 +668,7 @@ class _MyAppState extends State<MyApp> {
final userInfo = await _authgear.reauthenticate(
redirectURI: redirectURI,
wechatRedirectURI: wechatRedirectURI,
authenticationFlowGroup: _authenticationFlowGroupController.text,
);
setState(() {
_userInfo = userInfo;
Expand Down
10 changes: 5 additions & 5 deletions lib/src/client.dart
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ class OIDCAuthenticationRequest {
final AuthenticationPage? page;
final String? wechatRedirectURI;
final SettingsAction? settingsAction;
final String? xAuthenticationFlowGroup;
final String? authenticationFlowGroup;

OIDCAuthenticationRequest({
required this.clientID,
Expand All @@ -41,7 +41,7 @@ class OIDCAuthenticationRequest {
this.page,
this.wechatRedirectURI,
this.settingsAction,
this.xAuthenticationFlowGroup,
this.authenticationFlowGroup,
});

Map<String, String> toQueryParameters() {
Expand Down Expand Up @@ -124,9 +124,9 @@ class OIDCAuthenticationRequest {
q["x_settings_action"] = settingsAction.value;
}

final xAuthenticationFlowGroup = this.xAuthenticationFlowGroup;
if (xAuthenticationFlowGroup != null) {
q["x_authentication_flow_group"] = xAuthenticationFlowGroup;
final authenticationFlowGroup = this.authenticationFlowGroup;
if (authenticationFlowGroup != null) {
q["x_authentication_flow_group"] = authenticationFlowGroup;
}

return q;
Expand Down
20 changes: 10 additions & 10 deletions lib/src/container.dart
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ class AuthenticateOptions {
final ColorScheme? colorScheme;
final String? wechatRedirectURI;
final AuthenticationPage? page;
final String? xAuthenticationFlowGroup;
final String? authenticationFlowGroup;

AuthenticateOptions({
required this.redirectURI,
Expand All @@ -65,7 +65,7 @@ class AuthenticateOptions {
this.colorScheme,
this.wechatRedirectURI,
this.page,
this.xAuthenticationFlowGroup,
this.authenticationFlowGroup,
});

OIDCAuthenticationRequest toRequest(String clientID, CodeVerifier verifier) {
Expand All @@ -87,7 +87,7 @@ class AuthenticateOptions {
state: state,
loginHint: loginHint,
wechatRedirectURI: wechatRedirectURI,
xAuthenticationFlowGroup: xAuthenticationFlowGroup,
authenticationFlowGroup: authenticationFlowGroup,
);
}
}
Expand All @@ -100,7 +100,7 @@ class ReauthenticateOptions {
final ColorScheme? colorScheme;
final String? wechatRedirectURI;
final int? maxAge;
final String? xAuthenticationFlowGroup;
final String? authenticationFlowGroup;

ReauthenticateOptions({
required this.redirectURI,
Expand All @@ -110,7 +110,7 @@ class ReauthenticateOptions {
this.colorScheme,
this.wechatRedirectURI,
this.maxAge,
this.xAuthenticationFlowGroup,
this.authenticationFlowGroup,
});

OIDCAuthenticationRequest toRequest(
Expand All @@ -130,7 +130,7 @@ class ReauthenticateOptions {
idTokenHint: idTokenHint,
maxAge: maxAge,
wechatRedirectURI: wechatRedirectURI,
xAuthenticationFlowGroup: xAuthenticationFlowGroup,
authenticationFlowGroup: authenticationFlowGroup,
);
return oidcRequest;
}
Expand Down Expand Up @@ -293,7 +293,7 @@ class Authgear implements AuthgearHttpClientDelegate {
AuthenticationPage? page,
String? state,
String? wechatRedirectURI,
String? xAuthenticationFlowGroup,
String? authenticationFlowGroup,
}) async {
final authRequest =
await internalCreateAuthenticateRequest(AuthenticateOptions(
Expand All @@ -305,7 +305,7 @@ class Authgear implements AuthgearHttpClientDelegate {
colorScheme: colorScheme,
wechatRedirectURI: wechatRedirectURI,
page: page,
xAuthenticationFlowGroup: xAuthenticationFlowGroup,
authenticationFlowGroup: authenticationFlowGroup,
));

if (wechatRedirectURI != null) {
Expand Down Expand Up @@ -347,7 +347,7 @@ class Authgear implements AuthgearHttpClientDelegate {
String? wechatRedirectURI,
BiometricOptionsIOS? biometricIOS,
BiometricOptionsAndroid? biometricAndroid,
String? xAuthenticationFlowGroup,
String? authenticationFlowGroup,
}) async {
final biometricEnabled = await isBiometricEnabled();
if (biometricEnabled && biometricIOS != null && biometricAndroid != null) {
Expand All @@ -370,7 +370,7 @@ class Authgear implements AuthgearHttpClientDelegate {
colorScheme: colorScheme,
wechatRedirectURI: wechatRedirectURI,
maxAge: maxAge,
xAuthenticationFlowGroup: xAuthenticationFlowGroup,
authenticationFlowGroup: authenticationFlowGroup,
);

final request =
Expand Down

0 comments on commit 778fd56

Please sign in to comment.