Skip to content

Commit

Permalink
feat: Manage defining a custom OAuth Helper (#17)
Browse files Browse the repository at this point in the history
  • Loading branch information
taorepoara authored Dec 29, 2023
1 parent c755111 commit ce853b9
Showing 1 changed file with 20 additions and 15 deletions.
35 changes: 20 additions & 15 deletions lib/application.dart
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,9 @@ class LenraApplication extends StatefulWidget {
/// Defaults to `ws://localhost:4001/socket/websocket` in debug mode and `https://api.lenra.io/socket/websocket` in release mode.
final String socketEndpoint;

/// The OAuth2 helper for customizing OAuth configuration.
final LenraOauth2Helper? oauth2helper;

/// Creates a new instance of [LenraOauth2Widget].
LenraApplication({
super.key,
Expand All @@ -77,6 +80,7 @@ class LenraApplication extends StatefulWidget {
this.clientSecret,
this.loader,
this.loginWidgetBuilder,
this.oauth2helper,
}) {
this.oauthRedirectPort =
oauthRedirectPort ?? (kIsWeb ? Uri.base.port : 10000);
Expand All @@ -96,21 +100,22 @@ class _LenraApplicationState extends State<LenraApplication> {
@override
void initState() {
super.initState();
oauth2 = LenraOauth2Helper(
baseUri: widget.oauthBaseUri,
redirectUri: getPlatformRedirectUri(
applicationId: widget.applicaionId,
oauthRedirectPort: widget.oauthRedirectPort,
oauthRedirectPath: widget.oauthRedirectPath,
),
clientId: widget.clientId,
clientSecret: widget.clientSecret,
customUriScheme: getPlatformCustomUriScheme(
applicationId: widget.applicaionId,
oauthRedirectPort: widget.oauthRedirectPort,
),
scopes: widget.scopes,
);
oauth2 = widget.oauth2helper ??
LenraOauth2Helper(
baseUri: widget.oauthBaseUri,
redirectUri: getPlatformRedirectUri(
applicationId: widget.applicaionId,
oauthRedirectPort: widget.oauthRedirectPort,
oauthRedirectPath: widget.oauthRedirectPath,
),
clientId: widget.clientId,
clientSecret: widget.clientSecret,
customUriScheme: getPlatformCustomUriScheme(
applicationId: widget.applicaionId,
oauthRedirectPort: widget.oauthRedirectPort,
),
scopes: widget.scopes,
);
if (widget.loginWidgetBuilder == null) {
isLogging = true;
} else {
Expand Down

0 comments on commit ce853b9

Please sign in to comment.