mirror of
https://github.com/ppy/osu.git
synced 2024-11-11 18:27:26 +08:00
Add logout button and check for inputs before allowing login.
This commit is contained in:
parent
01dc7cb5c2
commit
ed879f33df
@ -281,6 +281,7 @@ namespace osu.Game.Online.API
|
||||
|
||||
public void Logout()
|
||||
{
|
||||
ClearCredentials();
|
||||
authentication.Clear();
|
||||
State = APIState.Offline;
|
||||
}
|
||||
|
@ -14,6 +14,7 @@ namespace osu.Game.Overlays.Options.General
|
||||
public class LoginOptions : OptionsSubsection, IOnlineComponent
|
||||
{
|
||||
private Container loginForm;
|
||||
private APIAccess api;
|
||||
protected override string Header => "Sign In";
|
||||
|
||||
public LoginOptions()
|
||||
@ -32,6 +33,7 @@ namespace osu.Game.Overlays.Options.General
|
||||
[BackgroundDependencyLoader(permitNulls: true)]
|
||||
private void load(APIAccess api)
|
||||
{
|
||||
this.api = api;
|
||||
api?.Register(this);
|
||||
}
|
||||
|
||||
@ -70,11 +72,22 @@ namespace osu.Game.Overlays.Options.General
|
||||
{
|
||||
Text = $@"Connected as {api.Username}!",
|
||||
},
|
||||
new OsuButton
|
||||
{
|
||||
RelativeSizeAxes = Axes.X,
|
||||
Text = "Sign out",
|
||||
Action = performLogout
|
||||
}
|
||||
};
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
private void performLogout()
|
||||
{
|
||||
api.Logout();
|
||||
}
|
||||
|
||||
class LoginForm : FlowContainer
|
||||
{
|
||||
private APIAccess api;
|
||||
@ -106,7 +119,8 @@ namespace osu.Game.Overlays.Options.General
|
||||
|
||||
private void performLogin()
|
||||
{
|
||||
api.Login(username.Text, password.Text);
|
||||
if (!string.IsNullOrEmpty(username.Text) && !string.IsNullOrEmpty(password.Text))
|
||||
api.Login(username.Text, password.Text);
|
||||
}
|
||||
|
||||
[BackgroundDependencyLoader(permitNulls: true)]
|
||||
|
Loading…
Reference in New Issue
Block a user