This commit is contained in:
parent
633c97e0da
commit
94f71fc00f
@ -15,6 +15,10 @@ using Sledgemapper.Api.Models;
|
||||
|
||||
namespace Sledgemapper.Api.Controllers
|
||||
{
|
||||
// TODO
|
||||
// introduce refresh token from https://github.com/mohamadlawand087/v8-refreshtokenswithJWT
|
||||
// and https://dev.to/moe23/refresh-jwt-with-refresh-tokens-in-asp-net-core-5-rest-api-step-by-step-3en5
|
||||
|
||||
[Route("[controller]")] // api/authmanagement
|
||||
[ApiController]
|
||||
public class AuthManagementController : ControllerBase
|
||||
@ -117,6 +121,7 @@ namespace Sledgemapper.Api.Controllers
|
||||
{
|
||||
Result = true,
|
||||
Token = jwtToken,
|
||||
|
||||
Username = existingUser.Email,
|
||||
Initials = existingUser.Initials,
|
||||
Id = existingUser.Id
|
||||
|
@ -302,8 +302,8 @@ namespace Sledgemapper
|
||||
Program.helper.SaveUnencryptedTokenCache(JsonSerializer.SerializeToUtf8Bytes(_authenticateResponse));
|
||||
|
||||
await Connection.StopAsync();
|
||||
|
||||
State.Instance.CampaignId=Guid.Empty;
|
||||
|
||||
State.Instance.CampaignId = Guid.Empty;
|
||||
State.Instance.CampaignName = string.Empty;
|
||||
State.Instance.SessionId = Guid.Empty;
|
||||
State.Instance.MapId = Guid.Empty;
|
||||
@ -327,18 +327,30 @@ namespace Sledgemapper
|
||||
return result;
|
||||
}
|
||||
|
||||
public async Task ResetSignalrConnection()
|
||||
{
|
||||
try
|
||||
{
|
||||
await Connection.StopAsync();
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
await Connection.StartAsync();
|
||||
}
|
||||
|
||||
public void CheckLogin()
|
||||
{
|
||||
var data = Program.helper.LoadUnencryptedTokenCache();
|
||||
if (data != null && data.Any())
|
||||
{
|
||||
try
|
||||
{
|
||||
_authenticateResponse = JsonSerializer.Deserialize<AuthenticateResponse>(Encoding.UTF8.GetString(data));
|
||||
Messenger.Publish(new LoginSuccesfulMessage(this) { UserName = _authenticateResponse.Username, Initials = _authenticateResponse.Initials });
|
||||
}
|
||||
catch
|
||||
{ }
|
||||
|
||||
_authenticateResponse = JsonSerializer.Deserialize<AuthenticateResponse>(Encoding.UTF8.GetString(data));
|
||||
|
||||
Messenger.Publish(new LoginSuccesfulMessage(this) { UserName = _authenticateResponse.Username, Initials = _authenticateResponse.Initials });
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -3,6 +3,7 @@ using System.Text;
|
||||
using Microsoft.Extensions.Configuration;
|
||||
using Microsoft.Identity.Client;
|
||||
using Microsoft.Identity.Client.Extensions.Msal;
|
||||
using Sentry;
|
||||
|
||||
namespace Sledgemapper
|
||||
{
|
||||
@ -41,7 +42,23 @@ namespace Sledgemapper
|
||||
|
||||
helper = MsalCacheHelper.CreateAsync(storageProperties).Result;
|
||||
|
||||
using (Sentry.SentrySdk.Init("https://973ac1606651454ba7a19f642d0a9bc1@glitchtip.michelescandura.com/1"))
|
||||
using (Sentry.SentrySdk.Init(o =>
|
||||
{
|
||||
o.Dsn = "https://973ac1606651454ba7a19f642d0a9bc1@glitchtip.michelescandura.com/1";
|
||||
o.MaxBreadcrumbs = 50;
|
||||
o.Debug = true;
|
||||
o.StackTraceMode = StackTraceMode.Enhanced;
|
||||
o.AttachStacktrace = true;
|
||||
o.Release = "1.0.0-alpha.3";
|
||||
|
||||
#if DEBUG
|
||||
o.Environment = "dev";
|
||||
#else
|
||||
o.Environment="production";
|
||||
#endif
|
||||
|
||||
o.ServerName = Settings.Instance.MachineName;
|
||||
}))
|
||||
using (var game = new Sledgemapper())
|
||||
{
|
||||
Sentry.SentrySdk.CaptureEvent(new Sentry.SentryEvent() { Message = "App starting" });
|
||||
|
@ -222,7 +222,7 @@ namespace Sledgemapper.UI
|
||||
_windowEditor.ShowModal(Desktop);
|
||||
}
|
||||
|
||||
private void OnLoginSuccesfulMessage(LoginSuccesfulMessage obj)
|
||||
private async void OnLoginSuccesfulMessage(LoginSuccesfulMessage obj)
|
||||
{
|
||||
//MenuConnectNew.Enabled = true;
|
||||
//MenuConnectJoin.Enabled = true;
|
||||
@ -235,6 +235,7 @@ namespace Sledgemapper.UI
|
||||
MenuCampaignPlayers.Enabled = false;
|
||||
lblCampaign.Text = "n/a";
|
||||
lblMap.Text = "n/a";
|
||||
//await CommunicationManager.ResetSignalrConnection();
|
||||
CommunicationManager.SessionData.MapEntityAdded -= OnMapEntityAdded;
|
||||
CommunicationManager.SessionData.MapEntityDeleted -= OnMapEntityDeleted;
|
||||
lblUsername.Text = $"{obj.Initials}";
|
||||
@ -267,6 +268,15 @@ namespace Sledgemapper.UI
|
||||
var serverMap = await CommunicationManager.Api.GetMap(State.Instance.CampaignId, State.Instance.MapId);
|
||||
if (CommunicationManager.Connection.State != HubConnectionState.Connected)
|
||||
{
|
||||
try
|
||||
{
|
||||
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
Console.WriteLine(e);
|
||||
throw;
|
||||
}
|
||||
await CommunicationManager.Connection.StartAsync();
|
||||
UpdateConnectionState(CommunicationManager.Connection);
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user