Skip to content

Commit

Permalink
add username
Browse files Browse the repository at this point in the history
  • Loading branch information
Lightczx committed Feb 6, 2024
1 parent 058a6e2 commit 4724b18
Show file tree
Hide file tree
Showing 3 changed files with 4 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -23,15 +23,13 @@ public class GithubAuthorizationController : ControllerBase
private readonly AppDbContext appDbContext;
private readonly GithubOptions githubOptions;
private readonly PassportService passportService;
private readonly UserManager<HutaoUser> userManager;

public GithubAuthorizationController(IServiceProvider serviceProvider)
{
httpClient = serviceProvider.GetRequiredService<HttpClient>();
appDbContext = serviceProvider.GetRequiredService<AppDbContext>();
githubOptions = serviceProvider.GetRequiredService<AppOptions>().Github;
passportService = serviceProvider.GetRequiredService<PassportService>();
userManager = serviceProvider.GetRequiredService<UserManager<HutaoUser>>();
}

[Authorize]
Expand All @@ -53,7 +51,7 @@ public async Task<IActionResult> RedirectLoginAsync()
return Redirect($"https://github.com/login/oauth/authorize?client_id={githubOptions.ClientId}&state={state}");
}

[HttpGet("Authorize")]
[HttpGet("Github/Authorize")]
public async Task<IActionResult> HandleAuthorizationCallbackAsync([FromQuery(Name = "code")] string code, [FromQuery(Name = "state")] string state)
{
if (string.IsNullOrEmpty(code) || string.IsNullOrEmpty(state))
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -180,6 +180,7 @@ public async Task<IActionResult> GetUserInfoAsync()
return Response<UserInfo>.Success("获取用户信息成功", new()
{
NormalizedUserName = user.NormalizedUserName ?? user.UserName,
UserName = user.UserName,
IsLicensedDeveloper = user.IsLicensedDeveloper,
IsMaintainer = user.IsMaintainer,
GachaLogExpireAt = DateTimeOffset.FromUnixTimeSeconds(user.GachaLogExpireAt),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,8 @@ public class UserInfo
{
public string? NormalizedUserName { get; set; }

public string? UserName { get; set; }

public bool IsLicensedDeveloper { get; set; }

public bool IsMaintainer { get; set; }
Expand Down

0 comments on commit 4724b18

Please sign in to comment.