Skip to content

Commit

Permalink
Make sure we're saving logins correctly
Browse files Browse the repository at this point in the history
  • Loading branch information
WamWooWam committed Nov 24, 2024
1 parent 3fb3bb6 commit 369038d
Showing 1 changed file with 10 additions and 5 deletions.
15 changes: 10 additions & 5 deletions UniSky/ViewModels/HomeViewModel.cs
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
using System;
using System.Threading.Tasks;
using CommunityToolkit.Mvvm.ComponentModel;
using CommunityToolkit.Mvvm.DependencyInjection;
using CommunityToolkit.Mvvm.Input;
using FishyFlip;
using FishyFlip.Events;
Expand Down Expand Up @@ -142,17 +143,21 @@ private async Task LoadAsync()
var authSessionRefresh = new AuthSession(
new Session(sessionRefresh.Did, sessionRefresh.DidDoc, sessionRefresh.Handle, null, sessionRefresh.RefreshJwt, sessionRefresh.RefreshJwt));

var session = await protocol.AuthenticateWithPasswordSessionAsync(authSessionRefresh);
var refreshSession = (await protocol.RefreshSessionAsync())
await protocol.AuthenticateWithPasswordSessionAsync(authSessionRefresh);
var refreshSession = (await protocol.RefreshSessionAsync().ConfigureAwait(false))
.HandleResult();

var session2 = await protocol.AuthenticateWithPasswordSessionAsync(
new AuthSession(
new Session(refreshSession.Did, refreshSession.DidDoc, refreshSession.Handle, null, refreshSession.AccessJwt, refreshSession.RefreshJwt)));
var authSession2 = new AuthSession(
new Session(refreshSession.Did, refreshSession.DidDoc, refreshSession.Handle, null, refreshSession.AccessJwt, refreshSession.RefreshJwt));
var session2 = await protocol.AuthenticateWithPasswordSessionAsync(authSession2).ConfigureAwait(false);

if (session2 == null)
throw new InvalidOperationException("Authentication failed!");

var sessionModel2 = new SessionModel(true, sessionModel.Service, authSession2.Session, authSession2);
var sessionService = Ioc.Default.GetRequiredService<SessionService>();
sessionService.SaveSession(sessionModel2);

protocolService.SetProtocol(protocol);
}
catch (Exception ex)
Expand Down

0 comments on commit 369038d

Please sign in to comment.