forked from SoDOff-Project/sodoff
mmo authentication support
This commit is contained in:
parent
471f09280c
commit
2c30736193
@ -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);
|
||||
}
|
||||
}
|
||||
|
19
src/Schema/AuthenticationInfo.cs
Normal file
19
src/Schema/AuthenticationInfo.cs
Normal file
@ -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
|
||||
}
|
Loading…
x
Reference in New Issue
Block a user