Skip to content

Commit

Permalink
Merge pull request #8 from Goose-Bomb/dev
Browse files Browse the repository at this point in the history
Ready for 2nd release version
  • Loading branch information
Nullkooland authored Aug 27, 2019
2 parents 5785da5 + 906a27c commit e677352
Show file tree
Hide file tree
Showing 9 changed files with 35 additions and 55 deletions.
32 changes: 0 additions & 32 deletions GBCLV3.Tests/AuthTest.cs

This file was deleted.

4 changes: 3 additions & 1 deletion GBCLV3/Models/Config.cs
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,9 @@ class Config
[JsonIgnore]
public string Password { get; set; }

public bool RefreshAuth { get; set; }
public bool UseToken { get; set; }

public string ClientToken { get; set; }

public string AccessToken { get; set; }

Expand Down
3 changes: 2 additions & 1 deletion GBCLV3/Models/Launcher/Authentication.cs
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,8 @@ class AuthResult

public List<AuthUserProfile> AvailableProfiles { get; set; }

public string ClientToken { get; set; }

public string AccessToken { get; set; }

public string UserType { get; set; }
Expand All @@ -56,7 +58,6 @@ class AuthRequest

public string Username { get; set; }


public string Password { get; set; }

public string ClientToken { get; set; }
Expand Down
4 changes: 2 additions & 2 deletions GBCLV3/Properties/AssemblyInfo.cs
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,8 @@
[assembly: AssemblyCopyright("Copyright © Goose Bomb 2019")]
[assembly: AssemblyTrademark("")]
[assembly: AssemblyCulture("")]
[assembly: AssemblyVersion("3.0.1.33")]
[assembly: AssemblyFileVersion("3.0.1.33")]
[assembly: AssemblyVersion("3.0.2.36")]
[assembly: AssemblyFileVersion("3.0.2.36")]

[assembly: ComVisible(false)]

Expand Down
10 changes: 4 additions & 6 deletions GBCLV3/Services/Launcher/AuthService.cs
Original file line number Diff line number Diff line change
Expand Up @@ -50,16 +50,12 @@ public static async Task<AuthResult> LoginAsync(string email, string password)
return await OnlineAuthenticateAsync(JsonSerializer.Serialize(request, _jsonOptions), false);
}

public static async Task<AuthResult> RefreshAsync(string accessToken, string uuid)
public static async Task<AuthResult> RefreshAsync(string clientToken, string accessToken)
{
var request = new RefreshRequest
{
ClientToken = clientToken,
AccessToken = accessToken,
ClientToken = _guid,
SelectedProfile = new AuthUserProfile
{
Id = uuid,
}
};

return await OnlineAuthenticateAsync(JsonSerializer.Serialize(request, _jsonOptions), true);
Expand All @@ -81,6 +77,7 @@ public static AuthResult GetOfflineProfile(string username)
{
Username = username,
UUID = CryptUtil.GetStringMD5(username),
ClientToken = _guid,
AccessToken = _guid,
UserType = "mojang",
IsSuccessful = true,
Expand Down Expand Up @@ -113,6 +110,7 @@ private static async Task<AuthResult> OnlineAuthenticateAsync(string requestJson
result.Username = response.SelectedProfile.Name;
result.UUID = response.SelectedProfile.Id;
result.AvailableProfiles = response.AvailableProfiles;
result.ClientToken = response.ClientToken;
result.AccessToken = response.AccessToken;
result.UserType = response.SelectedProfile.Legacy ? "legacy" : "mojang";
}
Expand Down
4 changes: 2 additions & 2 deletions GBCLV3/ViewModels/GameSettingsViewModel.cs
Original file line number Diff line number Diff line change
Expand Up @@ -130,10 +130,10 @@ public bool IsOfflineMode

public bool IsRefreshAuth
{
get => _config.RefreshAuth;
get => _config.UseToken;
set
{
_config.RefreshAuth = value;
_config.UseToken = value;
}
}

Expand Down
23 changes: 14 additions & 9 deletions GBCLV3/ViewModels/Pages/LaunchViewModel.cs
Original file line number Diff line number Diff line change
Expand Up @@ -152,18 +152,28 @@ public async void Launch()

var authResult =
_config.OfflineMode ? AuthService.GetOfflineProfile(_config.Username) :
_config.RefreshAuth ? await AuthService.RefreshAsync(_config.AccessToken, _config.UUID) :
await AuthService.LoginAsync(_config.Email, _config.Password);
_config.UseToken ? await AuthService.RefreshAsync(_config.ClientToken, _config.AccessToken) :
await AuthService.LoginAsync(_config.Email, _config.Password);

if (!authResult.IsSuccessful)
if (authResult.IsSuccessful)
{
_config.UseToken = true;
_config.ClientToken = authResult.ClientToken;
_config.AccessToken = authResult.AccessToken;

_config.Username = authResult.Username;
_config.UUID = authResult.UUID;
_eventAggregator.Publish(new UsernameChangedEvent());
}
else
{
_statusVM.Status = LaunchStatus.Failed;

if (authResult.ErrorType == AuthErrorType.InvalidToken)
{
// Clear the invalid token, using email and password for authentication next time
_config.AccessToken = null;
_config.RefreshAuth = false;
_config.UseToken = false;
}

_windowManager.ShowMessageBox(authResult.ErrorMessage, "${AuthFailed}",
Expand All @@ -172,11 +182,6 @@ public async void Launch()
return;
}

_config.Username = authResult.Username;
_config.AccessToken = authResult.AccessToken;
_config.UUID = authResult.UUID;
_eventAggregator.Publish(new UsernameChangedEvent());

_statusVM.Status = LaunchStatus.ProcessingDependencies;
var launchVersion = _versionService.GetByID(SelectedVersionID);

Expand Down
5 changes: 4 additions & 1 deletion README-CN.md
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,10 @@
- [x] 版本分离
- [x] 1.13+ 支持
- [x] Forge版本
- [x] 验证登录

- [x] 验证登录
- [x] 邮箱密码登录
- [x] 令牌刷新

- [x] 下载
- [x] 并发下载
Expand Down
5 changes: 4 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,10 @@
- [x] Version segregation
- [x] 1.13+ Support
- [x] Forge version
- [x] Authentication

- [x] Authentication
- [x] Email and Password Login
- [x] Token Refresh

- [x] Download
- [x] Parallel download
Expand Down

0 comments on commit e677352

Please sign in to comment.