Update key store to validate account and site
Docker Build and Release Upload / build (push) Successful in 1m24s
Docker Build and Release Upload / build (push) Successful in 1m24s
This commit is contained in:
@@ -2,6 +2,8 @@ using Microsoft.AspNetCore.Mvc;
|
||||
using System.Web.Http;
|
||||
using StackExchange.Redis;
|
||||
using Auth.Services.DatabaseService;
|
||||
using Auth.Services;
|
||||
using Auth.Entities;
|
||||
|
||||
namespace Auth.Controllers {
|
||||
[ApiController]
|
||||
@@ -18,16 +20,26 @@ namespace Auth.Controllers {
|
||||
|
||||
[Route("get")]
|
||||
[HttpGet]
|
||||
public async Task<ActionResult<string>> Get(string key) {
|
||||
RedisValue result = await _redisdb.StringGetAsync(key);
|
||||
return Ok(result.ToString());
|
||||
public async Task<ActionResult<string>> Get(string JWT, string key) {
|
||||
Account? account = AuthJWT.ValidateJWTToken(JWT);
|
||||
if (account != null) {
|
||||
RedisValue result = await _redisdb.StringGetAsync( account.Site + key);
|
||||
return Ok(result.ToString());
|
||||
} else {
|
||||
return BadRequest("JWT Not Valid");
|
||||
}
|
||||
}
|
||||
|
||||
[Route("set")]
|
||||
[HttpGet]
|
||||
public async Task<ActionResult> Set(string key, string value) {
|
||||
await _redisdb.StringSetAsync(key, value);
|
||||
return Ok();
|
||||
public async Task<ActionResult> Set(string JWT, string key, string value) {
|
||||
Account? account = AuthJWT.ValidateJWTToken(JWT);
|
||||
if (account != null) {
|
||||
await _redisdb.StringSetAsync(account.Site + key, value);
|
||||
return Ok();
|
||||
} else {
|
||||
return BadRequest("JWT Not Valid");
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user