Skip to content

Commit 87bef2a

Browse files
committed
keep password around after login and until account verification (if not verified already)
1 parent 1acfacf commit 87bef2a

5 files changed

+16
-12
lines changed

src/client/Launcher/Controllers/AccountVerificationModalController.cs

+2-7
Original file line numberDiff line numberDiff line change
@@ -8,15 +8,10 @@ internal sealed partial class AccountVerificationModalController : ModalControll
88
[NotifyCanExecuteChangedFor(nameof(ConfirmCommand))]
99
private string _token = string.Empty;
1010

11-
[ObservableProperty]
12-
[NotifyCanExecuteChangedFor(nameof(ConfirmCommand))]
13-
private string _password = string.Empty;
14-
1511
[ObservableProperty]
1612
private ActionStatus _actionStatus;
1713

1814
public bool CanConfirm => !string.IsNullOrEmpty(Token)
19-
&& !string.IsNullOrEmpty(Password)
2015
&& ActionStatus is not ActionStatus.Pending;
2116

2217
public AccountVerificationModalController(IServiceProvider services, MainController mainController)
@@ -31,7 +26,7 @@ private async Task ConfirmAsync()
3126
try
3227
{
3328
ActionStatus = ActionStatus.Pending;
34-
await MainController.Gateway.Rest.VerifyAccountTokenAsync(_session.AccountName!, Password, new AccountsVerifyRequest
29+
await MainController.Gateway.Rest.VerifyAccountTokenAsync(_session.AccountName!, _session.Password!, new AccountsVerifyRequest
3530
{
3631
Token = Token,
3732
}).ConfigureAwait(true);
@@ -62,7 +57,7 @@ private async Task ResendEmailAsync()
6257
try
6358
{
6459
ActionStatus = ActionStatus.Pending;
65-
await MainController.Gateway.Rest.SendAccountEmailAsync(_session.AccountName!, Password)
60+
await MainController.Gateway.Rest.SendAccountEmailAsync(_session.AccountName!, _session.Password!)
6661
.ConfigureAwait(true);
6762

6863
ActionStatus = ActionStatus.Successful;

src/client/Launcher/Controllers/LoginModalController.cs

+1-1
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@ private async Task LoginAsync()
4444

4545
if (resp.SessionTicket != null)
4646
{
47-
_session.Login(Email, resp);
47+
_session.Login(Email, resp, resp.IsVerifying ? Password : null);
4848

4949
ActionStatus = ActionStatus.Successful;
5050

src/client/Launcher/Controllers/RegistrationModalController.cs

+1-1
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@ await MainController.Gateway.Rest
4848

4949
if (resp.SessionTicket != null)
5050
{
51-
_session.Login(Email, resp);
51+
_session.Login(Email, resp, Password);
5252

5353
ActionStatus = ActionStatus.Successful;
5454

src/client/Launcher/UserSession.cs

+10-1
Original file line numberDiff line numberDiff line change
@@ -10,14 +10,21 @@ internal sealed class UserSession
1010

1111
public bool IsVerified { get; private set; }
1212

13+
public string? Password { get; private set; }
14+
1315
public bool IsLoggedIn => AccountName is not null;
1416

15-
public void Login(string accountName, AccountsAuthenticateResponse response)
17+
public void Login(string accountName, AccountsAuthenticateResponse response, string? password = null)
1618
{
1719
AccountName = accountName;
1820
SessionTicket = response.SessionTicket;
1921
IsVerified = !response.IsVerifying;
2022

23+
if (!string.IsNullOrEmpty(password) && !IsVerified)
24+
{
25+
Password = password;
26+
}
27+
2128
StatusChanged?.Invoke();
2229
}
2330

@@ -26,13 +33,15 @@ public void Logout()
2633
AccountName = null;
2734
SessionTicket = null;
2835
IsVerified = false;
36+
Password = null;
2937

3038
StatusChanged?.Invoke();
3139
}
3240

3341
public void Verify()
3442
{
3543
IsVerified = true;
44+
Password = null;
3645

3746
StatusChanged?.Invoke();
3847
}

src/client/Launcher/Views/AccountVerificationForm.axaml

+2-2
Original file line numberDiff line numberDiff line change
@@ -47,11 +47,11 @@
4747
x:Name="TokenTextBox"
4848
Text="{Binding Token, Mode=TwoWay}"
4949
/>
50-
<TextBox VerticalAlignment="Center"
50+
<!--<TextBox VerticalAlignment="Center"
5151
Watermark="Password"
5252
PasswordChar="•"
5353
Text="{Binding Password, Mode=TwoWay}"
54-
/>
54+
/>-->
5555
<Button CornerRadius="8"
5656
Classes="main"
5757
HorizontalAlignment="Stretch"

0 commit comments

Comments
 (0)