Compare commits
2 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| 76be6dc8e7 | |||
| bc8a4414cd |
@@ -14,8 +14,9 @@ using Aoba.RPC;
|
|||||||
|
|
||||||
namespace AobaServer.Services;
|
namespace AobaServer.Services;
|
||||||
|
|
||||||
public class AobaAuthService(AccountsService accountsService, AuthInfo authInfo) : AuthRpc.AuthRpcBase
|
public class AobaAuthService(AccountsService accountsService, AuthConfigService authConfig) : AuthRpc.AuthRpcBase
|
||||||
{
|
{
|
||||||
|
[AllowAnonymous]
|
||||||
public override async Task<LoginResponse> Login(Credentials request, ServerCallContext context)
|
public override async Task<LoginResponse> Login(Credentials request, ServerCallContext context)
|
||||||
{
|
{
|
||||||
var user = await accountsService.VerifyLoginAsync(request.User, request.Password, context.CancellationToken);
|
var user = await accountsService.VerifyLoginAsync(request.User, request.Password, context.CancellationToken);
|
||||||
@@ -27,6 +28,7 @@ public class AobaAuthService(AccountsService accountsService, AuthInfo authInfo)
|
|||||||
Message = "Invalid login credentials"
|
Message = "Invalid login credentials"
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
var authInfo = await authConfig.GetDefaultAuthInfoAsync();
|
||||||
var token = user.GetToken(authInfo);
|
var token = user.GetToken(authInfo);
|
||||||
return new LoginResponse
|
return new LoginResponse
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -16,7 +16,7 @@ using System.Text.Json.Serialization;
|
|||||||
|
|
||||||
namespace AobaServer.Services;
|
namespace AobaServer.Services;
|
||||||
|
|
||||||
public class AobaRpcService(AobaService aobaService, AccountsService accountsService, AuthInfo authInfo) : AobaRpc.AobaRpcBase
|
public class AobaRpcService(AobaService aobaService, AccountsService accountsService, AuthConfigService authConfig) : AobaRpc.AobaRpcBase
|
||||||
{
|
{
|
||||||
public override async Task<MediaResponse> GetMedia(Id request, ServerCallContext context)
|
public override async Task<MediaResponse> GetMedia(Id request, ServerCallContext context)
|
||||||
{
|
{
|
||||||
@@ -37,6 +37,7 @@ public class AobaRpcService(AobaService aobaService, AccountsService accountsSer
|
|||||||
var user = await accountsService.GetUserAsync(userId, context.CancellationToken);
|
var user = await accountsService.GetUserAsync(userId, context.CancellationToken);
|
||||||
if (user == null)
|
if (user == null)
|
||||||
return new ShareXResponse { Error = "User does not exist" };
|
return new ShareXResponse { Error = "User does not exist" };
|
||||||
|
var authInfo = await authConfig.GetDefaultAuthInfoAsync();
|
||||||
var token = user.GetToken(authInfo);
|
var token = user.GetToken(authInfo);
|
||||||
var dest = new ShareXDestination
|
var dest = new ShareXDestination
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -14,7 +14,6 @@ namespace AobaServer.Services;
|
|||||||
|
|
||||||
public class MetricsRpcService(AuthConfigService authConfig): Aoba.RPC.Metrics.MetricsRpc.MetricsRpcBase
|
public class MetricsRpcService(AuthConfigService authConfig): Aoba.RPC.Metrics.MetricsRpc.MetricsRpcBase
|
||||||
{
|
{
|
||||||
[AllowAnonymous]
|
|
||||||
public override async Task<Jwt> GetToken(Empty request, ServerCallContext context)
|
public override async Task<Jwt> GetToken(Empty request, ServerCallContext context)
|
||||||
{
|
{
|
||||||
var authInfo = await authConfig.GetAuthInfoAsync("aoba", "metrics");
|
var authInfo = await authConfig.GetAuthInfoAsync("aoba", "metrics");
|
||||||
|
|||||||
Reference in New Issue
Block a user