mirror of
https://github.com/SoDOff-Project/sodoff.git
synced 2025-10-11 08:18:49 -07:00
mmo roles
This commit is contained in:
parent
2c30736193
commit
768affd3b2
@ -223,7 +223,9 @@ public class AuthenticationController : Controller {
|
||||
if (session != null) {
|
||||
info.Authenticated = true;
|
||||
info.DisplayName = session.Viking.Name;
|
||||
info.Role = Role.User;
|
||||
Role? role = session.Viking.MMORoles.FirstOrDefault()?.Role;
|
||||
if (role != null)
|
||||
info.Role = (Role)role;
|
||||
}
|
||||
return Ok(info);
|
||||
}
|
||||
|
@ -21,6 +21,7 @@ public class DBContext : DbContext {
|
||||
public DbSet<GameDataPair> GameDataPairs { get; set; } = null!;
|
||||
public DbSet<AchievementPoints> AchievementPoints { get; set; } = null!;
|
||||
public DbSet<ProfileAnswer> ProfileAnswers { get; set; } = null!;
|
||||
public DbSet<MMORole> MMORoles { get; set; } = null!;
|
||||
public DbSet<Party> Parties { get; set; } = null!;
|
||||
private readonly IOptions<ApiServerConfig> config;
|
||||
|
||||
@ -126,6 +127,9 @@ public class DBContext : DbContext {
|
||||
builder.Entity<Viking>().HasMany(v => v.Parties)
|
||||
.WithOne(e => e.Viking);
|
||||
|
||||
builder.Entity<Viking>().HasMany(v => v.MMORoles)
|
||||
.WithOne(e => e.Viking);
|
||||
|
||||
// Dragons
|
||||
builder.Entity<Dragon>().HasOne(d => d.Viking)
|
||||
.WithMany(e => e.Dragons)
|
||||
@ -232,5 +236,10 @@ public class DBContext : DbContext {
|
||||
builder.Entity<SceneData>().HasOne(i => i.Viking)
|
||||
.WithMany(i => i.SceneData)
|
||||
.HasForeignKey(e => e.VikingId);
|
||||
|
||||
// MMO Roles
|
||||
builder.Entity<MMORole>().HasOne(r => r.Viking)
|
||||
.WithMany(e => e.MMORoles)
|
||||
.HasForeignKey(e => e.VikingId);
|
||||
}
|
||||
}
|
||||
|
15
src/Model/MMORole.cs
Normal file
15
src/Model/MMORole.cs
Normal file
@ -0,0 +1,15 @@
|
||||
using sodoff.Schema;
|
||||
using System.ComponentModel.DataAnnotations;
|
||||
|
||||
namespace sodoff.Model;
|
||||
|
||||
public class MMORole {
|
||||
[Key]
|
||||
public int Id { get; set; }
|
||||
|
||||
public int VikingId { get; set; }
|
||||
|
||||
public Role Role { get; set; }
|
||||
|
||||
public virtual Viking? Viking { get; set; }
|
||||
}
|
@ -36,6 +36,7 @@ public class Viking {
|
||||
public virtual ICollection<ProfileAnswer> ProfileAnswers { get; set; } = null!;
|
||||
public virtual ICollection<SavedData> SavedData { get; set; } = null!;
|
||||
public virtual ICollection<Party> Parties { get; set; } = null!;
|
||||
public virtual ICollection<MMORole> MMORoles { get; set; } = null!;
|
||||
public virtual Dragon? SelectedDragon { get; set; }
|
||||
|
||||
public DateTime? CreationDate { get; set; }
|
||||
|
@ -15,5 +15,5 @@ public class AuthenticationInfo {
|
||||
|
||||
[Serializable]
|
||||
public enum Role {
|
||||
User, Admin, Moderator
|
||||
User = 0, Admin = 1, Moderator = 2
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user