-
Hi, I'm using the WebServerAgent because my client is a Blazor Webassembly. Is it possible to add some parameters inside the RestApi controller where Are these filters save in any case. If I filter by UserId, is it possible to manipulate data for other users (add/modify/delete) on the server? |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment 4 replies
-
you have From the client side: var webRemoteOrchestrator = new WebRemoteOrchestrator(serviceUri);
var agent = new SyncAgent(clientProvider, webRemoteOrchestrator, options);
webRemoteOrchestrator.OnHttpSendingRequest(args =>
{
if (args.Context.AdditionalProperties == null)
args.Context.AdditionalProperties = new Dictionary<string, string> { { "A", "1" } };
}); From Server side, in your controller: var webServerAgent = context.RequestServices.GetService<WebServerAgent>(
webServerAgent.OnHttpGettingRequest(args =>
{
Assert.NotEmpty(args.Context.AdditionalProperties);
Assert.Single(args.Context.AdditionalProperties);
}); You can also use the headers from your request. You can use the var webRemoteOrchestrator = new WebRemoteOrchestrator(serviceUri);
webRemoteOrchestrator.AddCustomHeader("Key", "Value"); |
Beta Was this translation helpful? Give feedback.
You have an example here : https://github.com/Mimetis/Dotmim.Sync/blob/master/Samples/HelloWebAuthSync/HelloWebAuthSyncServer/Controllers/SyncController.cs
In the controller, the user id extracted from the bearer token is used and injected as a paramter.
The code is in comments (for no reason, I 've probably made some tests and commit the modification, sorry about that) but it's a good starting point