Skip to content

Commit 2a359a6

Browse files
authored
fix: deep link to world redirects to Genesis after account change (#8848)
* fix: deep link to world redirects to Genesis after account change - Moved world access check from bootstrap to post-auth in the loading flow, so it runs against the identity the user actually picked (rather than the cached one). Remove the now-dead IsUserAuthorisedToAccessWorldAsync from IRealmController. * Added async suffix * Replaced rethrowing with filtering for OperationCanceledException * Fixed OperationCanceledException handling as per code style guidelines * Removed unused TryExtractWorldName * Removed unused IsUserAuthorisedToAccessWorldAsync from Fake realm controller as well
1 parent 9673acf commit 2a359a6

8 files changed

Lines changed: 109 additions & 96 deletions

File tree

Explorer/Assets/DCL/Infrastructure/ECS/SceneLifeCycle/Realm/IRealmController.cs

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
using CommunicationData.URLHelpers;
22
using Cysharp.Threading.Tasks;
3-
using System;
43
using System.Threading;
54

65
namespace ECS.SceneLifeCycle.Realm
@@ -15,8 +14,6 @@ public interface IRealmController
1514

1615
UniTask<bool> IsReachableAsync(URLDomain realm, CancellationToken ct);
1716

18-
UniTask<bool> IsUserAuthorisedToAccessWorldAsync(URLDomain realm, CancellationToken ct);
19-
2017
/// <summary>
2118
/// Dispose everything on application quit
2219
/// </summary>
@@ -36,9 +33,6 @@ public UniTask SetRealmAsync(URLDomain realm, CancellationToken ct) =>
3633
public async UniTask<bool> IsReachableAsync(URLDomain realm, CancellationToken ct) =>
3734
false;
3835

39-
public async UniTask<bool> IsUserAuthorisedToAccessWorldAsync(URLDomain realm, CancellationToken ct) =>
40-
false;
41-
4236
public void DisposeGlobalWorld()
4337
{
4438
//ignore

Explorer/Assets/DCL/Infrastructure/Global/Dynamic/Bootstraper.cs

Lines changed: 0 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@
22
using CommunicationData.URLHelpers;
33
using Cysharp.Threading.Tasks;
44
using DCL.Audio;
5-
using DCL.Chat.History;
65
using DCL.DebugUtilities;
76
using DCL.Diagnostics;
87
using DCL.FeatureFlags;
@@ -287,27 +286,6 @@ public async UniTask LoadStartingRealmAsync(DynamicWorldContainer dynamicWorldCo
287286
if (startingRealm.HasValue == false)
288287
throw new InvalidOperationException("Starting realm is not set");
289288

290-
if (realmLaunchSettings.initialRealm is InitialRealm.World)
291-
{
292-
bool isAuthorized = await dynamicWorldContainer.RealmController
293-
.IsUserAuthorisedToAccessWorldAsync(startingRealm.Value, ct);
294-
295-
if (!isAuthorized)
296-
{
297-
ReportHub.LogWarning(ReportCategory.REALM,
298-
$"[Bootstrap] Startup world '{realmLaunchSettings.TargetWorld}' is not authorized for auto-entry, falling back to Genesis.");
299-
300-
dynamicWorldContainer.ChatHistory.AddMessage(
301-
ChatChannel.NEARBY_CHANNEL_ID,
302-
ChatChannel.ChatChannelType.NEARBY,
303-
ChatMessage.NewFromSystem($"Could not auto-enter '{realmLaunchSettings.TargetWorld}' due to world permissions. You were sent to Genesis Plaza."));
304-
305-
await dynamicWorldContainer.RealmController
306-
.SetRealmAsync(URLDomain.FromString(realmUrls.GenesisRealm()), ct);
307-
return;
308-
}
309-
}
310-
311289
await dynamicWorldContainer.RealmController.SetRealmAsync(startingRealm.Value, ct);
312290
}
313291

Explorer/Assets/DCL/Infrastructure/Global/Dynamic/DynamicWorldContainer.cs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -387,7 +387,6 @@ static IMultiPool MultiPoolFactory() =>
387387

388388
var realmContainer = RealmContainer.Create(
389389
staticContainer,
390-
identityCache,
391390
dynamicWorldParams.StaticLoadPositions,
392391
debugBuilder,
393392
loadingScreenTimeout,
@@ -396,8 +395,7 @@ static IMultiPool MultiPoolFactory() =>
396395
bootstrapContainer.DecentralandUrlsSource,
397396
appArgs,
398397
teleportController,
399-
bootstrapContainer.Environment,
400-
worldPermissionsService);
398+
bootstrapContainer.Environment);
401399

402400
var terrainContainer = TerrainContainer.Create(staticContainer, realmContainer, dynamicWorldParams.EnableLandscape, localSceneDevelopment);
403401

@@ -525,7 +523,9 @@ static IMultiPool MultiPoolFactory() =>
525523
roomHub,
526524
localSceneDevelopment,
527525
staticContainer.CharacterContainer,
528-
moderationDataProvider);
526+
moderationDataProvider,
527+
worldPermissionsService,
528+
chatHistory);
529529

530530
IRealmNavigator realmNavigator = realmNavigatorContainer.RealmNavigator;
531531
HomePlaceEventBus homePlaceEventBus = new HomePlaceEventBus();

Explorer/Assets/DCL/Infrastructure/Global/Dynamic/InitializationFlowContainer.cs

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,11 @@
11
using DCL.ApplicationBlocklistGuard;
22
using DCL.Audio;
33
using DCL.Character.Plugin;
4+
using DCL.Chat.History;
45
using DCL.Diagnostics;
56
using DCL.Multiplayer.Connections.RoomHubs;
67
using DCL.Multiplayer.HealthChecks;
8+
using DCL.PrivateWorlds;
79
using DCL.Profiles.Self;
810
using DCL.RealmNavigation;
911
using DCL.RealmNavigation.LoadingOperation;
@@ -37,7 +39,9 @@ public static InitializationFlowContainer Create(
3739
IRoomHub roomHub,
3840
bool localSceneDevelopment,
3941
CharacterContainer characterContainer,
40-
ModerationDataProvider moderationDataProvider)
42+
ModerationDataProvider moderationDataProvider,
43+
IWorldPermissionsService worldPermissionsService,
44+
IChatHistory chatHistory)
4145
{
4246
ILoadingStatus? loadingStatus = staticContainer.LoadingStatus;
4347

@@ -100,7 +104,9 @@ public static InitializationFlowContainer Create(
100104
characterContainer.CharacterObject,
101105
characterContainer.Transform,
102106
dynamicWorldParams.StartParcel,
103-
localSceneDevelopment),
107+
localSceneDevelopment,
108+
worldPermissionsService,
109+
chatHistory),
104110
};
105111
}
106112
}

Explorer/Assets/DCL/Infrastructure/Global/Dynamic/RealmController.cs

Lines changed: 1 addition & 54 deletions
Original file line numberDiff line numberDiff line change
@@ -8,10 +8,8 @@
88
using DCL.Ipfs;
99
using DCL.Multiplayer.Connections.DecentralandUrls;
1010
using DCL.Optimization.Pools;
11-
using DCL.PluginSystem.Global;
1211
using DCL.Utilities;
1312
using DCL.Utilities.Extensions;
14-
using DCL.Web3.Identities;
1513
using DCL.WebRequests;
1614
using ECS;
1715
using ECS.Prioritization.Components;
@@ -31,7 +29,6 @@
3129
using Global.AppArgs;
3230
using Unity.Mathematics;
3331
using UnityEngine;
34-
using DCL.PrivateWorlds;
3532
using DCL.UserInAppInitializationFlow.StartupOperations;
3633
using Utility;
3734

@@ -54,11 +51,9 @@ public class RealmController : IGlobalRealmController
5451

5552
private readonly List<ISceneFacade> allScenes = new (PoolConstants.SCENES_COUNT);
5653
private readonly ServerAbout serverAbout = new ();
57-
private readonly IWeb3IdentityCache web3IdentityCache;
5854
private readonly IWebRequestController webRequestController;
5955
private readonly IReadOnlyList<int2> staticLoadPositions;
6056
private readonly RealmData realmData;
61-
private readonly IWorldPermissionsService worldPermissionsService;
6257
private readonly RetrieveSceneFromFixedRealm retrieveSceneFromFixedRealm;
6358
private readonly RetrieveSceneFromVolatileWorld retrieveSceneFromVolatileWorld;
6459
private readonly TeleportController teleportController;
@@ -92,7 +87,6 @@ public GlobalWorld GlobalWorld
9287
}
9388

9489
public RealmController(
95-
IWeb3IdentityCache web3IdentityCache,
9690
IWebRequestController webRequestController,
9791
TeleportController teleportController,
9892
RetrieveSceneFromFixedRealm retrieveSceneFromFixedRealm,
@@ -107,14 +101,11 @@ public RealmController(
107101
IAppArgs appArgs,
108102
IDecentralandUrlsSource decentralandUrlsSource,
109103
DecentralandEnvironment environment,
110-
WorldManifestProvider worldManifestProvider,
111-
IWorldPermissionsService worldPermissionsService)
104+
WorldManifestProvider worldManifestProvider)
112105
{
113-
this.web3IdentityCache = web3IdentityCache;
114106
this.webRequestController = webRequestController;
115107
this.staticLoadPositions = staticLoadPositions;
116108
this.realmData = realmData;
117-
this.worldPermissionsService = worldPermissionsService;
118109
this.teleportController = teleportController;
119110
this.retrieveSceneFromFixedRealm = retrieveSceneFromFixedRealm;
120111
this.retrieveSceneFromVolatileWorld = retrieveSceneFromVolatileWorld;
@@ -203,50 +194,6 @@ public async UniTask SetRealmAsync(URLDomain realm, CancellationToken ct)
203194
public async UniTask<bool> IsReachableAsync(URLDomain realm, CancellationToken ct) =>
204195
await webRequestController.IsHeadReachableAsync(ReportCategory.REALM, realm.Append(new URLPath("/about")), ct);
205196

206-
public async UniTask<bool> IsUserAuthorisedToAccessWorldAsync(URLDomain realm, CancellationToken ct)
207-
{
208-
if (!TryExtractWorldName(realm, out string worldName))
209-
{
210-
ReportHub.LogWarning(ReportCategory.REALM,
211-
$"[RealmController] Failed to extract world name from realm '{realm}'.");
212-
return false;
213-
}
214-
215-
WorldAccessCheckContext context;
216-
try
217-
{
218-
context = await worldPermissionsService.CheckWorldAccessAsync(worldName, ct);
219-
}
220-
catch (OperationCanceledException) { throw; }
221-
catch (Exception e)
222-
{
223-
ReportHub.LogWarning(ReportCategory.REALM,
224-
$"[RealmController] Failed to verify world access for '{worldName}' via world permissions: {e.Message}");
225-
return false;
226-
}
227-
228-
return context.Result == WorldAccessCheckResult.Allowed;
229-
}
230-
231-
private static bool TryExtractWorldName(URLDomain realm, out string worldName)
232-
{
233-
worldName = string.Empty;
234-
235-
if (!Uri.TryCreate(realm.Value, UriKind.Absolute, out Uri? uri))
236-
return false;
237-
238-
string path = uri.AbsolutePath.Trim('/');
239-
if (string.IsNullOrEmpty(path))
240-
return false;
241-
242-
string[] segments = path.Split('/', StringSplitOptions.RemoveEmptyEntries);
243-
if (segments.Length == 0)
244-
return false;
245-
246-
worldName = segments[^1];
247-
return !string.IsNullOrEmpty(worldName);
248-
}
249-
250197
public async UniTask<List<SceneEntityDefinition>> WaitForFixedScenePromisesAsync(CancellationToken ct)
251198
{
252199
FixedScenePointers fixedScenePointers = default;

Explorer/Assets/DCL/RealmNavigation/Container/RealmContainer.cs

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,6 @@ public class RealmContainer
3232

3333
public static RealmContainer Create(
3434
StaticContainer staticContainer,
35-
IWeb3IdentityCache identityCache,
3635
IReadOnlyList<int2> staticLoadPositions,
3736
IDebugContainerBuilder debugContainerBuilder,
3837
LoadingScreenTimeout loadingScreenTimeout,
@@ -41,16 +40,14 @@ public static RealmContainer Create(
4140
IDecentralandUrlsSource urlsSource,
4241
IAppArgs appArgs,
4342
TeleportController teleportController,
44-
DecentralandEnvironment dclEnvironment,
45-
IWorldPermissionsService worldPermissionsService)
43+
DecentralandEnvironment dclEnvironment)
4644
{
4745
var retrieveSceneFromFixedRealm = new RetrieveSceneFromFixedRealm();
4846
var retrieveSceneFromVolatileWorld = new RetrieveSceneFromVolatileWorld(staticContainer.RealmData, urlsSource);
4947

5048
var realmNavigatorDebugView = new RealmNavigatorDebugView(debugContainerBuilder);
5149

5250
var realmController = new RealmController(
53-
identityCache,
5451
staticContainer.WebRequestsContainer.WebRequestController,
5552
teleportController,
5653
retrieveSceneFromFixedRealm,
@@ -66,8 +63,7 @@ public static RealmContainer Create(
6663
appArgs,
6764
urlsSource,
6865
dclEnvironment,
69-
staticContainer.WorldManifestProvider,
70-
worldPermissionsService
66+
staticContainer.WorldManifestProvider
7167
);
7268

7369
BuildDebugWidget(teleportController, debugContainerBuilder, loadingScreen, loadingScreenTimeout);

Explorer/Assets/DCL/UserInAppInitializationFlow/DCL.UserInAppInitializationFlow.asmdef

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,8 @@
3232
"GUID:c80c82a8f4e04453b85fbab973d6774a",
3333
"GUID:54d33bbd50a28174e8ba0110106203c2",
3434
"GUID:875a5d5129614170bd769ed012c2eb3d",
35-
"GUID:8614faad1014549c88b57654b0fb41bd"
35+
"GUID:8614faad1014549c88b57654b0fb41bd",
36+
"GUID:f8127c6ac263abf468221dcbccbde182"
3637
],
3738
"includePlatforms": [],
3839
"excludePlatforms": [],

0 commit comments

Comments
 (0)