Add 2FA verification screen to registration flow

This commit is contained in:
Bartłomiej Dach 2024-02-02 06:50:27 +01:00
parent 45f60b035e
commit a00cf87925
No known key found for this signature in database
2 changed files with 35 additions and 0 deletions

View File

@ -0,0 +1,24 @@
// Copyright (c) ppy Pty Ltd <contact@ppy.sh>. Licensed under the MIT Licence.
// See the LICENCE file in the repository root for full licence text.
using osu.Framework.Allocation;
using osu.Framework.Graphics;
using osu.Game.Overlays.Login;
namespace osu.Game.Overlays.AccountCreation
{
public partial class ScreenEmailVerification : AccountCreationScreen
{
[BackgroundDependencyLoader]
private void load()
{
InternalChild = new SecondFactorAuthForm
{
RelativeSizeAxes = Axes.Both,
Padding = new MarginPadding(20),
Anchor = Anchor.Centre,
Origin = Anchor.Centre,
};
}
}
}

View File

@ -5,6 +5,7 @@
using System.Linq;
using System.Threading.Tasks;
using osu.Framework.Allocation;
using osu.Framework.Bindables;
using osu.Framework.Extensions.LocalisationExtensions;
using osu.Framework.Graphics;
using osu.Framework.Graphics.Containers;
@ -37,6 +38,8 @@ public partial class ScreenEntry : AccountCreationScreen
[Resolved]
private IAPIProvider api { get; set; } = null!;
private IBindable<APIState> apiState = null!;
private ShakeContainer registerShake = null!;
private ITextPart characterCheckText = null!;
@ -142,6 +145,8 @@ private void load()
passwordTextBox.Current.BindValueChanged(_ => updateCharacterCheckTextColour(), true);
characterCheckText.DrawablePartsRecreated += _ => updateCharacterCheckTextColour();
apiState = api.State.GetBoundCopy();
}
private void updateCharacterCheckTextColour()
@ -221,6 +226,12 @@ private void performRegistration()
return;
}
apiState.BindValueChanged(state =>
{
if (state.NewValue == APIState.RequiresSecondFactorAuth)
this.Push(new ScreenEmailVerification());
});
api.Login(usernameTextBox.Text, passwordTextBox.Text);
});
});