diff --git a/VoidCat/Controllers/UserController.cs b/VoidCat/Controllers/UserController.cs index 8e7b005..c9e369f 100644 --- a/VoidCat/Controllers/UserController.cs +++ b/VoidCat/Controllers/UserController.cs @@ -1,4 +1,5 @@ using Microsoft.AspNetCore.Mvc; +using Newtonsoft.Json; using VoidCat.Database; using VoidCat.Model; using VoidCat.Services.Abstractions; @@ -137,17 +138,16 @@ public class UserController : Controller /// Confirm email verification code /// /// User id to verify - /// Verification code to check + /// Verification code to check /// [HttpPost] [Route("verify")] - public async Task VerifyCode([FromRoute] string id, [FromBody] string code) + public async Task VerifyCode([FromRoute] string id, [FromBody] VerifyCodeRequest req) { var user = await GetAuthorizedUser(id); if (user == default) return Unauthorized(); - var token = code.FromBase58Guid(); - if (!await _emailVerification.VerifyCode(user, token)) return BadRequest(); + if (!await _emailVerification.VerifyCode(user, req.Code)) return BadRequest(); user.Flags |= UserFlags.EmailVerified; await _store.UpdateProfile(user); @@ -167,4 +167,11 @@ public class UserController : Controller var gid = id.FromBase58Guid(); return await _store.Get(gid); } + + public class VerifyCodeRequest + { + [JsonProperty("code")] + [JsonConverter(typeof(Base58GuidConverter))] + public Guid Code { get; init; } + } }