wiring up new auth endpoint
This commit is contained in:
parent
b6999cef0a
commit
a13fb49942
17 changed files with 850 additions and 37 deletions
|
@ -1,4 +1,4 @@
|
|||
using Exceptionless;
|
||||
using Exceptionless;
|
||||
using Exceptionless.Models;
|
||||
using Microsoft.AspNetCore.SignalR.Client;
|
||||
using Microsoft.Xna.Framework;
|
||||
|
@ -211,6 +211,8 @@ namespace Sledgemapper
|
|||
_mainWidget.MenuViewCenterOnSelection.Selected += OnMenuViewCenterOnSelectionSelected;
|
||||
_mainWidget.MenuViewShowCellNUmbers.Selected += OnMenuViewShowCellNUmbersSelected;
|
||||
_mainWidget.MenuViewShowNotes.Selected += OnMenuViewNotesSelected;
|
||||
_mainWidget.MenuCampaingNew.Selected += OnMenuCampaignNew;
|
||||
|
||||
_mainWidget.MenuConnectNew.Enabled = false;
|
||||
_mainWidget.MenuConnectJoin.Enabled = false;
|
||||
_mainWidget.MenuConnectSync.Enabled = false;
|
||||
|
@ -219,6 +221,7 @@ namespace Sledgemapper
|
|||
_mainWidget.BtnToolbarRoom.Click += OnBtnToolbarRoomClicked;
|
||||
_mainWidget.BtnToolbarDelete.Click += OnBtnToolbarDeleteClicked;
|
||||
|
||||
|
||||
_wallsContent = Content.LoadContentFolder<Texture2D>("walls");
|
||||
|
||||
_spriteSheet = new SpriteSheet();
|
||||
|
@ -298,6 +301,27 @@ namespace Sledgemapper
|
|||
((ImageTextButton)sender).BorderThickness = new Myra.Graphics2D.Thickness(2);
|
||||
}
|
||||
|
||||
private void OnMenuCampaignNew(object sender, EventArgs e)
|
||||
{
|
||||
if (!((MenuItem)sender).Enabled)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
Window window = new()
|
||||
{
|
||||
Title = "New campaign"
|
||||
};
|
||||
|
||||
var content = new CampaignWindow();
|
||||
//content.BtnNewCampaign.Text = "N";
|
||||
content.BtnNewCampaign.Click += OnButtonNewCampaignClicked;
|
||||
window.Content = content;
|
||||
|
||||
window.ShowModal(_desktop);
|
||||
content.TxtCampaign.SetKeyboardFocus();
|
||||
}
|
||||
|
||||
private void OneMenuFileSettingsSelected(object sender, EventArgs e)
|
||||
{
|
||||
var propertyGrid = new PropertyGrid
|
||||
|
@ -1900,6 +1924,64 @@ namespace Sledgemapper
|
|||
}
|
||||
}
|
||||
|
||||
private async void OnButtonNewCampaignClicked(object sender, EventArgs e)
|
||||
{
|
||||
Container container = ((TextButton)sender).Parent;
|
||||
while (!(container is Window))
|
||||
{
|
||||
container = container.Parent;
|
||||
}
|
||||
var localWindow = (Window)container;
|
||||
var localContent = localWindow.Content as CampaignWindow;
|
||||
var isValid = ValidateTextbox(localContent.TxtCampaign);
|
||||
if (!isValid)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
if (_communicationManager.Connection.State != HubConnectionState.Connected)
|
||||
{
|
||||
_mainWidget.lblConnectionStatus.Text = "Connecting";
|
||||
await _communicationManager.Connection.StartAsync();
|
||||
UpdateConnectionState(_communicationManager.Connection);
|
||||
}
|
||||
|
||||
var successful = false;
|
||||
try
|
||||
{
|
||||
await _communicationManager.Api.NewCampaign(localContent.TxtCampaign.Text);
|
||||
|
||||
//if (result)
|
||||
//{
|
||||
// _sessionData.SessionName = localContent.TxtSession.Text;
|
||||
// _sessionData.MapEntityAdded -= OnMapEntityAdded;
|
||||
// _sessionData.MapEntityDeleted -= OnMapEntityDeleted;
|
||||
// _sessionData.MapEntityAdded += OnMapEntityAdded;
|
||||
// _sessionData.MapEntityDeleted += OnMapEntityDeleted;
|
||||
//}
|
||||
//successful = result;
|
||||
//var result2 = await _communicationManager.Connection?.InvokeAsync<Session>("JoinSession", localContent.TxtSession.Text);
|
||||
//_sessionData.SessionId = result2.SessionId;
|
||||
//_sessionData.SessionName = localContent.TxtSession.Text;
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
ExceptionlessClient.Default.SubmitException(ex);
|
||||
}
|
||||
|
||||
if (successful)
|
||||
{
|
||||
//_sessionData.SessionName = localContent.TxtSession.Text;
|
||||
//_communicationManager.SessionData.Map = _sessionData.Map;
|
||||
//_communicationManager.SessionData.Overlays = _sessionData.Overlays;
|
||||
//_communicationManager.SessionData.Walls = _sessionData.Walls;
|
||||
//_mainWidget.lblSessionName.Text = _sessionData.SessionName;
|
||||
//_mainWidget.MenuConnectSync.Enabled = true;
|
||||
//_mainWidget.MenuConnectUpload.Enabled = true;
|
||||
localWindow.Close();
|
||||
}
|
||||
}
|
||||
|
||||
private async void OnButtonNewSessionClicked(object sender, EventArgs e)
|
||||
{
|
||||
Container container = ((TextButton)sender).Parent;
|
||||
|
@ -2124,12 +2206,13 @@ namespace Sledgemapper
|
|||
var result = await _communicationManager.Register(new RegisterModel
|
||||
{
|
||||
Username = localContent.TxtEmail.Text,
|
||||
Email = localContent.TxtEmail.Text,
|
||||
Password = localContent.TxtPassword.Text,
|
||||
FirstName = localContent.TxtFirstname.Text,
|
||||
LastName = localContent.TxtLastname.Text,
|
||||
Initials = localContent.TxtInitials.Text
|
||||
});
|
||||
if (result.IsSuccessStatusCode)
|
||||
if (result.Result)
|
||||
{
|
||||
_authResponse = await _communicationManager.Login(new AuthenticateModel
|
||||
{
|
||||
|
@ -2140,7 +2223,7 @@ namespace Sledgemapper
|
|||
}
|
||||
else
|
||||
{
|
||||
localContent.LblLoginError.Text = result.ReasonPhrase;
|
||||
localContent.LblLoginError.Text = result.Errors.FirstOrDefault();
|
||||
localContent.LblLoginError.Visible = true;
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue