mirror of
https://github.com/osukey/osukey.git
synced 2025-05-03 04:37:30 +09:00
Move string-token property to OAuth
This commit is contained in:
parent
e007365916
commit
baae4427ff
@ -37,13 +37,7 @@ namespace osu.Game.Online.API
|
|||||||
|
|
||||||
public Bindable<User> LocalUser { get; } = new Bindable<User>(createGuestUser());
|
public Bindable<User> LocalUser { get; } = new Bindable<User>(createGuestUser());
|
||||||
|
|
||||||
public string Token
|
protected bool HasLogin => authentication.Token.Value != null || !string.IsNullOrEmpty(ProvidedUsername) && !string.IsNullOrEmpty(password);
|
||||||
{
|
|
||||||
get { return authentication.Token.Value?.ToString(); }
|
|
||||||
set { authentication.Token.Value = string.IsNullOrEmpty(value) ? null : OAuthToken.Parse(value); }
|
|
||||||
}
|
|
||||||
|
|
||||||
protected bool HasLogin => Token != null || !string.IsNullOrEmpty(ProvidedUsername) && !string.IsNullOrEmpty(password);
|
|
||||||
|
|
||||||
private readonly CancellationTokenSource cancellationToken = new CancellationTokenSource();
|
private readonly CancellationTokenSource cancellationToken = new CancellationTokenSource();
|
||||||
|
|
||||||
@ -57,14 +51,14 @@ namespace osu.Game.Online.API
|
|||||||
log = Logger.GetLogger(LoggingTarget.Network);
|
log = Logger.GetLogger(LoggingTarget.Network);
|
||||||
|
|
||||||
ProvidedUsername = config.Get<string>(OsuSetting.Username);
|
ProvidedUsername = config.Get<string>(OsuSetting.Username);
|
||||||
Token = config.Get<string>(OsuSetting.Token);
|
|
||||||
|
|
||||||
|
authentication.TokenString = config.Get<string>(OsuSetting.Token);
|
||||||
authentication.Token.ValueChanged += onTokenChanged;
|
authentication.Token.ValueChanged += onTokenChanged;
|
||||||
|
|
||||||
Task.Factory.StartNew(run, cancellationToken.Token, TaskCreationOptions.LongRunning, TaskScheduler.Default);
|
Task.Factory.StartNew(run, cancellationToken.Token, TaskCreationOptions.LongRunning, TaskScheduler.Default);
|
||||||
}
|
}
|
||||||
|
|
||||||
private void onTokenChanged(OAuthToken token) => config.Set(OsuSetting.Token, config.Get<bool>(OsuSetting.SavePassword) ? Token : string.Empty);
|
private void onTokenChanged(OAuthToken token) => config.Set(OsuSetting.Token, config.Get<bool>(OsuSetting.SavePassword) ? authentication.TokenString : string.Empty);
|
||||||
|
|
||||||
private readonly List<IOnlineComponent> components = new List<IOnlineComponent>();
|
private readonly List<IOnlineComponent> components = new List<IOnlineComponent>();
|
||||||
|
|
||||||
|
@ -15,6 +15,12 @@ namespace osu.Game.Online.API
|
|||||||
|
|
||||||
public readonly Bindable<OAuthToken> Token = new Bindable<OAuthToken>();
|
public readonly Bindable<OAuthToken> Token = new Bindable<OAuthToken>();
|
||||||
|
|
||||||
|
public string TokenString
|
||||||
|
{
|
||||||
|
get => Token.Value?.ToString();
|
||||||
|
set => Token.Value = string.IsNullOrEmpty(value) ? null : OAuthToken.Parse(value);
|
||||||
|
}
|
||||||
|
|
||||||
internal OAuth(string clientId, string clientSecret, string endpoint)
|
internal OAuth(string clientId, string clientSecret, string endpoint)
|
||||||
{
|
{
|
||||||
Debug.Assert(clientId != null);
|
Debug.Assert(clientId != null);
|
||||||
|
Loading…
x
Reference in New Issue
Block a user