Skip to content

Commit

Permalink
activate the desktop window once login is successful
Browse files Browse the repository at this point in the history
  • Loading branch information
hahn-kev committed Dec 20, 2024
1 parent 393eb6b commit 21099b1
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 0 deletions.
5 changes: 5 additions & 0 deletions backend/FwLite/FwLiteDesktop/FwLiteDesktopKernel.cs
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,11 @@ public static void AddFwLiteDesktopServices(this IServiceCollection services,
#if ANDROID
services.Configure<AuthConfig>(config => config.ParentActivityOrWindow = Platform.CurrentActivity);
#endif
services.Configure<AuthConfig>(config => config.AfterLoginWebView = () =>
{
var window = Application.Current?.Windows.FirstOrDefault();
if (window is not null) Application.Current?.ActivateWindow(window);
});

var defaultDataPath = IsPortableApp ? Directory.GetCurrentDirectory() : FileSystem.AppDataDirectory;
var baseDataPath = Path.GetFullPath(configuration.GetSection("FwLiteDesktop").GetValue<string>("BaseDataDir") ??
Expand Down
1 change: 1 addition & 0 deletions backend/FwLite/FwLiteShared/Auth/AuthConfig.cs
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ public class AuthConfig
public bool SystemWebViewLogin { get; set; } = false;
public object? ParentActivityOrWindow { get; set; }
public LexboxServer DefaultServer => LexboxServers.First();
public Action? AfterLoginWebView { get; set; }

public LexboxServer GetServerByAuthority(string authority)
{
Expand Down
1 change: 1 addition & 0 deletions backend/FwLite/FwLiteShared/Auth/AuthService.cs
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ public async Task SignInWebView(LexboxServer server)
{
var result = await clientFactory.GetClient(server).SignIn(string.Empty);//does nothing here
if (!result.HandledBySystemWebView) throw new InvalidOperationException("Sign in not handled by system web view");
options.Value.AfterLoginWebView?.Invoke();
}

public async Task<string> SignInWebApp(LexboxServer server, string returnUrl)
Expand Down

0 comments on commit 21099b1

Please sign in to comment.