mirror of
https://github.com/ppy/osu
synced 2024-12-29 18:32:39 +00: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 string Token
|
||||
{
|
||||
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);
|
||||
protected bool HasLogin => authentication.Token.Value != null || !string.IsNullOrEmpty(ProvidedUsername) && !string.IsNullOrEmpty(password);
|
||||
|
||||
private readonly CancellationTokenSource cancellationToken = new CancellationTokenSource();
|
||||
|
||||
@ -57,14 +51,14 @@ namespace osu.Game.Online.API
|
||||
log = Logger.GetLogger(LoggingTarget.Network);
|
||||
|
||||
ProvidedUsername = config.Get<string>(OsuSetting.Username);
|
||||
Token = config.Get<string>(OsuSetting.Token);
|
||||
|
||||
authentication.TokenString = config.Get<string>(OsuSetting.Token);
|
||||
authentication.Token.ValueChanged += onTokenChanged;
|
||||
|
||||
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>();
|
||||
|
||||
|
@ -15,6 +15,12 @@ namespace osu.Game.Online.API
|
||||
|
||||
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)
|
||||
{
|
||||
Debug.Assert(clientId != null);
|
||||
|
Loading…
Reference in New Issue
Block a user