diff --git a/src/Controllers/Common/AuthenticationController.cs b/src/Controllers/Common/AuthenticationController.cs index 9fecc4d..494e7e2 100644 --- a/src/Controllers/Common/AuthenticationController.cs +++ b/src/Controllers/Common/AuthenticationController.cs @@ -212,4 +212,19 @@ public class AuthenticationController : Controller { return Ok(MembershipUserStatus.Success); } + + [HttpPost] + [Produces("application/xml")] + [Route("Authentication/MMOAuthentication")] + public IActionResult MMOAuthentication([FromForm] Guid token) { + AuthenticationInfo info = new(); + info.Authenticated = false; + var session = ctx.Sessions.FirstOrDefault(x => x.ApiToken == token); + if (session != null) { + info.Authenticated = true; + info.DisplayName = session.Viking.Name; + info.Role = Role.User; + } + return Ok(info); + } } diff --git a/src/Schema/AuthenticationInfo.cs b/src/Schema/AuthenticationInfo.cs new file mode 100644 index 0000000..876b3a4 --- /dev/null +++ b/src/Schema/AuthenticationInfo.cs @@ -0,0 +1,19 @@ +using System.Xml.Serialization; +namespace sodoff.Schema; + +[Serializable] +public class AuthenticationInfo { + [XmlElement] + public bool Authenticated { get; set; } + + [XmlElement] + public string DisplayName { get; set; } = string.Empty; + + [XmlElement] + public Role Role { get; set; } = Role.User; +} + +[Serializable] +public enum Role { + User, Admin, Moderator +}