Merge pull request #229 from Moonlight-Panel/AddPermissionSystem
Added permission system and improved UIs and the IdentityService
This commit is contained in:
@@ -46,6 +46,7 @@ public class DataContext : DbContext
|
|||||||
public DbSet<WebSpace> WebSpaces { get; set; }
|
public DbSet<WebSpace> WebSpaces { get; set; }
|
||||||
public DbSet<SupportChatMessage> SupportChatMessages { get; set; }
|
public DbSet<SupportChatMessage> SupportChatMessages { get; set; }
|
||||||
public DbSet<IpBan> IpBans { get; set; }
|
public DbSet<IpBan> IpBans { get; set; }
|
||||||
|
public DbSet<PermissionGroup> PermissionGroups { get; set; }
|
||||||
|
|
||||||
protected override void OnConfiguring(DbContextOptionsBuilder optionsBuilder)
|
protected override void OnConfiguring(DbContextOptionsBuilder optionsBuilder)
|
||||||
{
|
{
|
||||||
|
|||||||
8
Moonlight/App/Database/Entities/PermissionGroup.cs
Normal file
8
Moonlight/App/Database/Entities/PermissionGroup.cs
Normal file
@@ -0,0 +1,8 @@
|
|||||||
|
namespace Moonlight.App.Database.Entities;
|
||||||
|
|
||||||
|
public class PermissionGroup
|
||||||
|
{
|
||||||
|
public int Id { get; set; }
|
||||||
|
public string Name { get; set; } = "";
|
||||||
|
public byte[] Permissions { get; set; } = Array.Empty<byte>();
|
||||||
|
}
|
||||||
@@ -1,4 +1,5 @@
|
|||||||
using Moonlight.App.Models.Misc;
|
using System.ComponentModel.DataAnnotations;
|
||||||
|
using Moonlight.App.Models.Misc;
|
||||||
|
|
||||||
namespace Moonlight.App.Database.Entities;
|
namespace Moonlight.App.Database.Entities;
|
||||||
|
|
||||||
@@ -39,6 +40,8 @@ public class User
|
|||||||
public bool TotpEnabled { get; set; } = false;
|
public bool TotpEnabled { get; set; } = false;
|
||||||
public string TotpSecret { get; set; } = "";
|
public string TotpSecret { get; set; } = "";
|
||||||
public DateTime TokenValidTime { get; set; } = DateTime.UtcNow;
|
public DateTime TokenValidTime { get; set; } = DateTime.UtcNow;
|
||||||
|
public byte[] Permissions { get; set; } = Array.Empty<byte>();
|
||||||
|
public PermissionGroup? PermissionGroup { get; set; }
|
||||||
|
|
||||||
// Discord
|
// Discord
|
||||||
public ulong DiscordId { get; set; }
|
public ulong DiscordId { get; set; }
|
||||||
|
|||||||
1109
Moonlight/App/Database/Migrations/20230715095531_AddPermissions.Designer.cs
generated
Normal file
1109
Moonlight/App/Database/Migrations/20230715095531_AddPermissions.Designer.cs
generated
Normal file
File diff suppressed because it is too large
Load Diff
@@ -0,0 +1,28 @@
|
|||||||
|
using Microsoft.EntityFrameworkCore.Migrations;
|
||||||
|
|
||||||
|
#nullable disable
|
||||||
|
|
||||||
|
namespace Moonlight.App.Database.Migrations
|
||||||
|
{
|
||||||
|
/// <inheritdoc />
|
||||||
|
public partial class AddPermissions : Migration
|
||||||
|
{
|
||||||
|
/// <inheritdoc />
|
||||||
|
protected override void Up(MigrationBuilder migrationBuilder)
|
||||||
|
{
|
||||||
|
migrationBuilder.AddColumn<byte[]>(
|
||||||
|
name: "Permissions",
|
||||||
|
table: "Users",
|
||||||
|
type: "longblob",
|
||||||
|
nullable: false);
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <inheritdoc />
|
||||||
|
protected override void Down(MigrationBuilder migrationBuilder)
|
||||||
|
{
|
||||||
|
migrationBuilder.DropColumn(
|
||||||
|
name: "Permissions",
|
||||||
|
table: "Users");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
1139
Moonlight/App/Database/Migrations/20230715214550_AddPermissionGroup.Designer.cs
generated
Normal file
1139
Moonlight/App/Database/Migrations/20230715214550_AddPermissionGroup.Designer.cs
generated
Normal file
File diff suppressed because it is too large
Load Diff
@@ -0,0 +1,68 @@
|
|||||||
|
using Microsoft.EntityFrameworkCore.Metadata;
|
||||||
|
using Microsoft.EntityFrameworkCore.Migrations;
|
||||||
|
|
||||||
|
#nullable disable
|
||||||
|
|
||||||
|
namespace Moonlight.App.Database.Migrations
|
||||||
|
{
|
||||||
|
/// <inheritdoc />
|
||||||
|
public partial class AddPermissionGroup : Migration
|
||||||
|
{
|
||||||
|
/// <inheritdoc />
|
||||||
|
protected override void Up(MigrationBuilder migrationBuilder)
|
||||||
|
{
|
||||||
|
migrationBuilder.AddColumn<int>(
|
||||||
|
name: "PermissionGroupId",
|
||||||
|
table: "Users",
|
||||||
|
type: "int",
|
||||||
|
nullable: true);
|
||||||
|
|
||||||
|
migrationBuilder.CreateTable(
|
||||||
|
name: "PermissionGroups",
|
||||||
|
columns: table => new
|
||||||
|
{
|
||||||
|
Id = table.Column<int>(type: "int", nullable: false)
|
||||||
|
.Annotation("MySql:ValueGenerationStrategy", MySqlValueGenerationStrategy.IdentityColumn),
|
||||||
|
Name = table.Column<string>(type: "longtext", nullable: false)
|
||||||
|
.Annotation("MySql:CharSet", "utf8mb4"),
|
||||||
|
Permissions = table.Column<byte[]>(type: "longblob", nullable: false)
|
||||||
|
},
|
||||||
|
constraints: table =>
|
||||||
|
{
|
||||||
|
table.PrimaryKey("PK_PermissionGroups", x => x.Id);
|
||||||
|
})
|
||||||
|
.Annotation("MySql:CharSet", "utf8mb4");
|
||||||
|
|
||||||
|
migrationBuilder.CreateIndex(
|
||||||
|
name: "IX_Users_PermissionGroupId",
|
||||||
|
table: "Users",
|
||||||
|
column: "PermissionGroupId");
|
||||||
|
|
||||||
|
migrationBuilder.AddForeignKey(
|
||||||
|
name: "FK_Users_PermissionGroups_PermissionGroupId",
|
||||||
|
table: "Users",
|
||||||
|
column: "PermissionGroupId",
|
||||||
|
principalTable: "PermissionGroups",
|
||||||
|
principalColumn: "Id");
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <inheritdoc />
|
||||||
|
protected override void Down(MigrationBuilder migrationBuilder)
|
||||||
|
{
|
||||||
|
migrationBuilder.DropForeignKey(
|
||||||
|
name: "FK_Users_PermissionGroups_PermissionGroupId",
|
||||||
|
table: "Users");
|
||||||
|
|
||||||
|
migrationBuilder.DropTable(
|
||||||
|
name: "PermissionGroups");
|
||||||
|
|
||||||
|
migrationBuilder.DropIndex(
|
||||||
|
name: "IX_Users_PermissionGroupId",
|
||||||
|
table: "Users");
|
||||||
|
|
||||||
|
migrationBuilder.DropColumn(
|
||||||
|
name: "PermissionGroupId",
|
||||||
|
table: "Users");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -475,6 +475,25 @@ namespace Moonlight.App.Database.Migrations
|
|||||||
b.ToTable("NotificationClients");
|
b.ToTable("NotificationClients");
|
||||||
});
|
});
|
||||||
|
|
||||||
|
modelBuilder.Entity("Moonlight.App.Database.Entities.PermissionGroup", b =>
|
||||||
|
{
|
||||||
|
b.Property<int>("Id")
|
||||||
|
.ValueGeneratedOnAdd()
|
||||||
|
.HasColumnType("int");
|
||||||
|
|
||||||
|
b.Property<string>("Name")
|
||||||
|
.IsRequired()
|
||||||
|
.HasColumnType("longtext");
|
||||||
|
|
||||||
|
b.Property<byte[]>("Permissions")
|
||||||
|
.IsRequired()
|
||||||
|
.HasColumnType("longblob");
|
||||||
|
|
||||||
|
b.HasKey("Id");
|
||||||
|
|
||||||
|
b.ToTable("PermissionGroups");
|
||||||
|
});
|
||||||
|
|
||||||
modelBuilder.Entity("Moonlight.App.Database.Entities.Revoke", b =>
|
modelBuilder.Entity("Moonlight.App.Database.Entities.Revoke", b =>
|
||||||
{
|
{
|
||||||
b.Property<int>("Id")
|
b.Property<int>("Id")
|
||||||
@@ -798,6 +817,13 @@ namespace Moonlight.App.Database.Migrations
|
|||||||
.IsRequired()
|
.IsRequired()
|
||||||
.HasColumnType("longtext");
|
.HasColumnType("longtext");
|
||||||
|
|
||||||
|
b.Property<int?>("PermissionGroupId")
|
||||||
|
.HasColumnType("int");
|
||||||
|
|
||||||
|
b.Property<byte[]>("Permissions")
|
||||||
|
.IsRequired()
|
||||||
|
.HasColumnType("longblob");
|
||||||
|
|
||||||
b.Property<int>("Rating")
|
b.Property<int>("Rating")
|
||||||
.HasColumnType("int");
|
.HasColumnType("int");
|
||||||
|
|
||||||
@@ -845,6 +871,8 @@ namespace Moonlight.App.Database.Migrations
|
|||||||
|
|
||||||
b.HasIndex("CurrentSubscriptionId");
|
b.HasIndex("CurrentSubscriptionId");
|
||||||
|
|
||||||
|
b.HasIndex("PermissionGroupId");
|
||||||
|
|
||||||
b.ToTable("Users");
|
b.ToTable("Users");
|
||||||
});
|
});
|
||||||
|
|
||||||
@@ -1049,7 +1077,13 @@ namespace Moonlight.App.Database.Migrations
|
|||||||
.WithMany()
|
.WithMany()
|
||||||
.HasForeignKey("CurrentSubscriptionId");
|
.HasForeignKey("CurrentSubscriptionId");
|
||||||
|
|
||||||
|
b.HasOne("Moonlight.App.Database.Entities.PermissionGroup", "PermissionGroup")
|
||||||
|
.WithMany()
|
||||||
|
.HasForeignKey("PermissionGroupId");
|
||||||
|
|
||||||
b.Navigation("CurrentSubscription");
|
b.Navigation("CurrentSubscription");
|
||||||
|
|
||||||
|
b.Navigation("PermissionGroup");
|
||||||
});
|
});
|
||||||
|
|
||||||
modelBuilder.Entity("Moonlight.App.Database.Entities.WebSpace", b =>
|
modelBuilder.Entity("Moonlight.App.Database.Entities.WebSpace", b =>
|
||||||
|
|||||||
88
Moonlight/App/Helpers/BitHelper.cs
Normal file
88
Moonlight/App/Helpers/BitHelper.cs
Normal file
@@ -0,0 +1,88 @@
|
|||||||
|
namespace Moonlight.App.Helpers;
|
||||||
|
|
||||||
|
public class BitHelper
|
||||||
|
{
|
||||||
|
public static bool ReadBit(byte[] byteArray, int bitIndex)
|
||||||
|
{
|
||||||
|
if (bitIndex < 0)
|
||||||
|
throw new ArgumentOutOfRangeException("bitIndex");
|
||||||
|
|
||||||
|
int byteIndex = bitIndex / 8;
|
||||||
|
if (byteIndex >= byteArray.Length)
|
||||||
|
throw new ArgumentOutOfRangeException("bitIndex");
|
||||||
|
|
||||||
|
int bitNumber = bitIndex % 8;
|
||||||
|
byte mask = (byte)(1 << bitNumber);
|
||||||
|
|
||||||
|
return (byteArray[byteIndex] & mask) != 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
public static byte[] WriteBit(byte[] byteArray, int bitIndex, bool value)
|
||||||
|
{
|
||||||
|
if (bitIndex < 0)
|
||||||
|
throw new ArgumentOutOfRangeException("bitIndex");
|
||||||
|
|
||||||
|
int byteIndex = bitIndex / 8;
|
||||||
|
byte[] resultArray;
|
||||||
|
|
||||||
|
if (byteIndex >= byteArray.Length)
|
||||||
|
{
|
||||||
|
// Create a new array with increased size and copy elements from old array
|
||||||
|
resultArray = new byte[byteIndex + 1];
|
||||||
|
Array.Copy(byteArray, resultArray, byteArray.Length);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
// Create a new array and copy elements from old array
|
||||||
|
resultArray = new byte[byteArray.Length];
|
||||||
|
Array.Copy(byteArray, resultArray, byteArray.Length);
|
||||||
|
}
|
||||||
|
|
||||||
|
int bitNumber = bitIndex % 8;
|
||||||
|
byte mask = (byte)(1 << bitNumber);
|
||||||
|
|
||||||
|
if (value)
|
||||||
|
resultArray[byteIndex] |= mask; // Set the bit to 1
|
||||||
|
else
|
||||||
|
resultArray[byteIndex] &= (byte)~mask; // Set the bit to 0
|
||||||
|
|
||||||
|
return resultArray;
|
||||||
|
}
|
||||||
|
|
||||||
|
public static byte[] OverwriteByteArrays(byte[] targetArray, byte[] overwriteArray)
|
||||||
|
{
|
||||||
|
int targetLength = targetArray.Length;
|
||||||
|
int overwriteLength = overwriteArray.Length;
|
||||||
|
|
||||||
|
int maxLength = Math.Max(targetLength, overwriteLength);
|
||||||
|
|
||||||
|
byte[] resultArray = new byte[maxLength];
|
||||||
|
|
||||||
|
for (int i = 0; i < maxLength; i++)
|
||||||
|
{
|
||||||
|
byte targetByte = i < targetLength ? targetArray[i] : (byte)0;
|
||||||
|
byte overwriteByte = i < overwriteLength ? overwriteArray[i] : (byte)0;
|
||||||
|
|
||||||
|
for (int j = 0; j < 8; j++)
|
||||||
|
{
|
||||||
|
bool overwriteBit = (overwriteByte & (1 << j)) != 0;
|
||||||
|
if (i < targetLength)
|
||||||
|
{
|
||||||
|
bool targetBit = (targetByte & (1 << j)) != 0;
|
||||||
|
if (overwriteBit)
|
||||||
|
{
|
||||||
|
targetByte = targetBit ? (byte)(targetByte | (1 << j)) : (byte)(targetByte & ~(1 << j));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else if (overwriteBit)
|
||||||
|
{
|
||||||
|
targetByte |= (byte)(1 << j);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
resultArray[i] = targetByte;
|
||||||
|
}
|
||||||
|
|
||||||
|
return resultArray;
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -24,7 +24,7 @@ public class BillingController : Controller
|
|||||||
[HttpGet("cancel")]
|
[HttpGet("cancel")]
|
||||||
public async Task<ActionResult> Cancel()
|
public async Task<ActionResult> Cancel()
|
||||||
{
|
{
|
||||||
var user = await IdentityService.Get();
|
var user = IdentityService.User;
|
||||||
|
|
||||||
if (user == null)
|
if (user == null)
|
||||||
return Redirect("/login");
|
return Redirect("/login");
|
||||||
@@ -35,7 +35,7 @@ public class BillingController : Controller
|
|||||||
[HttpGet("success")]
|
[HttpGet("success")]
|
||||||
public async Task<ActionResult> Success()
|
public async Task<ActionResult> Success()
|
||||||
{
|
{
|
||||||
var user = await IdentityService.Get();
|
var user = IdentityService.User;
|
||||||
|
|
||||||
if (user == null)
|
if (user == null)
|
||||||
return Redirect("/login");
|
return Redirect("/login");
|
||||||
|
|||||||
@@ -25,7 +25,7 @@ public class RegisterController : Controller
|
|||||||
[HttpGet]
|
[HttpGet]
|
||||||
public async Task<ActionResult<TokenRegister>> Register()
|
public async Task<ActionResult<TokenRegister>> Register()
|
||||||
{
|
{
|
||||||
var user = await IdentityService.Get();
|
var user = IdentityService.User;
|
||||||
|
|
||||||
if (user == null)
|
if (user == null)
|
||||||
return NotFound();
|
return NotFound();
|
||||||
|
|||||||
@@ -54,7 +54,7 @@ public class OAuth2Controller : Controller
|
|||||||
{
|
{
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
var currentUser = await IdentityService.Get();
|
var currentUser = IdentityService.User;
|
||||||
|
|
||||||
if (currentUser != null)
|
if (currentUser != null)
|
||||||
{
|
{
|
||||||
|
|||||||
34
Moonlight/App/Models/Forms/UserEditDataModel.cs
Normal file
34
Moonlight/App/Models/Forms/UserEditDataModel.cs
Normal file
@@ -0,0 +1,34 @@
|
|||||||
|
using System.ComponentModel.DataAnnotations;
|
||||||
|
using Moonlight.App.Database.Entities;
|
||||||
|
using Moonlight.App.Models.Misc;
|
||||||
|
|
||||||
|
namespace Moonlight.App.Models.Forms;
|
||||||
|
|
||||||
|
public class UserEditDataModel
|
||||||
|
{
|
||||||
|
[Required]
|
||||||
|
public string FirstName { get; set; } = "";
|
||||||
|
|
||||||
|
[Required]
|
||||||
|
public string LastName { get; set; } = "";
|
||||||
|
|
||||||
|
[Required]
|
||||||
|
public string Email { get; set; } = "";
|
||||||
|
|
||||||
|
[Required]
|
||||||
|
public string Address { get; set; } = "";
|
||||||
|
|
||||||
|
[Required]
|
||||||
|
public string City { get; set; } = "";
|
||||||
|
|
||||||
|
[Required]
|
||||||
|
public string State { get; set; } = "";
|
||||||
|
|
||||||
|
[Required]
|
||||||
|
public string Country { get; set; } = "";
|
||||||
|
|
||||||
|
public bool Admin { get; set; }
|
||||||
|
public bool TotpEnabled { get; set; }
|
||||||
|
public ulong DiscordId { get; set; }
|
||||||
|
public PermissionGroup? PermissionGroup { get; set; }
|
||||||
|
}
|
||||||
10
Moonlight/App/Perms/Permission.cs
Normal file
10
Moonlight/App/Perms/Permission.cs
Normal file
@@ -0,0 +1,10 @@
|
|||||||
|
namespace Moonlight.App.Perms;
|
||||||
|
|
||||||
|
public class Permission
|
||||||
|
{
|
||||||
|
public int Index { get; set; } = 0;
|
||||||
|
public string Name { get; set; } = "";
|
||||||
|
public string Description { get; set; } = "";
|
||||||
|
|
||||||
|
public static implicit operator int(Permission permission) => permission.Index;
|
||||||
|
}
|
||||||
11
Moonlight/App/Perms/PermissionRequired.cs
Normal file
11
Moonlight/App/Perms/PermissionRequired.cs
Normal file
@@ -0,0 +1,11 @@
|
|||||||
|
namespace Moonlight.App.Perms;
|
||||||
|
|
||||||
|
public class PermissionRequired : Attribute
|
||||||
|
{
|
||||||
|
public string Name { get; private set; }
|
||||||
|
|
||||||
|
public PermissionRequired(string name)
|
||||||
|
{
|
||||||
|
Name = name;
|
||||||
|
}
|
||||||
|
}
|
||||||
55
Moonlight/App/Perms/PermissionStorage.cs
Normal file
55
Moonlight/App/Perms/PermissionStorage.cs
Normal file
@@ -0,0 +1,55 @@
|
|||||||
|
using System.Data;
|
||||||
|
using Moonlight.App.Helpers;
|
||||||
|
|
||||||
|
namespace Moonlight.App.Perms;
|
||||||
|
|
||||||
|
public class PermissionStorage
|
||||||
|
{
|
||||||
|
public byte[] Data;
|
||||||
|
public bool IsReadyOnly;
|
||||||
|
|
||||||
|
public PermissionStorage(byte[] data, bool isReadyOnly = false)
|
||||||
|
{
|
||||||
|
Data = data;
|
||||||
|
IsReadyOnly = isReadyOnly;
|
||||||
|
}
|
||||||
|
|
||||||
|
public bool this[Permission permission]
|
||||||
|
{
|
||||||
|
get
|
||||||
|
{
|
||||||
|
try
|
||||||
|
{
|
||||||
|
return BitHelper.ReadBit(Data, permission.Index);
|
||||||
|
}
|
||||||
|
catch (ArgumentOutOfRangeException)
|
||||||
|
{
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
catch (Exception e)
|
||||||
|
{
|
||||||
|
Logger.Verbose("Error reading permissions. (Can be intentional)");
|
||||||
|
Logger.Verbose(e);
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
set
|
||||||
|
{
|
||||||
|
if (IsReadyOnly)
|
||||||
|
throw new ReadOnlyException();
|
||||||
|
|
||||||
|
Data = BitHelper.WriteBit(Data, permission.Index, value);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public bool HasAnyPermissions()
|
||||||
|
{
|
||||||
|
foreach (var permission in Permissions.GetAllPermissions())
|
||||||
|
{
|
||||||
|
if (this[permission])
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
||||||
424
Moonlight/App/Perms/Permissions.cs
Normal file
424
Moonlight/App/Perms/Permissions.cs
Normal file
@@ -0,0 +1,424 @@
|
|||||||
|
namespace Moonlight.App.Perms;
|
||||||
|
|
||||||
|
public static class Permissions
|
||||||
|
{
|
||||||
|
public static Permission AdminDashboard = new()
|
||||||
|
{
|
||||||
|
Index = 0,
|
||||||
|
Name = "Admin Dashboard",
|
||||||
|
Description = "Access the main admin dashboard page"
|
||||||
|
};
|
||||||
|
|
||||||
|
public static Permission AdminStatistics = new()
|
||||||
|
{
|
||||||
|
Index = 1,
|
||||||
|
Name = "Admin Statistics",
|
||||||
|
Description = "View statistical information about the moonlight instance"
|
||||||
|
};
|
||||||
|
|
||||||
|
public static Permission AdminDomains = new()
|
||||||
|
{
|
||||||
|
Index = 4,
|
||||||
|
Name = "Admin Domains",
|
||||||
|
Description = "Manage domains in the admin area"
|
||||||
|
};
|
||||||
|
|
||||||
|
public static Permission AdminNewDomain = new()
|
||||||
|
{
|
||||||
|
Index = 5,
|
||||||
|
Name = "Admin New Domain",
|
||||||
|
Description = "Create a new domain in the admin area"
|
||||||
|
};
|
||||||
|
|
||||||
|
public static Permission AdminSharedDomains = new()
|
||||||
|
{
|
||||||
|
Index = 6,
|
||||||
|
Name = "Admin Shared Domains",
|
||||||
|
Description = "Manage shared domains in the admin area"
|
||||||
|
};
|
||||||
|
|
||||||
|
public static Permission AdminNewSharedDomain = new()
|
||||||
|
{
|
||||||
|
Index = 7,
|
||||||
|
Name = "Admin New Shared Domain",
|
||||||
|
Description = "Create a new shared domain in the admin area"
|
||||||
|
};
|
||||||
|
|
||||||
|
public static Permission AdminNodeDdos = new()
|
||||||
|
{
|
||||||
|
Index = 8,
|
||||||
|
Name = "Admin Node DDoS",
|
||||||
|
Description = "Manage DDoS protection for nodes in the admin area"
|
||||||
|
};
|
||||||
|
|
||||||
|
public static Permission AdminNodeEdit = new()
|
||||||
|
{
|
||||||
|
Index = 9,
|
||||||
|
Name = "Admin Node Edit",
|
||||||
|
Description = "Edit node settings in the admin area"
|
||||||
|
};
|
||||||
|
|
||||||
|
public static Permission AdminNodes = new()
|
||||||
|
{
|
||||||
|
Index = 10,
|
||||||
|
Name = "Admin Node",
|
||||||
|
Description = "Access the node management page in the admin area"
|
||||||
|
};
|
||||||
|
|
||||||
|
public static Permission AdminNewNode = new()
|
||||||
|
{
|
||||||
|
Index = 11,
|
||||||
|
Name = "Admin New Node",
|
||||||
|
Description = "Create a new node in the admin area"
|
||||||
|
};
|
||||||
|
|
||||||
|
public static Permission AdminNodeSetup = new()
|
||||||
|
{
|
||||||
|
Index = 12,
|
||||||
|
Name = "Admin Node Setup",
|
||||||
|
Description = "Set up a node in the admin area"
|
||||||
|
};
|
||||||
|
|
||||||
|
public static Permission AdminNodeView = new()
|
||||||
|
{
|
||||||
|
Index = 13,
|
||||||
|
Name = "Admin Node View",
|
||||||
|
Description = "View node details in the admin area"
|
||||||
|
};
|
||||||
|
|
||||||
|
public static Permission AdminNotificationDebugging = new()
|
||||||
|
{
|
||||||
|
Index = 14,
|
||||||
|
Name = "Admin Notification Debugging",
|
||||||
|
Description = "Manage debugging notifications in the admin area"
|
||||||
|
};
|
||||||
|
|
||||||
|
public static Permission AdminServerCleanup = new()
|
||||||
|
{
|
||||||
|
Index = 15,
|
||||||
|
Name = "Admin Server Cleanup",
|
||||||
|
Description = "Perform server cleanup tasks in the admin area"
|
||||||
|
};
|
||||||
|
|
||||||
|
public static Permission AdminServerEdit = new()
|
||||||
|
{
|
||||||
|
Index = 16,
|
||||||
|
Name = "Admin Server Edit",
|
||||||
|
Description = "Edit server settings in the admin area"
|
||||||
|
};
|
||||||
|
|
||||||
|
public static Permission AdminServers = new()
|
||||||
|
{
|
||||||
|
Index = 17,
|
||||||
|
Name = "Admin Server",
|
||||||
|
Description = "Access the server management page in the admin area"
|
||||||
|
};
|
||||||
|
|
||||||
|
public static Permission AdminServerManager = new()
|
||||||
|
{
|
||||||
|
Index = 18,
|
||||||
|
Name = "Admin Server Manager",
|
||||||
|
Description = "Manage servers in the admin area"
|
||||||
|
};
|
||||||
|
|
||||||
|
public static Permission AdminNewServer = new()
|
||||||
|
{
|
||||||
|
Index = 19,
|
||||||
|
Name = "Admin New Server",
|
||||||
|
Description = "Create a new server in the admin area"
|
||||||
|
};
|
||||||
|
|
||||||
|
public static Permission AdminServerImageEdit = new()
|
||||||
|
{
|
||||||
|
Index = 20,
|
||||||
|
Name = "Admin Server Image Edit",
|
||||||
|
Description = "Edit server image settings in the admin area"
|
||||||
|
};
|
||||||
|
|
||||||
|
public static Permission AdminServerImages = new()
|
||||||
|
{
|
||||||
|
Index = 21,
|
||||||
|
Name = "Admin Server Images",
|
||||||
|
Description = "Access the server image management page in the admin area"
|
||||||
|
};
|
||||||
|
|
||||||
|
public static Permission AdminServerImageNew = new()
|
||||||
|
{
|
||||||
|
Index = 22,
|
||||||
|
Name = "Admin Server Image New",
|
||||||
|
Description = "Create a new server image in the admin area"
|
||||||
|
};
|
||||||
|
|
||||||
|
public static Permission AdminServerViewAllocations = new()
|
||||||
|
{
|
||||||
|
Index = 23,
|
||||||
|
Name = "Admin Server View Allocations",
|
||||||
|
Description = "View server allocations in the admin area"
|
||||||
|
};
|
||||||
|
|
||||||
|
public static Permission AdminServerViewArchive = new()
|
||||||
|
{
|
||||||
|
Index = 24,
|
||||||
|
Name = "Admin Server View Archive",
|
||||||
|
Description = "View server archive in the admin area"
|
||||||
|
};
|
||||||
|
|
||||||
|
public static Permission AdminServerViewDebug = new()
|
||||||
|
{
|
||||||
|
Index = 25,
|
||||||
|
Name = "Admin Server View Debug",
|
||||||
|
Description = "View server debugging information in the admin area"
|
||||||
|
};
|
||||||
|
|
||||||
|
public static Permission AdminServerViewImage = new()
|
||||||
|
{
|
||||||
|
Index = 26,
|
||||||
|
Name = "Admin Server View Image",
|
||||||
|
Description = "View server image details in the admin area"
|
||||||
|
};
|
||||||
|
|
||||||
|
public static Permission AdminServerViewIndex = new()
|
||||||
|
{
|
||||||
|
Index = 27,
|
||||||
|
Name = "Admin Server View",
|
||||||
|
Description = "Access the server view page in the admin area"
|
||||||
|
};
|
||||||
|
|
||||||
|
public static Permission AdminServerViewOverview = new()
|
||||||
|
{
|
||||||
|
Index = 28,
|
||||||
|
Name = "Admin Server View Overview",
|
||||||
|
Description = "View server overview in the admin area"
|
||||||
|
};
|
||||||
|
|
||||||
|
public static Permission AdminServerViewResources = new()
|
||||||
|
{
|
||||||
|
Index = 29,
|
||||||
|
Name = "Admin Server View Resources",
|
||||||
|
Description = "View server resources in the admin area"
|
||||||
|
};
|
||||||
|
|
||||||
|
public static Permission AdminSubscriptionEdit = new()
|
||||||
|
{
|
||||||
|
Index = 30,
|
||||||
|
Name = "Admin Subscription Edit",
|
||||||
|
Description = "Edit subscription settings in the admin area"
|
||||||
|
};
|
||||||
|
|
||||||
|
public static Permission AdminSubscriptions = new()
|
||||||
|
{
|
||||||
|
Index = 31,
|
||||||
|
Name = "Admin Subscriptions",
|
||||||
|
Description = "Access the subscription management page in the admin area"
|
||||||
|
};
|
||||||
|
|
||||||
|
public static Permission AdminNewSubscription = new()
|
||||||
|
{
|
||||||
|
Index = 32,
|
||||||
|
Name = "Admin New Subscription",
|
||||||
|
Description = "Create a new subscription in the admin area"
|
||||||
|
};
|
||||||
|
|
||||||
|
public static Permission AdminSupport = new()
|
||||||
|
{
|
||||||
|
Index = 33,
|
||||||
|
Name = "Admin Support",
|
||||||
|
Description = "Access the support page in the admin area"
|
||||||
|
};
|
||||||
|
|
||||||
|
public static Permission AdminSupportView = new()
|
||||||
|
{
|
||||||
|
Index = 34,
|
||||||
|
Name = "Admin Support View",
|
||||||
|
Description = "View support details in the admin area"
|
||||||
|
};
|
||||||
|
|
||||||
|
public static Permission AdminSysConfiguration = new()
|
||||||
|
{
|
||||||
|
Index = 35,
|
||||||
|
Name = "Admin system Configuration",
|
||||||
|
Description = "Access system configuration settings in the admin area"
|
||||||
|
};
|
||||||
|
|
||||||
|
public static Permission AdminSysDiscordBot = new()
|
||||||
|
{
|
||||||
|
Index = 36,
|
||||||
|
Name = "Admin system Discord Bot",
|
||||||
|
Description = "Manage Discord bot settings in the admin area"
|
||||||
|
};
|
||||||
|
|
||||||
|
public static Permission AdminSystem = new()
|
||||||
|
{
|
||||||
|
Index = 37,
|
||||||
|
Name = "Admin system",
|
||||||
|
Description = "Access the system management page in the admin area"
|
||||||
|
};
|
||||||
|
|
||||||
|
public static Permission AdminSysMail = new()
|
||||||
|
{
|
||||||
|
Index = 38,
|
||||||
|
Name = "Admin system Mail",
|
||||||
|
Description = "Manage mail settings in the admin area"
|
||||||
|
};
|
||||||
|
|
||||||
|
public static Permission AdminSecurityMalware = new()
|
||||||
|
{
|
||||||
|
Index = 39,
|
||||||
|
Name = "Admin security Malware",
|
||||||
|
Description = "Manage malware settings in the admin area"
|
||||||
|
};
|
||||||
|
|
||||||
|
public static Permission AdminSysResources = new()
|
||||||
|
{
|
||||||
|
Index = 40,
|
||||||
|
Name = "Admin system Resources",
|
||||||
|
Description = "View system resources in the admin area"
|
||||||
|
};
|
||||||
|
|
||||||
|
public static Permission AdminSecurity = new()
|
||||||
|
{
|
||||||
|
Index = 41,
|
||||||
|
Name = "Admin Security",
|
||||||
|
Description = "View security logs in the admin area"
|
||||||
|
};
|
||||||
|
|
||||||
|
public static Permission AdminSysSentry = new()
|
||||||
|
{
|
||||||
|
Index = 42,
|
||||||
|
Name = "Admin system Sentry",
|
||||||
|
Description = "Manage Sentry settings in the admin area"
|
||||||
|
};
|
||||||
|
|
||||||
|
public static Permission AdminSysNewsEdit = new()
|
||||||
|
{
|
||||||
|
Index = 43,
|
||||||
|
Name = "Admin system News Edit",
|
||||||
|
Description = "Edit system news in the admin area"
|
||||||
|
};
|
||||||
|
|
||||||
|
public static Permission AdminSysNews = new()
|
||||||
|
{
|
||||||
|
Index = 44,
|
||||||
|
Name = "Admin system News",
|
||||||
|
Description = "Access the system news management page in the admin area"
|
||||||
|
};
|
||||||
|
|
||||||
|
public static Permission AdminSysNewsNew = new()
|
||||||
|
{
|
||||||
|
Index = 45,
|
||||||
|
Name = "Admin system News New",
|
||||||
|
Description = "Create new system news in the admin area"
|
||||||
|
};
|
||||||
|
|
||||||
|
public static Permission AdminUserEdit = new()
|
||||||
|
{
|
||||||
|
Index = 46,
|
||||||
|
Name = "Admin User Edit",
|
||||||
|
Description = "Edit user settings in the admin area"
|
||||||
|
};
|
||||||
|
|
||||||
|
public static Permission AdminUsers = new()
|
||||||
|
{
|
||||||
|
Index = 47,
|
||||||
|
Name = "Admin Users",
|
||||||
|
Description = "Access the user management page in the admin area"
|
||||||
|
};
|
||||||
|
|
||||||
|
public static Permission AdminNewUser = new()
|
||||||
|
{
|
||||||
|
Index = 48,
|
||||||
|
Name = "Admin New User",
|
||||||
|
Description = "Create a new user in the admin area"
|
||||||
|
};
|
||||||
|
|
||||||
|
public static Permission AdminUserSessions = new()
|
||||||
|
{
|
||||||
|
Index = 49,
|
||||||
|
Name = "Admin User Sessions",
|
||||||
|
Description = "View user sessions in the admin area"
|
||||||
|
};
|
||||||
|
|
||||||
|
public static Permission AdminUserView = new()
|
||||||
|
{
|
||||||
|
Index = 50,
|
||||||
|
Name = "Admin User View",
|
||||||
|
Description = "View user details in the admin area"
|
||||||
|
};
|
||||||
|
|
||||||
|
public static Permission AdminWebspaces = new()
|
||||||
|
{
|
||||||
|
Index = 51,
|
||||||
|
Name = "Admin Webspaces",
|
||||||
|
Description = "Access the webspaces management page in the admin area"
|
||||||
|
};
|
||||||
|
|
||||||
|
public static Permission AdminNewWebspace = new()
|
||||||
|
{
|
||||||
|
Index = 52,
|
||||||
|
Name = "Admin New Webspace",
|
||||||
|
Description = "Create a new webspace in the admin area"
|
||||||
|
};
|
||||||
|
|
||||||
|
public static Permission AdminWebspacesServerEdit = new()
|
||||||
|
{
|
||||||
|
Index = 53,
|
||||||
|
Name = "Admin Webspaces Server Edit",
|
||||||
|
Description = "Edit webspace server settings in the admin area"
|
||||||
|
};
|
||||||
|
|
||||||
|
public static Permission AdminWebspacesServers = new()
|
||||||
|
{
|
||||||
|
Index = 54,
|
||||||
|
Name = "Admin Webspaces Servers",
|
||||||
|
Description = "Access the webspace server management page in the admin area"
|
||||||
|
};
|
||||||
|
|
||||||
|
public static Permission AdminWebspacesServerNew = new()
|
||||||
|
{
|
||||||
|
Index = 55,
|
||||||
|
Name = "Admin Webspaces Server New",
|
||||||
|
Description = "Create a new webspace server in the admin area"
|
||||||
|
};
|
||||||
|
|
||||||
|
public static Permission AdminSecurityIpBans = new()
|
||||||
|
{
|
||||||
|
Index = 56,
|
||||||
|
Name = "Admin security ip bans",
|
||||||
|
Description = "Manage ip bans in the admin area"
|
||||||
|
};
|
||||||
|
|
||||||
|
public static Permission AdminSecurityPermissionGroups = new()
|
||||||
|
{
|
||||||
|
Index = 57,
|
||||||
|
Name = "Admin security permission groups",
|
||||||
|
Description = "View, add and delete permission groups"
|
||||||
|
};
|
||||||
|
|
||||||
|
public static Permission? FromString(string name)
|
||||||
|
{
|
||||||
|
var type = typeof(Permissions);
|
||||||
|
|
||||||
|
var field = type
|
||||||
|
.GetFields()
|
||||||
|
.FirstOrDefault(x => x.FieldType == typeof(Permission) && x.Name == name);
|
||||||
|
|
||||||
|
if (field != null)
|
||||||
|
{
|
||||||
|
var value = field.GetValue(null);
|
||||||
|
return value as Permission;
|
||||||
|
}
|
||||||
|
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
public static Permission[] GetAllPermissions()
|
||||||
|
{
|
||||||
|
var type = typeof(Permissions);
|
||||||
|
|
||||||
|
return type
|
||||||
|
.GetFields()
|
||||||
|
.Where(x => x.FieldType == typeof(Permission))
|
||||||
|
.Select(x => (x.GetValue(null) as Permission)!)
|
||||||
|
.ToArray();
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -39,7 +39,7 @@ public class RatingService
|
|||||||
if (!Enabled)
|
if (!Enabled)
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
var user = await IdentityService.Get();
|
var user = IdentityService.User;
|
||||||
|
|
||||||
if (user == null)
|
if (user == null)
|
||||||
return false;
|
return false;
|
||||||
@@ -62,7 +62,7 @@ public class RatingService
|
|||||||
|
|
||||||
public async Task<bool> Rate(int rate)
|
public async Task<bool> Rate(int rate)
|
||||||
{
|
{
|
||||||
var user = await IdentityService.Get();
|
var user = IdentityService.User;
|
||||||
|
|
||||||
// Double check states:
|
// Double check states:
|
||||||
|
|
||||||
|
|||||||
@@ -2,9 +2,10 @@
|
|||||||
using JWT.Algorithms;
|
using JWT.Algorithms;
|
||||||
using JWT.Builder;
|
using JWT.Builder;
|
||||||
using JWT.Exceptions;
|
using JWT.Exceptions;
|
||||||
|
using Microsoft.EntityFrameworkCore;
|
||||||
using Moonlight.App.Database.Entities;
|
using Moonlight.App.Database.Entities;
|
||||||
using Moonlight.App.Helpers;
|
using Moonlight.App.Helpers;
|
||||||
using Moonlight.App.Models.Misc;
|
using Moonlight.App.Perms;
|
||||||
using Moonlight.App.Repositories;
|
using Moonlight.App.Repositories;
|
||||||
using UAParser;
|
using UAParser;
|
||||||
|
|
||||||
@@ -12,16 +13,21 @@ namespace Moonlight.App.Services.Sessions;
|
|||||||
|
|
||||||
public class IdentityService
|
public class IdentityService
|
||||||
{
|
{
|
||||||
private readonly UserRepository UserRepository;
|
private readonly Repository<User> UserRepository;
|
||||||
private readonly CookieService CookieService;
|
private readonly CookieService CookieService;
|
||||||
private readonly IHttpContextAccessor HttpContextAccessor;
|
private readonly IHttpContextAccessor HttpContextAccessor;
|
||||||
private readonly string Secret;
|
private readonly string Secret;
|
||||||
|
|
||||||
private User? UserCache;
|
public User User { get; private set; }
|
||||||
|
public string Ip { get; private set; } = "N/A";
|
||||||
|
public string Device { get; private set; } = "N/A";
|
||||||
|
public PermissionStorage Permissions { get; private set; }
|
||||||
|
public PermissionStorage UserPermissions { get; private set; }
|
||||||
|
public PermissionStorage GroupPermissions { get; private set; }
|
||||||
|
|
||||||
public IdentityService(
|
public IdentityService(
|
||||||
CookieService cookieService,
|
CookieService cookieService,
|
||||||
UserRepository userRepository,
|
Repository<User> userRepository,
|
||||||
IHttpContextAccessor httpContextAccessor,
|
IHttpContextAccessor httpContextAccessor,
|
||||||
ConfigService configService)
|
ConfigService configService)
|
||||||
{
|
{
|
||||||
@@ -34,13 +40,17 @@ public class IdentityService
|
|||||||
.Moonlight.Security.Token;
|
.Moonlight.Security.Token;
|
||||||
}
|
}
|
||||||
|
|
||||||
public async Task<User?> Get()
|
public async Task Load()
|
||||||
|
{
|
||||||
|
await LoadIp();
|
||||||
|
await LoadDevice();
|
||||||
|
await LoadUser();
|
||||||
|
}
|
||||||
|
|
||||||
|
private async Task LoadUser()
|
||||||
{
|
{
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
if (UserCache != null)
|
|
||||||
return UserCache;
|
|
||||||
|
|
||||||
var token = "none";
|
var token = "none";
|
||||||
|
|
||||||
// Load token via http context if available
|
// Load token via http context if available
|
||||||
@@ -60,13 +70,13 @@ public class IdentityService
|
|||||||
|
|
||||||
if (token == "none")
|
if (token == "none")
|
||||||
{
|
{
|
||||||
return null;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (string.IsNullOrEmpty(token))
|
if (string.IsNullOrEmpty(token))
|
||||||
return null;
|
return;
|
||||||
|
|
||||||
var json = "";
|
string json;
|
||||||
|
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
@@ -77,18 +87,18 @@ public class IdentityService
|
|||||||
}
|
}
|
||||||
catch (TokenExpiredException)
|
catch (TokenExpiredException)
|
||||||
{
|
{
|
||||||
return null;
|
return;
|
||||||
}
|
}
|
||||||
catch (SignatureVerificationException)
|
catch (SignatureVerificationException)
|
||||||
{
|
{
|
||||||
Logger.Warn($"Detected a manipulated JWT: {token}", "security");
|
Logger.Warn($"Detected a manipulated JWT: {token}", "security");
|
||||||
return null;
|
return;
|
||||||
}
|
}
|
||||||
catch (Exception e)
|
catch (Exception e)
|
||||||
{
|
{
|
||||||
Logger.Error("Error reading jwt");
|
Logger.Error("Error reading jwt");
|
||||||
Logger.Error(e);
|
Logger.Error(e);
|
||||||
return null;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
// To make it easier to use the json data
|
// To make it easier to use the json data
|
||||||
@@ -101,8 +111,9 @@ public class IdentityService
|
|||||||
|
|
||||||
if (user == null)
|
if (user == null)
|
||||||
{
|
{
|
||||||
Logger.Warn($"Cannot find user with the id '{userid}' in the database. Maybe the user has been deleted or a token has been successfully faked by a hacker");
|
Logger.Warn(
|
||||||
return null;
|
$"Cannot find user with the id '{userid}' in the database. Maybe the user has been deleted or a token has been successfully faked by a hacker");
|
||||||
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
var iat = data.GetValue<long>("iat", -1);
|
var iat = data.GetValue<long>("iat", -1);
|
||||||
@@ -110,46 +121,54 @@ public class IdentityService
|
|||||||
if (iat == -1)
|
if (iat == -1)
|
||||||
{
|
{
|
||||||
Logger.Debug("Legacy token found (without the time the token has been issued at)");
|
Logger.Debug("Legacy token found (without the time the token has been issued at)");
|
||||||
return null;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
var iatD = DateTimeOffset.FromUnixTimeSeconds(iat).ToUniversalTime().DateTime;
|
var iatD = DateTimeOffset.FromUnixTimeSeconds(iat).ToUniversalTime().DateTime;
|
||||||
|
|
||||||
if (iatD < user.TokenValidTime)
|
if (iatD < user.TokenValidTime)
|
||||||
return null;
|
return;
|
||||||
|
|
||||||
UserCache = user;
|
User = user;
|
||||||
|
|
||||||
user.LastIp = GetIp();
|
ConstructPermissions();
|
||||||
UserRepository.Update(user);
|
|
||||||
|
|
||||||
return UserCache;
|
User.LastIp = Ip;
|
||||||
|
UserRepository.Update(User);
|
||||||
}
|
}
|
||||||
catch (Exception e)
|
catch (Exception e)
|
||||||
{
|
{
|
||||||
Logger.Error("Unexpected error while processing token");
|
Logger.Error("Unexpected error while processing token");
|
||||||
Logger.Error(e);
|
Logger.Error(e);
|
||||||
return null;
|
return;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public string GetIp()
|
private Task LoadIp()
|
||||||
{
|
{
|
||||||
if (HttpContextAccessor.HttpContext == null)
|
if (HttpContextAccessor.HttpContext == null)
|
||||||
return "N/A";
|
{
|
||||||
|
Ip = "N/A";
|
||||||
|
return Task.CompletedTask;
|
||||||
|
}
|
||||||
|
|
||||||
if (HttpContextAccessor.HttpContext.Request.Headers.ContainsKey("X-Real-IP"))
|
if (HttpContextAccessor.HttpContext.Request.Headers.ContainsKey("X-Real-IP"))
|
||||||
{
|
{
|
||||||
return HttpContextAccessor.HttpContext.Request.Headers["X-Real-IP"]!;
|
Ip = HttpContextAccessor.HttpContext.Request.Headers["X-Real-IP"]!;
|
||||||
|
return Task.CompletedTask;
|
||||||
}
|
}
|
||||||
|
|
||||||
return HttpContextAccessor.HttpContext.Connection.RemoteIpAddress!.ToString();
|
Ip = HttpContextAccessor.HttpContext.Connection.RemoteIpAddress!.ToString();
|
||||||
|
return Task.CompletedTask;
|
||||||
}
|
}
|
||||||
|
|
||||||
public string GetDevice()
|
private Task LoadDevice()
|
||||||
{
|
{
|
||||||
if (HttpContextAccessor.HttpContext == null)
|
if (HttpContextAccessor.HttpContext == null)
|
||||||
return "N/A";
|
{
|
||||||
|
Device = "N/A";
|
||||||
|
return Task.CompletedTask;
|
||||||
|
}
|
||||||
|
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
@@ -159,17 +178,86 @@ public class IdentityService
|
|||||||
{
|
{
|
||||||
var version = userAgent.Remove(0, "Moonlight.App/".Length).Split(' ').FirstOrDefault();
|
var version = userAgent.Remove(0, "Moonlight.App/".Length).Split(' ').FirstOrDefault();
|
||||||
|
|
||||||
return "Moonlight App " + version;
|
Device = "Moonlight App " + version;
|
||||||
|
return Task.CompletedTask;
|
||||||
}
|
}
|
||||||
|
|
||||||
var uaParser = Parser.GetDefault();
|
var uaParser = Parser.GetDefault();
|
||||||
var info = uaParser.Parse(userAgent);
|
var info = uaParser.Parse(userAgent);
|
||||||
|
|
||||||
return $"{info.OS} - {info.Device}";
|
Device = $"{info.OS} - {info.Device}";
|
||||||
|
return Task.CompletedTask;
|
||||||
}
|
}
|
||||||
catch (Exception e)
|
catch (Exception e)
|
||||||
{
|
{
|
||||||
return "UserAgent not present";
|
Device = "UserAgent not present";
|
||||||
|
return Task.CompletedTask;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public Task SavePermissions()
|
||||||
|
{
|
||||||
|
if (User != null)
|
||||||
|
{
|
||||||
|
User.Permissions = UserPermissions.Data;
|
||||||
|
UserRepository.Update(User);
|
||||||
|
ConstructPermissions();
|
||||||
|
}
|
||||||
|
|
||||||
|
return Task.CompletedTask;
|
||||||
|
}
|
||||||
|
|
||||||
|
private void ConstructPermissions()
|
||||||
|
{
|
||||||
|
if (User == null)
|
||||||
|
{
|
||||||
|
UserPermissions = new(Array.Empty<byte>());
|
||||||
|
GroupPermissions = new(Array.Empty<byte>(), true);
|
||||||
|
Permissions = new(Array.Empty<byte>(), true);
|
||||||
|
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
var user = UserRepository
|
||||||
|
.Get()
|
||||||
|
.Include(x => x.PermissionGroup)
|
||||||
|
.First(x => x.Id == User.Id);
|
||||||
|
|
||||||
|
UserPermissions = new PermissionStorage(user.Permissions);
|
||||||
|
|
||||||
|
if (user.PermissionGroup == null)
|
||||||
|
GroupPermissions = new PermissionStorage(Array.Empty<byte>(), true);
|
||||||
|
else
|
||||||
|
GroupPermissions = new PermissionStorage(user.PermissionGroup.Permissions, true);
|
||||||
|
|
||||||
|
if (user.Admin)
|
||||||
|
{
|
||||||
|
Permissions = new PermissionStorage(Array.Empty<byte>());
|
||||||
|
|
||||||
|
foreach (var permission in Perms.Permissions.GetAllPermissions())
|
||||||
|
{
|
||||||
|
Permissions[permission] = true;
|
||||||
|
}
|
||||||
|
|
||||||
|
Permissions.IsReadyOnly = true;
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
Permissions = new(Array.Empty<byte>());
|
||||||
|
|
||||||
|
foreach (var permission in Perms.Permissions.GetAllPermissions())
|
||||||
|
{
|
||||||
|
Permissions[permission] = GroupPermissions[permission];
|
||||||
|
}
|
||||||
|
|
||||||
|
foreach (var permission in Perms.Permissions.GetAllPermissions())
|
||||||
|
{
|
||||||
|
if (UserPermissions[permission])
|
||||||
|
{
|
||||||
|
Permissions[permission] = true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
Permissions.IsReadyOnly = true;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
@@ -19,7 +19,7 @@ public class IpBanService
|
|||||||
|
|
||||||
public Task<bool> IsBanned()
|
public Task<bool> IsBanned()
|
||||||
{
|
{
|
||||||
var ip = IdentityService.GetIp();
|
var ip = IdentityService.Ip;
|
||||||
|
|
||||||
return Task.FromResult(
|
return Task.FromResult(
|
||||||
IpBanRepository
|
IpBanRepository
|
||||||
|
|||||||
@@ -15,7 +15,7 @@ public class IpLocateService
|
|||||||
|
|
||||||
public async Task<string> GetLocation()
|
public async Task<string> GetLocation()
|
||||||
{
|
{
|
||||||
var ip = IdentityService.GetIp();
|
var ip = IdentityService.Ip;
|
||||||
var location = "N/A";
|
var location = "N/A";
|
||||||
|
|
||||||
if (ip != "N/A")
|
if (ip != "N/A")
|
||||||
|
|||||||
@@ -40,9 +40,9 @@ public class SessionClientService
|
|||||||
|
|
||||||
public async Task Start()
|
public async Task Start()
|
||||||
{
|
{
|
||||||
User = await IdentityService.Get();
|
User = IdentityService.User;
|
||||||
Ip = IdentityService.GetIp();
|
Ip = IdentityService.Ip;
|
||||||
Device = IdentityService.GetDevice();
|
Device = IdentityService.Device;
|
||||||
|
|
||||||
if (User != null) // Track users last visit
|
if (User != null) // Track users last visit
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -34,7 +34,7 @@ public class SupportChatAdminService : IDisposable
|
|||||||
|
|
||||||
public async Task Start(User recipient)
|
public async Task Start(User recipient)
|
||||||
{
|
{
|
||||||
User = await IdentityService.Get();
|
User = IdentityService.User;
|
||||||
Recipient = recipient;
|
Recipient = recipient;
|
||||||
|
|
||||||
if (User != null)
|
if (User != null)
|
||||||
|
|||||||
@@ -33,7 +33,7 @@ public class SupportChatClientService : IDisposable
|
|||||||
|
|
||||||
public async Task Start()
|
public async Task Start()
|
||||||
{
|
{
|
||||||
User = await IdentityService.Get();
|
User = IdentityService.User;
|
||||||
|
|
||||||
if (User != null)
|
if (User != null)
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -25,32 +25,30 @@ public class TotpService
|
|||||||
return Task.FromResult(codeserver == code);
|
return Task.FromResult(codeserver == code);
|
||||||
}
|
}
|
||||||
|
|
||||||
public async Task<bool> GetEnabled()
|
public Task<bool> GetEnabled()
|
||||||
{
|
{
|
||||||
var user = await IdentityService.Get();
|
return Task.FromResult(IdentityService.User.TotpEnabled);
|
||||||
|
|
||||||
return user!.TotpEnabled;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public async Task<string> GetSecret()
|
public Task<string> GetSecret()
|
||||||
{
|
{
|
||||||
var user = await IdentityService.Get();
|
return Task.FromResult(IdentityService.User.TotpSecret);
|
||||||
|
|
||||||
return user!.TotpSecret;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public async Task GenerateSecret()
|
public Task GenerateSecret()
|
||||||
{
|
{
|
||||||
var user = (await IdentityService.Get())!;
|
var user = IdentityService.User;
|
||||||
|
|
||||||
user.TotpSecret = Base32Encoding.ToString(KeyGeneration.GenerateRandomKey(20));;
|
user.TotpSecret = Base32Encoding.ToString(KeyGeneration.GenerateRandomKey(20));;
|
||||||
|
|
||||||
UserRepository.Update(user);
|
UserRepository.Update(user);
|
||||||
|
|
||||||
|
return Task.CompletedTask;
|
||||||
}
|
}
|
||||||
|
|
||||||
public async Task Enable(string code)
|
public async Task Enable(string code)
|
||||||
{
|
{
|
||||||
var user = (await IdentityService.Get())!;
|
var user = IdentityService.User;
|
||||||
|
|
||||||
if (!await Verify(user.TotpSecret, code))
|
if (!await Verify(user.TotpSecret, code))
|
||||||
{
|
{
|
||||||
@@ -61,9 +59,9 @@ public class TotpService
|
|||||||
UserRepository.Update(user);
|
UserRepository.Update(user);
|
||||||
}
|
}
|
||||||
|
|
||||||
public async Task Disable()
|
public Task Disable()
|
||||||
{
|
{
|
||||||
var user = (await IdentityService.Get())!;
|
var user = IdentityService.User;
|
||||||
|
|
||||||
user.TotpEnabled = false;
|
user.TotpEnabled = false;
|
||||||
user.TotpSecret = "";
|
user.TotpSecret = "";
|
||||||
@@ -71,5 +69,7 @@ public class TotpService
|
|||||||
UserRepository.Update(user);
|
UserRepository.Update(user);
|
||||||
|
|
||||||
//TODO: AuditLog
|
//TODO: AuditLog
|
||||||
|
|
||||||
|
return Task.CompletedTask;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -85,8 +85,8 @@ public class UserService
|
|||||||
TotpSecret = "",
|
TotpSecret = "",
|
||||||
UpdatedAt = DateTimeService.GetCurrent(),
|
UpdatedAt = DateTimeService.GetCurrent(),
|
||||||
TokenValidTime = DateTimeService.GetCurrent().AddDays(-5),
|
TokenValidTime = DateTimeService.GetCurrent().AddDays(-5),
|
||||||
LastIp = IdentityService.GetIp(),
|
LastIp = IdentityService.Ip,
|
||||||
RegisterIp = IdentityService.GetIp()
|
RegisterIp = IdentityService.Ip
|
||||||
});
|
});
|
||||||
|
|
||||||
await MailService.SendMail(user!, "register", values => {});
|
await MailService.SendMail(user!, "register", values => {});
|
||||||
@@ -174,8 +174,8 @@ public class UserService
|
|||||||
|
|
||||||
await MailService.SendMail(user!, "passwordChange", values =>
|
await MailService.SendMail(user!, "passwordChange", values =>
|
||||||
{
|
{
|
||||||
values.Add("Ip", IdentityService.GetIp());
|
values.Add("Ip", IdentityService.Ip);
|
||||||
values.Add("Device", IdentityService.GetDevice());
|
values.Add("Device", IdentityService.Device);
|
||||||
values.Add("Location", location);
|
values.Add("Location", location);
|
||||||
});
|
});
|
||||||
|
|
||||||
@@ -212,8 +212,8 @@ public class UserService
|
|||||||
{
|
{
|
||||||
await MailService.SendMail(user!, "login", values =>
|
await MailService.SendMail(user!, "login", values =>
|
||||||
{
|
{
|
||||||
values.Add("Ip", IdentityService.GetIp());
|
values.Add("Ip", IdentityService.Ip);
|
||||||
values.Add("Device", IdentityService.GetDevice());
|
values.Add("Device", IdentityService.Device);
|
||||||
values.Add("Location", location);
|
values.Add("Location", location);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
@@ -249,8 +249,8 @@ public class UserService
|
|||||||
|
|
||||||
await MailService.SendMail(user, "passwordReset", values =>
|
await MailService.SendMail(user, "passwordReset", values =>
|
||||||
{
|
{
|
||||||
values.Add("Ip", IdentityService.GetIp());
|
values.Add("Ip", IdentityService.Ip);
|
||||||
values.Add("Device", IdentityService.GetDevice());
|
values.Add("Device", IdentityService.Device);
|
||||||
values.Add("Location", location);
|
values.Add("Location", location);
|
||||||
values.Add("Password", newPassword);
|
values.Add("Password", newPassword);
|
||||||
});
|
});
|
||||||
|
|||||||
@@ -2,12 +2,19 @@
|
|||||||
|
|
||||||
<Router AppAssembly="@typeof(BlazorApp).Assembly">
|
<Router AppAssembly="@typeof(BlazorApp).Assembly">
|
||||||
<Found Context="routeData">
|
<Found Context="routeData">
|
||||||
|
<CascadingValue TValue="Type" Name="TargetPageType" Value="routeData.PageType">
|
||||||
<RouteView RouteData="@routeData" DefaultLayout="@typeof(MainLayout)"/>
|
<RouteView RouteData="@routeData" DefaultLayout="@typeof(MainLayout)"/>
|
||||||
|
</CascadingValue>
|
||||||
</Found>
|
</Found>
|
||||||
<NotFound>
|
<NotFound>
|
||||||
<PageTitle>Not found</PageTitle>
|
<PageTitle>Not found</PageTitle>
|
||||||
<LayoutView Layout="@typeof(NotFoundLayout)">
|
<LayoutView Layout="@typeof(NotFoundLayout)">
|
||||||
<p role="alert">Sorry, there's nothing at this address.</p>
|
<NotFoundAlert />
|
||||||
</LayoutView>
|
</LayoutView>
|
||||||
</NotFound>
|
</NotFound>
|
||||||
</Router>
|
</Router>
|
||||||
|
|
||||||
|
@code
|
||||||
|
{
|
||||||
|
|
||||||
|
}
|
||||||
@@ -77,6 +77,9 @@
|
|||||||
<_ContentIncludedByDefault Remove="Shared\Views\Admin\Servers\Cleanup\Exceptions\Edit.razor" />
|
<_ContentIncludedByDefault Remove="Shared\Views\Admin\Servers\Cleanup\Exceptions\Edit.razor" />
|
||||||
<_ContentIncludedByDefault Remove="Shared\Components\News\NewsEditor.razor" />
|
<_ContentIncludedByDefault Remove="Shared\Components\News\NewsEditor.razor" />
|
||||||
<_ContentIncludedByDefault Remove="Shared\News\Edit.razor" />
|
<_ContentIncludedByDefault Remove="Shared\News\Edit.razor" />
|
||||||
|
<_ContentIncludedByDefault Remove="Shared\Views\Admin\AaPanels\Index.razor" />
|
||||||
|
<_ContentIncludedByDefault Remove="Shared\Views\Admin\Databases\Index.razor" />
|
||||||
|
<_ContentIncludedByDefault Remove="Shared\Components\StateLogic\OnlyAdmin.razor" />
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
|
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
|
|||||||
13
Moonlight/Shared/Components/Alerts/NoPermissionAlert.razor
Normal file
13
Moonlight/Shared/Components/Alerts/NoPermissionAlert.razor
Normal file
@@ -0,0 +1,13 @@
|
|||||||
|
<div class="mx-auto">
|
||||||
|
<div class="card">
|
||||||
|
<div class="d-flex justify-content-center pt-5">
|
||||||
|
<img height="300" width="300" src="/assets/media/svg/warning.svg" alt="Warning"/>
|
||||||
|
</div>
|
||||||
|
<span class="card-title text-center fs-3">
|
||||||
|
<TL>You have no permission to access this resource</TL>
|
||||||
|
</span>
|
||||||
|
<p class="card-body text-center fs-4 text-gray-800">
|
||||||
|
<TL>You have no permission to access this resource. This attempt has been logged ;)</TL>
|
||||||
|
</p>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
@@ -14,7 +14,7 @@
|
|||||||
<span class="bullet me-5"></span> <TL>The resource was deleted</TL>
|
<span class="bullet me-5"></span> <TL>The resource was deleted</TL>
|
||||||
</li>
|
</li>
|
||||||
<li class="d-flex align-items-center py-2">
|
<li class="d-flex align-items-center py-2">
|
||||||
<span class="bullet me-5"></span> <TL>You have to permission to access this resource</TL>
|
<span class="bullet me-5"></span> <TL>You have no permission to access this resource</TL>
|
||||||
</li>
|
</li>
|
||||||
<li class="d-flex align-items-center py-2">
|
<li class="d-flex align-items-center py-2">
|
||||||
<span class="bullet me-5"></span> <TL>You may have entered invalid data</TL>
|
<span class="bullet me-5"></span> <TL>You may have entered invalid data</TL>
|
||||||
|
|||||||
@@ -1,10 +0,0 @@
|
|||||||
@using Moonlight.App.Services
|
|
||||||
|
|
||||||
<div class="card card-flush w-lg-650px py-5">
|
|
||||||
<div class="card-body py-15 py-lg-20">
|
|
||||||
<h1 class="fw-bolder text-gray-900 mb-5"><TL>Setup complete</TL></h1>
|
|
||||||
<div class="fw-semibold fs-6 text-gray-500 mb-8">
|
|
||||||
<TL>It looks like this moonlight instance is ready to go</TL>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
@@ -49,9 +49,10 @@
|
|||||||
private PasswordModel Password = new();
|
private PasswordModel Password = new();
|
||||||
private User User;
|
private User User;
|
||||||
|
|
||||||
private async Task Load(LazyLoader loader)
|
private Task Load(LazyLoader loader)
|
||||||
{
|
{
|
||||||
User = await IdentityService.Get();
|
User = IdentityService.User;
|
||||||
|
return Task.CompletedTask;
|
||||||
}
|
}
|
||||||
|
|
||||||
private async Task DoChange()
|
private async Task DoChange()
|
||||||
|
|||||||
@@ -50,9 +50,10 @@
|
|||||||
private User User;
|
private User User;
|
||||||
private NameModel Name = new ();
|
private NameModel Name = new ();
|
||||||
|
|
||||||
private async Task Load(LazyLoader loader)
|
private Task Load(LazyLoader loader)
|
||||||
{
|
{
|
||||||
User = await IdentityService.Get();
|
User = IdentityService.User;
|
||||||
|
return Task.CompletedTask;
|
||||||
}
|
}
|
||||||
|
|
||||||
private async Task SetName()
|
private async Task SetName()
|
||||||
|
|||||||
@@ -57,7 +57,7 @@ else
|
|||||||
{
|
{
|
||||||
receivedExceptions.Add(exception);
|
receivedExceptions.Add(exception);
|
||||||
|
|
||||||
var user = await IdentityService.Get();
|
var user = IdentityService.User;
|
||||||
var id = user == null ? -1 : user.Id;
|
var id = user == null ? -1 : user.Id;
|
||||||
|
|
||||||
Logger.Error($"[{id}] An unhanded exception occured:");
|
Logger.Error($"[{id}] An unhanded exception occured:");
|
||||||
|
|||||||
@@ -1,22 +0,0 @@
|
|||||||
<div class="card mb-5 mb-xl-10">
|
|
||||||
<div class="card-body pt-0 pb-0">
|
|
||||||
<ul class="nav nav-stretch nav-line-tabs nav-line-tabs-2x border-transparent fs-5 fw-bold">
|
|
||||||
<li class="nav-item mt-2">
|
|
||||||
<a class="nav-link text-active-primary ms-0 me-10 py-5 @(Index == 0 ? "active" : "")" href="/admin/nodes">
|
|
||||||
<TL>Nodes</TL>
|
|
||||||
</a>
|
|
||||||
</li>
|
|
||||||
<li class="nav-item mt-2">
|
|
||||||
<a class="nav-link text-active-primary ms-0 me-10 py-5 @(Index == 1 ? "active" : "")" href="/admin/nodes/ddos">
|
|
||||||
<TL>DDos</TL>
|
|
||||||
</a>
|
|
||||||
</li>
|
|
||||||
</ul>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
|
|
||||||
@code
|
|
||||||
{
|
|
||||||
[Parameter]
|
|
||||||
public int Index { get; set; } = 0;
|
|
||||||
}
|
|
||||||
@@ -0,0 +1,32 @@
|
|||||||
|
<div class="card mb-5 mb-xl-10">
|
||||||
|
<div class="card-body pt-0 pb-0">
|
||||||
|
<ul class="nav nav-stretch nav-line-tabs nav-line-tabs-2x border-transparent fs-5 fw-bold">
|
||||||
|
<li class="nav-item mt-2">
|
||||||
|
<a class="nav-link text-active-primary ms-0 me-10 py-5 @(Index == 0 ? "active" : "")" href="/admin/security">
|
||||||
|
<TL>Overview</TL>
|
||||||
|
</a>
|
||||||
|
</li>
|
||||||
|
<li class="nav-item mt-2">
|
||||||
|
<a class="nav-link text-active-primary ms-0 me-10 py-5 @(Index == 1 ? "active" : "")" href="/admin/security/malware">
|
||||||
|
<TL>Malware</TL>
|
||||||
|
</a>
|
||||||
|
</li>
|
||||||
|
<li class="nav-item mt-2">
|
||||||
|
<a class="nav-link text-active-primary ms-0 me-10 py-5 @(Index == 2 ? "active" : "")" href="/admin/security/ipbans">
|
||||||
|
<TL>Ip bans</TL>
|
||||||
|
</a>
|
||||||
|
</li>
|
||||||
|
<li class="nav-item mt-2">
|
||||||
|
<a class="nav-link text-active-primary ms-0 me-10 py-5 @(Index == 3 ? "active" : "")" href="/admin/security/permissiongroups">
|
||||||
|
<TL>Permission groups</TL>
|
||||||
|
</a>
|
||||||
|
</li>
|
||||||
|
</ul>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
@code
|
||||||
|
{
|
||||||
|
[Parameter]
|
||||||
|
public int Index { get; set; } = 0;
|
||||||
|
}
|
||||||
@@ -0,0 +1,37 @@
|
|||||||
|
<div class="card mb-5 mb-xl-10">
|
||||||
|
<div class="card-body pt-0 pb-0">
|
||||||
|
<ul class="nav nav-stretch nav-line-tabs nav-line-tabs-2x border-transparent fs-5 fw-bold">
|
||||||
|
<li class="nav-item mt-2">
|
||||||
|
<a class="nav-link text-active-primary ms-0 me-10 py-5 @(Index == 0 ? "active" : "")" href="/admin/servers">
|
||||||
|
<TL>Overview</TL>
|
||||||
|
</a>
|
||||||
|
</li>
|
||||||
|
<li class="nav-item mt-2">
|
||||||
|
<a class="nav-link text-active-primary ms-0 me-10 py-5 @(Index == 1 ? "active" : "")" href="/admin/servers/manager">
|
||||||
|
<TL>Manager</TL>
|
||||||
|
</a>
|
||||||
|
</li>
|
||||||
|
<li class="nav-item mt-2">
|
||||||
|
<a class="nav-link text-active-primary ms-0 me-10 py-5 @(Index == 2 ? "active" : "")" href="/admin/servers/cleanup">
|
||||||
|
<TL>Cleanup</TL>
|
||||||
|
</a>
|
||||||
|
</li>
|
||||||
|
<li class="nav-item mt-2">
|
||||||
|
<a class="nav-link text-active-primary ms-0 me-10 py-5 @(Index == 3 ? "active" : "")" href="/admin/nodes">
|
||||||
|
<TL>Nodes</TL>
|
||||||
|
</a>
|
||||||
|
</li>
|
||||||
|
<li class="nav-item mt-2">
|
||||||
|
<a class="nav-link text-active-primary ms-0 me-10 py-5 @(Index == 4 ? "active" : "")" href="/admin/servers/images">
|
||||||
|
<TL>Images</TL>
|
||||||
|
</a>
|
||||||
|
</li>
|
||||||
|
</ul>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
@code
|
||||||
|
{
|
||||||
|
[Parameter]
|
||||||
|
public int Index { get; set; } = 0;
|
||||||
|
}
|
||||||
@@ -9,21 +9,6 @@
|
|||||||
<TL>Overview</TL>
|
<TL>Overview</TL>
|
||||||
</a>
|
</a>
|
||||||
</li>
|
</li>
|
||||||
<li class="nav-item mt-2">
|
|
||||||
<a class="nav-link text-active-primary ms-0 me-10 py-5 @(Index == 1 ? "active" : "")" href="/admin/system/sentry">
|
|
||||||
<TL>Sentry</TL>
|
|
||||||
</a>
|
|
||||||
</li>
|
|
||||||
<li class="nav-item mt-2">
|
|
||||||
<a class="nav-link text-active-primary ms-0 me-10 py-5 @(Index == 2 ? "active" : "")" href="/admin/system/malware">
|
|
||||||
<TL>Malware</TL>
|
|
||||||
</a>
|
|
||||||
</li>
|
|
||||||
<li class="nav-item mt-2">
|
|
||||||
<a class="nav-link text-active-primary ms-0 me-10 py-5 @(Index == 3 ? "active" : "")" href="/admin/system/security">
|
|
||||||
<TL>Security</TL>
|
|
||||||
</a>
|
|
||||||
</li>
|
|
||||||
<li class="nav-item mt-2">
|
<li class="nav-item mt-2">
|
||||||
<a class="nav-link text-active-primary ms-0 me-10 py-5 @(Index == 5 ? "active" : "")" href="/admin/system/resources">
|
<a class="nav-link text-active-primary ms-0 me-10 py-5 @(Index == 5 ? "active" : "")" href="/admin/system/resources">
|
||||||
<TL>Resources</TL>
|
<TL>Resources</TL>
|
||||||
|
|||||||
@@ -1,5 +1,8 @@
|
|||||||
@using Moonlight.App.Database.Entities
|
@using Moonlight.App.Database.Entities
|
||||||
@using Moonlight.App.Models.Misc
|
@using Moonlight.App.Models.Misc
|
||||||
|
@using Moonlight.App.Services.Sessions
|
||||||
|
|
||||||
|
@inject IdentityService IdentityService
|
||||||
|
|
||||||
<div class="card mb-5 mb-xl-10">
|
<div class="card mb-5 mb-xl-10">
|
||||||
<div class="card-body pt-9 pb-0">
|
<div class="card-body pt-9 pb-0">
|
||||||
@@ -8,16 +11,16 @@
|
|||||||
<div class="d-flex justify-content-between align-items-start flex-wrap mb-2">
|
<div class="d-flex justify-content-between align-items-start flex-wrap mb-2">
|
||||||
<div class="d-flex flex-column">
|
<div class="d-flex flex-column">
|
||||||
<div class="d-flex align-items-center mb-2">
|
<div class="d-flex align-items-center mb-2">
|
||||||
<a class="text-gray-900 fs-2 fw-bold me-1 @(User.StreamerMode ? "blur" : "")">@(User.FirstName) @(User.LastName)</a>
|
<a class="text-gray-900 fs-2 fw-bold me-1 @(IdentityService.User.StreamerMode ? "blur" : "")">@(IdentityService.User.FirstName) @(IdentityService.User.LastName)</a>
|
||||||
|
|
||||||
@if (User.Status == UserStatus.Verified)
|
@if (IdentityService.User.Status == UserStatus.Verified)
|
||||||
{
|
{
|
||||||
<i class="text-success bx bx-md bxs-badge-check"></i>
|
<i class="text-success bx bx-md bxs-badge-check"></i>
|
||||||
}
|
}
|
||||||
</div>
|
</div>
|
||||||
<div class="d-flex flex-wrap fw-semibold fs-6 mb-4 pe-2">
|
<div class="d-flex flex-wrap fw-semibold fs-6 mb-4 pe-2">
|
||||||
<span class="d-flex align-items-center text-gray-400 mb-2 @(User.StreamerMode ? "blur" : "")">
|
<span class="d-flex align-items-center text-gray-400 mb-2 @(IdentityService.User.StreamerMode ? "blur" : "")">
|
||||||
@(User.Email)
|
@(IdentityService.User.Email)
|
||||||
</span>
|
</span>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
@@ -51,9 +54,6 @@
|
|||||||
|
|
||||||
@code
|
@code
|
||||||
{
|
{
|
||||||
[CascadingParameter]
|
|
||||||
public User User { get; set; }
|
|
||||||
|
|
||||||
[Parameter]
|
[Parameter]
|
||||||
public int Index { get; set; } = 0;
|
public int Index { get; set; } = 0;
|
||||||
}
|
}
|
||||||
@@ -106,7 +106,7 @@
|
|||||||
{
|
{
|
||||||
if (firstRender)
|
if (firstRender)
|
||||||
{
|
{
|
||||||
User = await IdentityService.Get();
|
User = IdentityService.User;
|
||||||
|
|
||||||
await InvokeAsync(StateHasChanged);
|
await InvokeAsync(StateHasChanged);
|
||||||
}
|
}
|
||||||
|
|||||||
86
Moonlight/Shared/Components/Partials/PermissionEditor.razor
Normal file
86
Moonlight/Shared/Components/Partials/PermissionEditor.razor
Normal file
@@ -0,0 +1,86 @@
|
|||||||
|
@using Moonlight.App.Services.Interop
|
||||||
|
@using Moonlight.App.Services
|
||||||
|
@using Moonlight.App.Perms
|
||||||
|
|
||||||
|
@inject ModalService ModalService
|
||||||
|
@inject SmartTranslateService SmartTranslateService
|
||||||
|
|
||||||
|
<div id="permissionEditor" class="modal" tabindex="-1">
|
||||||
|
<div class="modal-dialog modal-lg modal-dialog-centered modal-dialog-scrollable">
|
||||||
|
<div class="modal-content">
|
||||||
|
<div class="modal-header">
|
||||||
|
<h5 class="modal-title">
|
||||||
|
<TL>Edit permissions</TL>
|
||||||
|
</h5>
|
||||||
|
<button type="button" class="btn-close" data-bs-dismiss="modal" aria-label="Close"></button>
|
||||||
|
</div>
|
||||||
|
<div class="modal-body">
|
||||||
|
@if (Enabled)
|
||||||
|
{
|
||||||
|
<div class="table-responsive">
|
||||||
|
<table class="table align-middle table-row-dashed fs-6 gy-5">
|
||||||
|
<tbody class="text-gray-600 fw-semibold">
|
||||||
|
@foreach (var permission in Permissions.GetAllPermissions())
|
||||||
|
{
|
||||||
|
<tr>
|
||||||
|
<td class="text-gray-800">
|
||||||
|
@(permission.Name)
|
||||||
|
</td>
|
||||||
|
<td>
|
||||||
|
@(permission.Description)
|
||||||
|
</td>
|
||||||
|
<td>
|
||||||
|
<div class="form-check form-switch form-check-custom form-check-solid">
|
||||||
|
<input class="form-check-input" type="checkbox" @bind="Storage[permission]"/>
|
||||||
|
</div>
|
||||||
|
</td>
|
||||||
|
</tr>
|
||||||
|
}
|
||||||
|
</tbody>
|
||||||
|
</table>
|
||||||
|
</div>
|
||||||
|
}
|
||||||
|
</div>
|
||||||
|
<div class="modal-footer">
|
||||||
|
<button type="button" class="btn btn-secondary" data-bs-dismiss="modal">
|
||||||
|
<TL>Close</TL>
|
||||||
|
</button>
|
||||||
|
<WButton Text="@(SmartTranslateService.Translate("Save"))"
|
||||||
|
WorkingText="@(SmartTranslateService.Translate("Saving"))"
|
||||||
|
CssClasses="btn-primary"
|
||||||
|
OnClick="Save">
|
||||||
|
</WButton>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
@code
|
||||||
|
{
|
||||||
|
[Parameter]
|
||||||
|
public byte[] InitialData { get; set; } = Array.Empty<byte>();
|
||||||
|
|
||||||
|
[Parameter]
|
||||||
|
public Func<byte[], Task>? OnSave { get; set; }
|
||||||
|
|
||||||
|
private bool Enabled = false;
|
||||||
|
private PermissionStorage Storage;
|
||||||
|
|
||||||
|
public async Task Launch()
|
||||||
|
{
|
||||||
|
Enabled = true;
|
||||||
|
Storage = new(InitialData);
|
||||||
|
await InvokeAsync(StateHasChanged);
|
||||||
|
|
||||||
|
await ModalService.Show("permissionEditor");
|
||||||
|
}
|
||||||
|
|
||||||
|
private async Task Save()
|
||||||
|
{
|
||||||
|
OnSave?.Invoke(Storage.Data);
|
||||||
|
|
||||||
|
await ModalService.Hide("permissionEditor");
|
||||||
|
Enabled = false;
|
||||||
|
await InvokeAsync(StateHasChanged);
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,62 @@
|
|||||||
|
@using Moonlight.App.Services.Sessions
|
||||||
|
@using Moonlight.App.Perms
|
||||||
|
@using Moonlight.App.Helpers
|
||||||
|
@using Moonlight.Shared.Components.Alerts
|
||||||
|
|
||||||
|
@inject IdentityService IdentityService
|
||||||
|
@inject NavigationManager NavigationManager
|
||||||
|
|
||||||
|
@if (Allowed)
|
||||||
|
{
|
||||||
|
@ChildContent
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
<NoPermissionAlert />
|
||||||
|
}
|
||||||
|
|
||||||
|
@code
|
||||||
|
{
|
||||||
|
[CascadingParameter(Name = "TargetPageType")]
|
||||||
|
public Type TargetPageType { get; set; }
|
||||||
|
|
||||||
|
[Parameter]
|
||||||
|
public RenderFragment ChildContent { get; set; }
|
||||||
|
|
||||||
|
private bool Allowed = false;
|
||||||
|
|
||||||
|
protected override Task OnParametersSetAsync()
|
||||||
|
{
|
||||||
|
var attributes = TargetPageType.GetCustomAttributes(true);
|
||||||
|
var permAttrs = attributes
|
||||||
|
.Where(x => x.GetType() == typeof(PermissionRequired))
|
||||||
|
.Select(x => x as PermissionRequired)
|
||||||
|
.ToArray();
|
||||||
|
|
||||||
|
Allowed = true;
|
||||||
|
|
||||||
|
foreach (var permissionRequired in permAttrs)
|
||||||
|
{
|
||||||
|
var permission = Permissions.FromString(permissionRequired!.Name);
|
||||||
|
|
||||||
|
if (permission == null)
|
||||||
|
{
|
||||||
|
Allowed = false;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!IdentityService.Permissions[permission])
|
||||||
|
{
|
||||||
|
Allowed = false;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!Allowed)
|
||||||
|
{
|
||||||
|
Logger.Warn($"{IdentityService.Ip} has tried to access {NavigationManager.Uri} without permission", "security");
|
||||||
|
}
|
||||||
|
|
||||||
|
return Task.CompletedTask;
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -49,7 +49,7 @@
|
|||||||
{
|
{
|
||||||
if (firstRender)
|
if (firstRender)
|
||||||
{
|
{
|
||||||
User = await IdentityService.Get();
|
User = IdentityService.User;
|
||||||
sidebar = await JsRuntime.InvokeAsync<string>("document.body.getAttribute", "data-kt-app-layout");
|
sidebar = await JsRuntime.InvokeAsync<string>("document.body.getAttribute", "data-kt-app-layout");
|
||||||
StateHasChanged();
|
StateHasChanged();
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -69,7 +69,7 @@ else
|
|||||||
</a>
|
</a>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
if (User.Admin)
|
if (IdentityService.Permissions.HasAnyPermissions())
|
||||||
{
|
{
|
||||||
<div class="menu-item pt-5">
|
<div class="menu-item pt-5">
|
||||||
<div class="menu-content">
|
<div class="menu-content">
|
||||||
@@ -92,61 +92,22 @@ else
|
|||||||
<span class="menu-title"><TL>System</TL></span>
|
<span class="menu-title"><TL>System</TL></span>
|
||||||
</a>
|
</a>
|
||||||
</div>
|
</div>
|
||||||
<div data-kt-menu-trigger="click" class="menu-item menu-accordion">
|
<div class="menu-item">
|
||||||
<span class="menu-link">
|
<a class="menu-link" href="/admin/security">
|
||||||
|
<span class="menu-icon">
|
||||||
|
<i class="bx bx-shield"></i>
|
||||||
|
</span>
|
||||||
|
<span class="menu-title"><TL>Security</TL></span>
|
||||||
|
</a>
|
||||||
|
</div>
|
||||||
|
<div class="menu-item">
|
||||||
|
<a class="menu-link" href="/admin/servers">
|
||||||
<span class="menu-icon">
|
<span class="menu-icon">
|
||||||
<i class="bx bx-server"></i>
|
<i class="bx bx-server"></i>
|
||||||
</span>
|
</span>
|
||||||
<span class="menu-title"><TL>Servers</TL></span>
|
<span class="menu-title"><TL>Servers</TL></span>
|
||||||
<span class="menu-arrow"></span>
|
|
||||||
</span>
|
|
||||||
<div class="menu-sub menu-sub-accordion">
|
|
||||||
<div class="menu-item">
|
|
||||||
<a class="menu-link" href="/admin/servers">
|
|
||||||
<span class="menu-bullet">
|
|
||||||
<span class="bullet bullet-dot"></span>
|
|
||||||
</span>
|
|
||||||
<span class="menu-title"><TL>Overview</TL></span>
|
|
||||||
</a>
|
</a>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div class="menu-item">
|
|
||||||
<a class="menu-link" href="/admin/servers/manager">
|
|
||||||
<span class="menu-bullet">
|
|
||||||
<span class="bullet bullet-dot"></span>
|
|
||||||
</span>
|
|
||||||
<span class="menu-title"><TL>Manager</TL></span>
|
|
||||||
</a>
|
|
||||||
</div>
|
|
||||||
|
|
||||||
<div class="menu-item">
|
|
||||||
<a class="menu-link" href="/admin/servers/cleanup">
|
|
||||||
<span class="menu-bullet">
|
|
||||||
<span class="bullet bullet-dot"></span>
|
|
||||||
</span>
|
|
||||||
<span class="menu-title"><TL>Cleanup</TL></span>
|
|
||||||
</a>
|
|
||||||
</div>
|
|
||||||
|
|
||||||
<div class="menu-item">
|
|
||||||
<a class="menu-link" href="/admin/nodes">
|
|
||||||
<span class="menu-bullet">
|
|
||||||
<span class="bullet bullet-dot"></span>
|
|
||||||
</span>
|
|
||||||
<span class="menu-title"><TL>Nodes</TL></span>
|
|
||||||
</a>
|
|
||||||
</div>
|
|
||||||
|
|
||||||
<div class="menu-item">
|
|
||||||
<a class="menu-link" href="/admin/servers/images">
|
|
||||||
<span class="menu-bullet">
|
|
||||||
<span class="bullet bullet-dot"></span>
|
|
||||||
</span>
|
|
||||||
<span class="menu-title"><TL>Images</TL></span>
|
|
||||||
</a>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
<div class="menu-item">
|
<div class="menu-item">
|
||||||
<a class="menu-link" href="/admin/webspaces">
|
<a class="menu-link" href="/admin/webspaces">
|
||||||
<span class="menu-icon">
|
<span class="menu-icon">
|
||||||
@@ -228,7 +189,7 @@ else
|
|||||||
{
|
{
|
||||||
if (firstRender)
|
if (firstRender)
|
||||||
{
|
{
|
||||||
User = await IdentityService.Get();
|
User = IdentityService.User;
|
||||||
|
|
||||||
await InvokeAsync(StateHasChanged);
|
await InvokeAsync(StateHasChanged);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,28 +0,0 @@
|
|||||||
@using Moonlight.App.Services.Sessions
|
|
||||||
@using Moonlight.App.Database.Entities
|
|
||||||
|
|
||||||
@if (User != null)
|
|
||||||
{
|
|
||||||
if (User.Admin)
|
|
||||||
{
|
|
||||||
@ChildContent
|
|
||||||
}
|
|
||||||
else if(!Silent)
|
|
||||||
{
|
|
||||||
<div class="alert alert-danger">
|
|
||||||
<TL>Missing admin permissions. This attempt has been logged ;)</TL>
|
|
||||||
</div>
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
@code
|
|
||||||
{
|
|
||||||
[Parameter]
|
|
||||||
public RenderFragment ChildContent { get; set; }
|
|
||||||
|
|
||||||
[CascadingParameter]
|
|
||||||
public User? User { get; set; }
|
|
||||||
|
|
||||||
[Parameter]
|
|
||||||
public bool Silent { get; set; } = false;
|
|
||||||
}
|
|
||||||
@@ -42,7 +42,6 @@
|
|||||||
}
|
}
|
||||||
|
|
||||||
<GlobalErrorBoundary>
|
<GlobalErrorBoundary>
|
||||||
<CascadingValue Value="User">
|
|
||||||
<PageTitle>@(string.IsNullOrEmpty(title) ? "Dashboard - " : title)Moonlight</PageTitle>
|
<PageTitle>@(string.IsNullOrEmpty(title) ? "Dashboard - " : title)Moonlight</PageTitle>
|
||||||
|
|
||||||
<div class="d-flex flex-column flex-root app-root" id="kt_app_root">
|
<div class="d-flex flex-column flex-root app-root" id="kt_app_root">
|
||||||
@@ -70,31 +69,33 @@
|
|||||||
uri.LocalPath != "/passwordreset" &&
|
uri.LocalPath != "/passwordreset" &&
|
||||||
uri.LocalPath != "/register")
|
uri.LocalPath != "/register")
|
||||||
{
|
{
|
||||||
if (User == null)
|
if (IdentityService.User == null)
|
||||||
{
|
{
|
||||||
<Login></Login>
|
<Login></Login>
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
if (User.Status == UserStatus.Banned)
|
if (IdentityService.User.Status == UserStatus.Banned)
|
||||||
{
|
{
|
||||||
<BannedAlert></BannedAlert>
|
<BannedAlert></BannedAlert>
|
||||||
}
|
}
|
||||||
else if (User.Status == UserStatus.Disabled)
|
else if (IdentityService.User.Status == UserStatus.Disabled)
|
||||||
{
|
{
|
||||||
<DisabledAlert></DisabledAlert>
|
<DisabledAlert></DisabledAlert>
|
||||||
}
|
}
|
||||||
else if (User.Status == UserStatus.PasswordPending)
|
else if (IdentityService.User.Status == UserStatus.PasswordPending)
|
||||||
{
|
{
|
||||||
<PasswordChangeView></PasswordChangeView>
|
<PasswordChangeView></PasswordChangeView>
|
||||||
}
|
}
|
||||||
else if (User.Status == UserStatus.DataPending)
|
else if (IdentityService.User.Status == UserStatus.DataPending)
|
||||||
{
|
{
|
||||||
<UserDataSetView></UserDataSetView>
|
<UserDataSetView></UserDataSetView>
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
<RenderPermissionChecker>
|
||||||
@Body
|
@Body
|
||||||
|
</RenderPermissionChecker>
|
||||||
|
|
||||||
<RatingPopup/>
|
<RatingPopup/>
|
||||||
}
|
}
|
||||||
@@ -153,12 +154,10 @@
|
|||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</CascadingValue>
|
|
||||||
</GlobalErrorBoundary>
|
</GlobalErrorBoundary>
|
||||||
|
|
||||||
@code
|
@code
|
||||||
{
|
{
|
||||||
private User? User;
|
|
||||||
private bool UserProcessed = false;
|
private bool UserProcessed = false;
|
||||||
|
|
||||||
private bool IsIpBanned = false;
|
private bool IsIpBanned = false;
|
||||||
@@ -202,7 +201,7 @@
|
|||||||
NavigationManager.NavigateTo(NavigationManager.Uri, true);
|
NavigationManager.NavigateTo(NavigationManager.Uri, true);
|
||||||
});
|
});
|
||||||
|
|
||||||
User = await IdentityService.Get();
|
await IdentityService.Load();
|
||||||
UserProcessed = true;
|
UserProcessed = true;
|
||||||
await InvokeAsync(StateHasChanged);
|
await InvokeAsync(StateHasChanged);
|
||||||
|
|
||||||
@@ -213,7 +212,10 @@
|
|||||||
await JsRuntime.InvokeVoidAsync("KTMenu.createInstances");
|
await JsRuntime.InvokeVoidAsync("KTMenu.createInstances");
|
||||||
await JsRuntime.InvokeVoidAsync("KTDrawer.createInstances");
|
await JsRuntime.InvokeVoidAsync("KTDrawer.createInstances");
|
||||||
}
|
}
|
||||||
catch (Exception){ /* ignore errors to make sure that the session call is executed */ }
|
catch (Exception)
|
||||||
|
{
|
||||||
|
/* ignore errors to make sure that the session call is executed */
|
||||||
|
}
|
||||||
|
|
||||||
await SessionClientService.Start();
|
await SessionClientService.Start();
|
||||||
|
|
||||||
@@ -223,14 +225,14 @@
|
|||||||
await DynamicBackgroundService.Reset();
|
await DynamicBackgroundService.Reset();
|
||||||
};
|
};
|
||||||
|
|
||||||
if (User != null)
|
if (IdentityService.User != null)
|
||||||
{
|
{
|
||||||
await Event.On<SupportChatMessage>(
|
await Event.On<SupportChatMessage>(
|
||||||
$"supportChat.{User.Id}.message",
|
$"supportChat.{IdentityService.User.Id}.message",
|
||||||
this,
|
this,
|
||||||
async message =>
|
async message =>
|
||||||
{
|
{
|
||||||
if (!NavigationManager.Uri.EndsWith("/support") && message.Sender != User)
|
if (!NavigationManager.Uri.EndsWith("/support") && message.Sender != IdentityService.User)
|
||||||
{
|
{
|
||||||
await ToastService.Info($"Support: {message.Content}");
|
await ToastService.Info($"Support: {message.Content}");
|
||||||
}
|
}
|
||||||
@@ -257,9 +259,9 @@
|
|||||||
|
|
||||||
await KeyListenerService.DisposeAsync();
|
await KeyListenerService.DisposeAsync();
|
||||||
|
|
||||||
if (User != null)
|
if (IdentityService.User != null)
|
||||||
{
|
{
|
||||||
await Event.Off($"supportChat.{User.Id}.message", this);
|
await Event.Off($"supportChat.{IdentityService.User.Id}.message", this);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -60,8 +60,6 @@
|
|||||||
|
|
||||||
@code
|
@code
|
||||||
{
|
{
|
||||||
private User? User;
|
|
||||||
|
|
||||||
protected override void OnInitialized()
|
protected override void OnInitialized()
|
||||||
{
|
{
|
||||||
AddBodyAttribute("data-kt-app-page-loading", "on");
|
AddBodyAttribute("data-kt-app-page-loading", "on");
|
||||||
@@ -95,7 +93,7 @@
|
|||||||
{
|
{
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
User = await IdentityService.Get();
|
await IdentityService.Load();
|
||||||
|
|
||||||
await InvokeAsync(StateHasChanged);
|
await InvokeAsync(StateHasChanged);
|
||||||
await Task.Delay(300);
|
await Task.Delay(300);
|
||||||
|
|||||||
@@ -1,2 +0,0 @@
|
|||||||
@page "/admin/aapanels"
|
|
||||||
|
|
||||||
@@ -1,5 +0,0 @@
|
|||||||
@page "/admin/databases"
|
|
||||||
|
|
||||||
<OnlyAdmin>
|
|
||||||
|
|
||||||
</OnlyAdmin>
|
|
||||||
@@ -9,7 +9,8 @@
|
|||||||
@inject DomainService DomainService
|
@inject DomainService DomainService
|
||||||
@inject SmartTranslateService SmartTranslateService
|
@inject SmartTranslateService SmartTranslateService
|
||||||
|
|
||||||
<OnlyAdmin>
|
@attribute [PermissionRequired(nameof(Permissions.AdminDomains))]
|
||||||
|
|
||||||
<LazyLoader @ref="LazyLoader" Load="Load">
|
<LazyLoader @ref="LazyLoader" Load="Load">
|
||||||
<div class="row">
|
<div class="row">
|
||||||
<div class="card">
|
<div class="card">
|
||||||
@@ -61,7 +62,6 @@
|
|||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</LazyLoader>
|
</LazyLoader>
|
||||||
</OnlyAdmin>
|
|
||||||
|
|
||||||
@code
|
@code
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -11,7 +11,8 @@
|
|||||||
@inject NavigationManager NavigationManager
|
@inject NavigationManager NavigationManager
|
||||||
@inject DomainService DomainService
|
@inject DomainService DomainService
|
||||||
|
|
||||||
<OnlyAdmin>
|
@attribute [PermissionRequired(nameof(Permissions.AdminNewDomain))]
|
||||||
|
|
||||||
<div class="row mb-5">
|
<div class="row mb-5">
|
||||||
<div class="card card-body p-10">
|
<div class="card card-body p-10">
|
||||||
<LazyLoader Load="Load">
|
<LazyLoader Load="Load">
|
||||||
@@ -48,7 +49,6 @@
|
|||||||
</LazyLoader>
|
</LazyLoader>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</OnlyAdmin>
|
|
||||||
|
|
||||||
@code
|
@code
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -12,7 +12,8 @@
|
|||||||
@inject AlertService AlertService
|
@inject AlertService AlertService
|
||||||
@inject ToastService ToastService
|
@inject ToastService ToastService
|
||||||
|
|
||||||
<OnlyAdmin>
|
@attribute [PermissionRequired(nameof(Permissions.AdminSharedDomains))]
|
||||||
|
|
||||||
<LazyLoader @ref="LazyLoader" Load="Load">
|
<LazyLoader @ref="LazyLoader" Load="Load">
|
||||||
<div class="card">
|
<div class="card">
|
||||||
<div class="card-header border-0 pt-5">
|
<div class="card-header border-0 pt-5">
|
||||||
@@ -44,7 +45,6 @@
|
|||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</LazyLoader>
|
</LazyLoader>
|
||||||
</OnlyAdmin>
|
|
||||||
|
|
||||||
@code
|
@code
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -12,6 +12,8 @@
|
|||||||
@inject ToastService ToastService
|
@inject ToastService ToastService
|
||||||
@inject NavigationManager NavigationManager
|
@inject NavigationManager NavigationManager
|
||||||
|
|
||||||
|
@attribute [PermissionRequired(nameof(Permissions.AdminNewSharedDomain))]
|
||||||
|
|
||||||
<LazyLoader Load="Load" @ref="LazyLoader">
|
<LazyLoader Load="Load" @ref="LazyLoader">
|
||||||
<div class="row mb-5">
|
<div class="row mb-5">
|
||||||
<div class="card card-body">
|
<div class="card card-body">
|
||||||
|
|||||||
@@ -14,7 +14,8 @@
|
|||||||
@inject DomainRepository DomainRepository
|
@inject DomainRepository DomainRepository
|
||||||
@inject ConfigService ConfigService
|
@inject ConfigService ConfigService
|
||||||
|
|
||||||
<OnlyAdmin>
|
@attribute [PermissionRequired(nameof(Permissions.AdminDashboard))]
|
||||||
|
|
||||||
<LazyLoader Load="Load">
|
<LazyLoader Load="Load">
|
||||||
<div class="row mb-5">
|
<div class="row mb-5">
|
||||||
<div class="col-12 col-lg-6 col-xl">
|
<div class="col-12 col-lg-6 col-xl">
|
||||||
@@ -125,7 +126,6 @@
|
|||||||
}
|
}
|
||||||
</LazyLoader>
|
</LazyLoader>
|
||||||
</LazyLoader>
|
</LazyLoader>
|
||||||
</OnlyAdmin>
|
|
||||||
|
|
||||||
@code
|
@code
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -15,7 +15,8 @@
|
|||||||
@inject SmartTranslateService SmartTranslateService
|
@inject SmartTranslateService SmartTranslateService
|
||||||
@inject EventSystem Event
|
@inject EventSystem Event
|
||||||
|
|
||||||
<OnlyAdmin>
|
@attribute [PermissionRequired(nameof(Permissions.AdminNodeDdos))]
|
||||||
|
|
||||||
<AdminNodesNavigation Index="1"/>
|
<AdminNodesNavigation Index="1"/>
|
||||||
|
|
||||||
<LazyLoader @ref="LazyLoader" Load="Load">
|
<LazyLoader @ref="LazyLoader" Load="Load">
|
||||||
@@ -69,7 +70,6 @@
|
|||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</LazyLoader>
|
</LazyLoader>
|
||||||
</OnlyAdmin>
|
|
||||||
|
|
||||||
@code
|
@code
|
||||||
{
|
{
|
||||||
@@ -99,4 +99,6 @@
|
|||||||
{
|
{
|
||||||
await Event.Off("node.ddos", this);
|
await Event.Off("node.ddos", this);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//TODO: Move to security
|
||||||
}
|
}
|
||||||
@@ -9,7 +9,8 @@
|
|||||||
@inject SmartTranslateService SmartTranslateService
|
@inject SmartTranslateService SmartTranslateService
|
||||||
@inject NavigationManager NavigationManager
|
@inject NavigationManager NavigationManager
|
||||||
|
|
||||||
<OnlyAdmin>
|
@attribute [PermissionRequired(nameof(Permissions.AdminNodeEdit))]
|
||||||
|
|
||||||
<LazyLoader Load="Load" @ref="LazyLoader">
|
<LazyLoader Load="Load" @ref="LazyLoader">
|
||||||
@if (Node == null)
|
@if (Node == null)
|
||||||
{
|
{
|
||||||
@@ -149,7 +150,6 @@
|
|||||||
</div>
|
</div>
|
||||||
}
|
}
|
||||||
</LazyLoader>
|
</LazyLoader>
|
||||||
</OnlyAdmin>
|
|
||||||
|
|
||||||
@code
|
@code
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -13,8 +13,9 @@
|
|||||||
@inject NodeService NodeService
|
@inject NodeService NodeService
|
||||||
@inject SmartTranslateService SmartTranslateService
|
@inject SmartTranslateService SmartTranslateService
|
||||||
|
|
||||||
<OnlyAdmin>
|
@attribute [PermissionRequired(nameof(Permissions.AdminNodes))]
|
||||||
<AdminNodesNavigation Index="0"/>
|
|
||||||
|
<AdminServersNavigation Index="3" />
|
||||||
|
|
||||||
<LazyLoader @ref="LazyLoader" Load="Load">
|
<LazyLoader @ref="LazyLoader" Load="Load">
|
||||||
<div class="card">
|
<div class="card">
|
||||||
@@ -95,7 +96,6 @@
|
|||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</LazyLoader>
|
</LazyLoader>
|
||||||
</OnlyAdmin>
|
|
||||||
|
|
||||||
@code
|
@code
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -9,7 +9,8 @@
|
|||||||
@inject NodeRepository NodeRepository
|
@inject NodeRepository NodeRepository
|
||||||
@inject NavigationManager NavigationManager
|
@inject NavigationManager NavigationManager
|
||||||
|
|
||||||
<OnlyAdmin>
|
@attribute [PermissionRequired(nameof(Permissions.AdminNewNode))]
|
||||||
|
|
||||||
<div class="d-flex flex-center">
|
<div class="d-flex flex-center">
|
||||||
<div class="card rounded-3 w-md-550px">
|
<div class="card rounded-3 w-md-550px">
|
||||||
<div class="card-body">
|
<div class="card-body">
|
||||||
@@ -73,7 +74,6 @@
|
|||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</OnlyAdmin>
|
|
||||||
|
|
||||||
@code
|
@code
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -6,11 +6,12 @@
|
|||||||
@inject NodeRepository NodeRepository
|
@inject NodeRepository NodeRepository
|
||||||
@inject ConfigService ConfigService
|
@inject ConfigService ConfigService
|
||||||
|
|
||||||
|
@attribute [PermissionRequired(nameof(Permissions.AdminNodeSetup))]
|
||||||
|
|
||||||
@{
|
@{
|
||||||
var appUrl = ConfigService.Get().Moonlight.AppUrl;
|
var appUrl = ConfigService.Get().Moonlight.AppUrl;
|
||||||
}
|
}
|
||||||
|
|
||||||
<OnlyAdmin>
|
|
||||||
<LazyLoader Load="Load">
|
<LazyLoader Load="Load">
|
||||||
@if (Node == null)
|
@if (Node == null)
|
||||||
{
|
{
|
||||||
@@ -141,7 +142,6 @@
|
|||||||
</div>
|
</div>
|
||||||
}
|
}
|
||||||
</LazyLoader>
|
</LazyLoader>
|
||||||
</OnlyAdmin>
|
|
||||||
|
|
||||||
@code
|
@code
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -10,7 +10,8 @@
|
|||||||
@inject NodeRepository NodeRepository
|
@inject NodeRepository NodeRepository
|
||||||
@inject NodeService NodeService
|
@inject NodeService NodeService
|
||||||
|
|
||||||
<OnlyAdmin>
|
@attribute [PermissionRequired(nameof(Permissions.AdminNodeView))]
|
||||||
|
|
||||||
<LazyLoader Load="Load">
|
<LazyLoader Load="Load">
|
||||||
@if (Node == null)
|
@if (Node == null)
|
||||||
{
|
{
|
||||||
@@ -252,7 +253,6 @@ else
|
|||||||
</div>
|
</div>
|
||||||
}
|
}
|
||||||
</LazyLoader>
|
</LazyLoader>
|
||||||
</OnlyAdmin>
|
|
||||||
|
|
||||||
@code
|
@code
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -12,7 +12,8 @@
|
|||||||
|
|
||||||
@implements IDisposable
|
@implements IDisposable
|
||||||
|
|
||||||
<OnlyAdmin>
|
@attribute [PermissionRequired(nameof(Permissions.AdminNotificationDebugging))]
|
||||||
|
|
||||||
<LazyLoader Load="Load">
|
<LazyLoader Load="Load">
|
||||||
<div class="card card-body">
|
<div class="card card-body">
|
||||||
<Table TableItem="ActiveNotificationClient" Items="Clients" PageSize="25" TableClass="table table-row-bordered table-row-gray-100 align-middle gs-0 gy-3" TableHeadClass="fw-bold text-muted">
|
<Table TableItem="ActiveNotificationClient" Items="Clients" PageSize="25" TableClass="table table-row-bordered table-row-gray-100 align-middle gs-0 gy-3" TableHeadClass="fw-bold text-muted">
|
||||||
@@ -31,8 +32,6 @@
|
|||||||
</Table>
|
</Table>
|
||||||
</div>
|
</div>
|
||||||
</LazyLoader>
|
</LazyLoader>
|
||||||
</OnlyAdmin>
|
|
||||||
|
|
||||||
|
|
||||||
@code
|
@code
|
||||||
{
|
{
|
||||||
|
|||||||
7
Moonlight/Shared/Views/Admin/Security/Index.razor
Normal file
7
Moonlight/Shared/Views/Admin/Security/Index.razor
Normal file
@@ -0,0 +1,7 @@
|
|||||||
|
@page "/admin/security"
|
||||||
|
|
||||||
|
@using Moonlight.Shared.Components.Navigations
|
||||||
|
|
||||||
|
@attribute [PermissionRequired(nameof(Permissions.AdminSecurity))]
|
||||||
|
|
||||||
|
<AdminSecurityNavigation Index="0" />
|
||||||
@@ -1,4 +1,4 @@
|
|||||||
@page "/admin/system/security"
|
@page "/admin/security/ipbans"
|
||||||
|
|
||||||
@using Moonlight.Shared.Components.Navigations
|
@using Moonlight.Shared.Components.Navigations
|
||||||
@using BlazorTable
|
@using BlazorTable
|
||||||
@@ -13,8 +13,9 @@
|
|||||||
@inject EventSystem Event
|
@inject EventSystem Event
|
||||||
@inject ToastService ToastService
|
@inject ToastService ToastService
|
||||||
|
|
||||||
<OnlyAdmin>
|
@attribute [PermissionRequired(nameof(Permissions.AdminSecurityIpBans))]
|
||||||
<AdminSystemNavigation Index="3"/>
|
|
||||||
|
<AdminSecurityNavigation Index="2"/>
|
||||||
|
|
||||||
<div class="card mb-5">
|
<div class="card mb-5">
|
||||||
<div class="card-header">
|
<div class="card-header">
|
||||||
@@ -40,7 +41,8 @@
|
|||||||
</div>
|
</div>
|
||||||
<div class="card-body">
|
<div class="card-body">
|
||||||
<LazyLoader @ref="LazyLoader" Load="Load">
|
<LazyLoader @ref="LazyLoader" Load="Load">
|
||||||
<Table TableItem="IpBan" Items="IpBans" PageSize="25" TableClass="table table-row-bordered table-row-gray-100 align-middle gs-0 gy-3" TableHeadClass="fw-bold text-muted">
|
<div class="table-responsive">
|
||||||
|
<Table TableItem="IpBan" Items="AllIpBans" PageSize="25" TableClass="table table-row-bordered table-row-gray-100 align-middle gs-0 gy-3" TableHeadClass="fw-bold text-muted">
|
||||||
<Column TableItem="IpBan" Title="@(SmartTranslateService.Translate("Ip"))" Field="@(x => x.Ip)" Filterable="true" Sortable="false"/>
|
<Column TableItem="IpBan" Title="@(SmartTranslateService.Translate("Ip"))" Field="@(x => x.Ip)" Filterable="true" Sortable="false"/>
|
||||||
<Column TableItem="IpBan" Title="" Field="@(x => x.Id)" Filterable="false" Sortable="false">
|
<Column TableItem="IpBan" Title="" Field="@(x => x.Id)" Filterable="false" Sortable="false">
|
||||||
<Template>
|
<Template>
|
||||||
@@ -51,21 +53,21 @@
|
|||||||
</Column>
|
</Column>
|
||||||
<Pager ShowPageNumber="true" ShowTotalCount="true"/>
|
<Pager ShowPageNumber="true" ShowTotalCount="true"/>
|
||||||
</Table>
|
</Table>
|
||||||
|
</div>
|
||||||
</LazyLoader>
|
</LazyLoader>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</OnlyAdmin>
|
|
||||||
|
|
||||||
@code
|
@code
|
||||||
{
|
{
|
||||||
private IpBan[] IpBans;
|
private IpBan[] AllIpBans;
|
||||||
private string Ip;
|
private string Ip;
|
||||||
|
|
||||||
private LazyLoader LazyLoader;
|
private LazyLoader LazyLoader;
|
||||||
|
|
||||||
private Task Load(LazyLoader arg)
|
private Task Load(LazyLoader arg)
|
||||||
{
|
{
|
||||||
IpBans = IpBanRepository.Get().ToArray();
|
AllIpBans = IpBanRepository.Get().ToArray();
|
||||||
|
|
||||||
return Task.CompletedTask;
|
return Task.CompletedTask;
|
||||||
}
|
}
|
||||||
134
Moonlight/Shared/Views/Admin/Security/Malware.razor
Normal file
134
Moonlight/Shared/Views/Admin/Security/Malware.razor
Normal file
@@ -0,0 +1,134 @@
|
|||||||
|
@page "/admin/security/malware"
|
||||||
|
|
||||||
|
@using Moonlight.Shared.Components.Navigations
|
||||||
|
@using Moonlight.App.Services.Background
|
||||||
|
@using Moonlight.App.Services
|
||||||
|
@using BlazorTable
|
||||||
|
@using Moonlight.App.Database.Entities
|
||||||
|
@using Moonlight.App.Events
|
||||||
|
@using Moonlight.App.Models.Misc
|
||||||
|
|
||||||
|
@inject MalwareScanService MalwareScanService
|
||||||
|
@inject SmartTranslateService SmartTranslateService
|
||||||
|
@inject EventSystem Event
|
||||||
|
|
||||||
|
@implements IDisposable
|
||||||
|
|
||||||
|
@attribute [PermissionRequired(nameof(Permissions.AdminSecurityMalware))]
|
||||||
|
|
||||||
|
<AdminSecurityNavigation Index="1"/>
|
||||||
|
|
||||||
|
<div class="row">
|
||||||
|
<div class="col-12 col-lg-6">
|
||||||
|
<div class="card">
|
||||||
|
<div class="card-body">
|
||||||
|
@if (MalwareScanService.IsRunning)
|
||||||
|
{
|
||||||
|
<span class="fs-3 spinner-border align-middle me-3"></span>
|
||||||
|
}
|
||||||
|
|
||||||
|
<span class="fs-3">@(MalwareScanService.Status)</span>
|
||||||
|
</div>
|
||||||
|
<div class="card-footer">
|
||||||
|
@if (MalwareScanService.IsRunning)
|
||||||
|
{
|
||||||
|
<button class="btn btn-success disabled">
|
||||||
|
<TL>Scan in progress</TL>
|
||||||
|
</button>
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
<WButton Text="@(SmartTranslateService.Translate("Start scan"))"
|
||||||
|
CssClasses="btn-success"
|
||||||
|
OnClick="MalwareScanService.Start">
|
||||||
|
</WButton>
|
||||||
|
}
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
<div class="col-12 col-lg-6">
|
||||||
|
<div class="card">
|
||||||
|
<div class="card-header">
|
||||||
|
<span class="card-title">
|
||||||
|
<TL>Results</TL>
|
||||||
|
</span>
|
||||||
|
</div>
|
||||||
|
<div class="card-body">
|
||||||
|
<LazyLoader @ref="LazyLoaderResults" Load="LoadResults">
|
||||||
|
<div class="table-responsive">
|
||||||
|
<Table TableItem="Server" Items="ScanResults.Keys" PageSize="25" TableClass="table table-row-bordered table-row-gray-100 align-middle gs-0 gy-3" TableHeadClass="fw-bold text-muted">
|
||||||
|
<Column TableItem="Server" Title="@(SmartTranslateService.Translate("Server"))" Field="@(x => x.Id)" Sortable="false" Filterable="false">
|
||||||
|
<Template>
|
||||||
|
<a href="/server/@(context.Uuid)">@(context.Name)</a>
|
||||||
|
</Template>
|
||||||
|
</Column>
|
||||||
|
<Column TableItem="Server" Title="@(SmartTranslateService.Translate("Results"))" Field="@(x => x.Id)" Sortable="false" Filterable="false">
|
||||||
|
<Template>
|
||||||
|
<div class="row">
|
||||||
|
@foreach (var result in ScanResults[context])
|
||||||
|
{
|
||||||
|
<div class="col-12 col-md-6 p-3">
|
||||||
|
<div class="accordion" id="scanResult@(result.GetHashCode())">
|
||||||
|
<div class="accordion-item">
|
||||||
|
<h2 class="accordion-header" id="scanResult-header@(result.GetHashCode())">
|
||||||
|
<button class="accordion-button fs-4 fw-semibold collapsed" type="button" data-bs-toggle="collapse" data-bs-target="#scanResult-body@(result.GetHashCode())" aria-expanded="false" aria-controls="scanResult-body@(result.GetHashCode())">
|
||||||
|
<span>@(result.Title)</span>
|
||||||
|
</button>
|
||||||
|
</h2>
|
||||||
|
<div id="scanResult-body@(result.GetHashCode())" class="accordion-collapse collapse" aria-labelledby="scanResult-header@(result.GetHashCode())" data-bs-parent="#scanResult">
|
||||||
|
<div class="accordion-body">
|
||||||
|
<p>
|
||||||
|
@(result.Description)
|
||||||
|
</p>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
}
|
||||||
|
</div>
|
||||||
|
</Template>
|
||||||
|
</Column>
|
||||||
|
<Pager ShowPageNumber="true" ShowTotalCount="true"/>
|
||||||
|
</Table>
|
||||||
|
</div>
|
||||||
|
</LazyLoader>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
@code
|
||||||
|
{
|
||||||
|
private readonly Dictionary<Server, MalwareScanResult[]> ScanResults = new();
|
||||||
|
|
||||||
|
private LazyLoader LazyLoaderResults;
|
||||||
|
|
||||||
|
protected override async Task OnInitializedAsync()
|
||||||
|
{
|
||||||
|
await Event.On<Object>("malwareScan.status", this, async o => { await InvokeAsync(StateHasChanged); });
|
||||||
|
|
||||||
|
await Event.On<Object>("malwareScan.result", this, async o => { await LazyLoaderResults.Reload(); });
|
||||||
|
}
|
||||||
|
|
||||||
|
private Task LoadResults(LazyLoader arg)
|
||||||
|
{
|
||||||
|
ScanResults.Clear();
|
||||||
|
|
||||||
|
lock (MalwareScanService.ScanResults)
|
||||||
|
{
|
||||||
|
foreach (var result in MalwareScanService.ScanResults)
|
||||||
|
{
|
||||||
|
ScanResults.Add(result.Key, result.Value);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return Task.CompletedTask;
|
||||||
|
}
|
||||||
|
|
||||||
|
public async void Dispose()
|
||||||
|
{
|
||||||
|
await Event.Off("malwareScan.status", this);
|
||||||
|
await Event.Off("malwareScan.result", this);
|
||||||
|
}
|
||||||
|
}
|
||||||
132
Moonlight/Shared/Views/Admin/Security/PermissionGroups.razor
Normal file
132
Moonlight/Shared/Views/Admin/Security/PermissionGroups.razor
Normal file
@@ -0,0 +1,132 @@
|
|||||||
|
@page "/admin/security/permissiongroups"
|
||||||
|
|
||||||
|
@using Moonlight.Shared.Components.Navigations
|
||||||
|
@using Moonlight.App.Services
|
||||||
|
@using Moonlight.App.Repositories
|
||||||
|
@using Moonlight.App.Database.Entities
|
||||||
|
@using BlazorTable
|
||||||
|
@using Microsoft.EntityFrameworkCore
|
||||||
|
@using Moonlight.App.Services.Interop
|
||||||
|
@using Moonlight.App.Services.Sessions
|
||||||
|
|
||||||
|
@inject SmartTranslateService SmartTranslateService
|
||||||
|
@inject Repository<PermissionGroup> PermissionGroupRepository
|
||||||
|
@inject SessionServerService SessionServerService
|
||||||
|
@inject Repository<User> UserRepository
|
||||||
|
@inject AlertService AlertService
|
||||||
|
@inject ToastService ToastService
|
||||||
|
|
||||||
|
@attribute [PermissionRequired(nameof(Permissions.AdminSecurityPermissionGroups))]
|
||||||
|
|
||||||
|
<AdminSecurityNavigation Index="3"/>
|
||||||
|
|
||||||
|
<div class="card">
|
||||||
|
<div class="card-header">
|
||||||
|
<span class="card-title">
|
||||||
|
<TL>Permission groups</TL>
|
||||||
|
</span>
|
||||||
|
<div class="card-toolbar">
|
||||||
|
<WButton Text="@(SmartTranslateService.Translate("New"))"
|
||||||
|
CssClasses="btn-sm btn-success"
|
||||||
|
OnClick="NewGroupPermission">
|
||||||
|
</WButton>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
<div class="card-body">
|
||||||
|
<LazyLoader @ref="LazyLoader" Load="Load">
|
||||||
|
<div class="table-responsive">
|
||||||
|
<Table TableItem="PermissionGroup" Items="AllPermissionGroups" PageSize="25" TableClass="table table-row-bordered table-row-gray-100 align-middle gs-0 gy-3" TableHeadClass="fw-bold text-muted">
|
||||||
|
<Column TableItem="PermissionGroup" Title="@(SmartTranslateService.Translate("Name"))" Field="@(x => x.Name)" Filterable="true" Sortable="false"/>
|
||||||
|
<Column TableItem="PermissionGroup" Title="" Field="@(x => x.Id)" Filterable="false" Sortable="false">
|
||||||
|
<Template>
|
||||||
|
<div class="text-end">
|
||||||
|
<WButton Text="@(SmartTranslateService.Translate("Edit permissions"))"
|
||||||
|
CssClasses="btn-primary me-2"
|
||||||
|
OnClick="() => EditPermissions(context)">
|
||||||
|
</WButton>
|
||||||
|
<DeleteButton Confirm="true" OnClick="() => DeletePermissionGroup(context)"></DeleteButton>
|
||||||
|
</div>
|
||||||
|
</Template>
|
||||||
|
</Column>
|
||||||
|
<Pager ShowPageNumber="true" ShowTotalCount="true"/>
|
||||||
|
</Table>
|
||||||
|
</div>
|
||||||
|
</LazyLoader>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<PermissionEditor @ref="PermissionEditor" OnSave="OnSave"/>
|
||||||
|
|
||||||
|
@code
|
||||||
|
{
|
||||||
|
private PermissionGroup[] AllPermissionGroups;
|
||||||
|
private PermissionGroup CurrentPermissionGroup;
|
||||||
|
private LazyLoader LazyLoader;
|
||||||
|
private PermissionEditor PermissionEditor;
|
||||||
|
|
||||||
|
private Task Load(LazyLoader arg)
|
||||||
|
{
|
||||||
|
AllPermissionGroups = PermissionGroupRepository
|
||||||
|
.Get()
|
||||||
|
.ToArray();
|
||||||
|
|
||||||
|
return Task.CompletedTask;
|
||||||
|
}
|
||||||
|
|
||||||
|
private async Task EditPermissions(PermissionGroup group)
|
||||||
|
{
|
||||||
|
CurrentPermissionGroup = group;
|
||||||
|
PermissionEditor.InitialData = CurrentPermissionGroup.Permissions;
|
||||||
|
|
||||||
|
await PermissionEditor.Launch();
|
||||||
|
}
|
||||||
|
|
||||||
|
private async Task DeletePermissionGroup(PermissionGroup group)
|
||||||
|
{
|
||||||
|
PermissionGroupRepository.Delete(group);
|
||||||
|
|
||||||
|
await LazyLoader.Reload();
|
||||||
|
}
|
||||||
|
|
||||||
|
private async Task OnSave(byte[] data)
|
||||||
|
{
|
||||||
|
CurrentPermissionGroup.Permissions = data;
|
||||||
|
PermissionGroupRepository.Update(CurrentPermissionGroup);
|
||||||
|
|
||||||
|
await ToastService.Success("Successfully modified permissions");
|
||||||
|
|
||||||
|
var usersWithTheGroup = UserRepository
|
||||||
|
.Get()
|
||||||
|
.Include(x => x.PermissionGroup)
|
||||||
|
.Where(x => x.PermissionGroup != null)
|
||||||
|
.Where(x => x.PermissionGroup!.Id == CurrentPermissionGroup.Id)
|
||||||
|
.ToArray();
|
||||||
|
|
||||||
|
foreach (var user in usersWithTheGroup)
|
||||||
|
{
|
||||||
|
await SessionServerService.ReloadUserSessions(user);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private async Task NewGroupPermission()
|
||||||
|
{
|
||||||
|
var name = await AlertService.Text(
|
||||||
|
SmartTranslateService.Translate("Enter the name for the new group"),
|
||||||
|
"",
|
||||||
|
""
|
||||||
|
);
|
||||||
|
|
||||||
|
if(string.IsNullOrEmpty(name))
|
||||||
|
return;
|
||||||
|
|
||||||
|
var group = new PermissionGroup()
|
||||||
|
{
|
||||||
|
Name = name,
|
||||||
|
Permissions = Array.Empty<byte>()
|
||||||
|
};
|
||||||
|
|
||||||
|
PermissionGroupRepository.Add(group);
|
||||||
|
|
||||||
|
await LazyLoader.Reload();
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -1,13 +1,17 @@
|
|||||||
@page "/admin/servers/cleanup"
|
@page "/admin/servers/cleanup"
|
||||||
@using Moonlight.App.Events
|
@using Moonlight.App.Events
|
||||||
@using Moonlight.App.Services.Background
|
@using Moonlight.App.Services.Background
|
||||||
|
@using Moonlight.Shared.Components.Navigations
|
||||||
|
|
||||||
@inject CleanupService CleanupService
|
@inject CleanupService CleanupService
|
||||||
@inject EventSystem Event
|
@inject EventSystem Event
|
||||||
|
|
||||||
@implements IDisposable
|
@implements IDisposable
|
||||||
|
|
||||||
<OnlyAdmin>
|
@attribute [PermissionRequired(nameof(Permissions.AdminServerCleanup))]
|
||||||
|
|
||||||
|
<AdminServersNavigation Index="2" />
|
||||||
|
|
||||||
<div class="row g-5 g-xl-10 mb-5 mb-xl-10">
|
<div class="row g-5 g-xl-10 mb-5 mb-xl-10">
|
||||||
<div class="col-xl-3">
|
<div class="col-xl-3">
|
||||||
<div class="card card-flush bgi-no-repeat bgi-size-contain bgi-position-x-end h-xl-100" style="background-color: #170049;">
|
<div class="card card-flush bgi-no-repeat bgi-size-contain bgi-position-x-end h-xl-100" style="background-color: #170049;">
|
||||||
@@ -76,7 +80,6 @@
|
|||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</OnlyAdmin>
|
|
||||||
|
|
||||||
@code
|
@code
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -13,7 +13,8 @@
|
|||||||
@inject ImageRepository ImageRepository
|
@inject ImageRepository ImageRepository
|
||||||
@inject Repository<User> UserRepository
|
@inject Repository<User> UserRepository
|
||||||
|
|
||||||
<OnlyAdmin>
|
@attribute [PermissionRequired(nameof(Permissions.AdminServerEdit))]
|
||||||
|
|
||||||
<LazyLoader @ref="LazyLoader" Load="Load">
|
<LazyLoader @ref="LazyLoader" Load="Load">
|
||||||
@if (Server == null)
|
@if (Server == null)
|
||||||
{
|
{
|
||||||
@@ -171,7 +172,6 @@
|
|||||||
</SmartForm>
|
</SmartForm>
|
||||||
}
|
}
|
||||||
</LazyLoader>
|
</LazyLoader>
|
||||||
</OnlyAdmin>
|
|
||||||
|
|
||||||
@code
|
@code
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -12,7 +12,8 @@
|
|||||||
@inject ToastService ToastService
|
@inject ToastService ToastService
|
||||||
@inject FileDownloadService FileDownloadService
|
@inject FileDownloadService FileDownloadService
|
||||||
|
|
||||||
<OnlyAdmin>
|
@attribute [PermissionRequired(nameof(Permissions.AdminServerImageEdit))]
|
||||||
|
|
||||||
<div class="row">
|
<div class="row">
|
||||||
<LazyLoader @ref="LazyLoader" Load="Load">
|
<LazyLoader @ref="LazyLoader" Load="Load">
|
||||||
@if (Image == null)
|
@if (Image == null)
|
||||||
@@ -257,7 +258,6 @@ else
|
|||||||
}
|
}
|
||||||
</LazyLoader>
|
</LazyLoader>
|
||||||
</div>
|
</div>
|
||||||
</OnlyAdmin>
|
|
||||||
|
|
||||||
@code
|
@code
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -9,6 +9,7 @@
|
|||||||
@using System.Text
|
@using System.Text
|
||||||
@using Moonlight.App.Helpers
|
@using Moonlight.App.Helpers
|
||||||
@using Newtonsoft.Json
|
@using Newtonsoft.Json
|
||||||
|
@using Moonlight.Shared.Components.Navigations
|
||||||
|
|
||||||
@inject Repository<Image> ImageRepository
|
@inject Repository<Image> ImageRepository
|
||||||
@inject Repository<ImageVariable> ImageVariableRepository
|
@inject Repository<ImageVariable> ImageVariableRepository
|
||||||
@@ -16,8 +17,10 @@
|
|||||||
@inject SmartTranslateService SmartTranslateService
|
@inject SmartTranslateService SmartTranslateService
|
||||||
@inject AlertService AlertService
|
@inject AlertService AlertService
|
||||||
|
|
||||||
<OnlyAdmin>
|
@attribute [PermissionRequired(nameof(Permissions.AdminServerImages))]
|
||||||
<div class="row">
|
|
||||||
|
<AdminServersNavigation Index="4" />
|
||||||
|
|
||||||
<LazyLoader @ref="LazyLoader" Load="Load">
|
<LazyLoader @ref="LazyLoader" Load="Load">
|
||||||
<div class="card">
|
<div class="card">
|
||||||
<div class="card-header border-0 pt-5">
|
<div class="card-header border-0 pt-5">
|
||||||
@@ -103,8 +106,6 @@
|
|||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</LazyLoader>
|
</LazyLoader>
|
||||||
</div>
|
|
||||||
</OnlyAdmin>
|
|
||||||
|
|
||||||
@code
|
@code
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -4,17 +4,22 @@
|
|||||||
@using Moonlight.App.Repositories.Servers
|
@using Moonlight.App.Repositories.Servers
|
||||||
@using BlazorTable
|
@using BlazorTable
|
||||||
@using Microsoft.EntityFrameworkCore
|
@using Microsoft.EntityFrameworkCore
|
||||||
|
@using Moonlight.Shared.Components.Navigations
|
||||||
|
|
||||||
@inject ServerRepository ServerRepository
|
@inject ServerRepository ServerRepository
|
||||||
@inject SmartTranslateService SmartTranslateService
|
@inject SmartTranslateService SmartTranslateService
|
||||||
|
|
||||||
<OnlyAdmin>
|
@attribute [PermissionRequired(nameof(Permissions.AdminServers))]
|
||||||
<div class="row">
|
|
||||||
|
<AdminServersNavigation Index="0" />
|
||||||
|
|
||||||
<LazyLoader Load="Load">
|
<LazyLoader Load="Load">
|
||||||
<div class="card">
|
<div class="card">
|
||||||
<div class="card-header border-0 pt-5">
|
<div class="card-header border-0 pt-5">
|
||||||
<h3 class="card-title align-items-start flex-column">
|
<h3 class="card-title align-items-start flex-column">
|
||||||
<span class="card-label fw-bold fs-3 mb-1"><TL>Servers</TL></span>
|
<span class="card-label fw-bold fs-3 mb-1">
|
||||||
|
<TL>Servers</TL>
|
||||||
|
</span>
|
||||||
</h3>
|
</h3>
|
||||||
<div class="card-toolbar">
|
<div class="card-toolbar">
|
||||||
<a href="/admin/servers/new" class="btn btn-sm btn-light-success">
|
<a href="/admin/servers/new" class="btn btn-sm btn-light-success">
|
||||||
@@ -62,8 +67,6 @@
|
|||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</LazyLoader>
|
</LazyLoader>
|
||||||
</div>
|
|
||||||
</OnlyAdmin>
|
|
||||||
|
|
||||||
@code
|
@code
|
||||||
{
|
{
|
||||||
@@ -74,6 +77,8 @@
|
|||||||
Servers = ServerRepository
|
Servers = ServerRepository
|
||||||
.Get()
|
.Get()
|
||||||
.Include(x => x.Owner)
|
.Include(x => x.Owner)
|
||||||
|
.ToArray() // Execute query and use the moonlight instance to sort
|
||||||
|
.OrderBy(x => x.Id)
|
||||||
.ToArray();
|
.ToArray();
|
||||||
|
|
||||||
return Task.CompletedTask;
|
return Task.CompletedTask;
|
||||||
|
|||||||
@@ -6,7 +6,7 @@
|
|||||||
@using Moonlight.App.Database.Entities
|
@using Moonlight.App.Database.Entities
|
||||||
@using BlazorTable
|
@using BlazorTable
|
||||||
@using Microsoft.EntityFrameworkCore
|
@using Microsoft.EntityFrameworkCore
|
||||||
@using Moonlight.App.ApiClients.Daemon.Resources
|
@using Moonlight.Shared.Components.Navigations
|
||||||
@using Moonlight.App.ApiClients.Wings
|
@using Moonlight.App.ApiClients.Wings
|
||||||
@using Moonlight.App.Helpers
|
@using Moonlight.App.Helpers
|
||||||
@using Moonlight.App.Models.Misc
|
@using Moonlight.App.Models.Misc
|
||||||
@@ -18,17 +18,31 @@
|
|||||||
@inject AlertService AlertService
|
@inject AlertService AlertService
|
||||||
@inject ServerService ServerService
|
@inject ServerService ServerService
|
||||||
|
|
||||||
<OnlyAdmin>
|
@attribute [PermissionRequired(nameof(Permissions.AdminServerManager))]
|
||||||
<div class="card mb-5">
|
|
||||||
<div class="card-body">
|
<AdminServersNavigation Index="1"/>
|
||||||
|
|
||||||
|
<div class="card">
|
||||||
|
<div class="card-header">
|
||||||
|
<span class="card-title">
|
||||||
|
@if (IsRunning)
|
||||||
|
{
|
||||||
|
<span><TL>Status</TL>: <TL>Currently scanning</TL> @(Node?.Name)</span>
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
<span><TL>Status</TL>: <TL>Scan complete</TL></span>
|
||||||
|
}
|
||||||
|
</span>
|
||||||
|
<div class="card-toolbar">
|
||||||
<WButton Text="@(SmartTranslateService.Translate("Refresh"))"
|
<WButton Text="@(SmartTranslateService.Translate("Refresh"))"
|
||||||
WorkingText="@(SmartTranslateService.Translate("Working"))"
|
WorkingText="@(SmartTranslateService.Translate("Working"))"
|
||||||
CssClasses="btn-primary"
|
CssClasses="btn-primary me-2"
|
||||||
OnClick="() => Task.Run(Scan)">
|
OnClick="() => Task.Run(Scan)">
|
||||||
</WButton>
|
</WButton>
|
||||||
<WButton Text="@(SmartTranslateService.Translate("Stop all"))"
|
<WButton Text="@(SmartTranslateService.Translate("Stop all"))"
|
||||||
WorkingText="@(SmartTranslateService.Translate("Working"))"
|
WorkingText="@(SmartTranslateService.Translate("Working"))"
|
||||||
CssClasses="btn-danger"
|
CssClasses="btn-danger me-2"
|
||||||
OnClick="StopAll">
|
OnClick="StopAll">
|
||||||
</WButton>
|
</WButton>
|
||||||
<WButton Text="@(SmartTranslateService.Translate("Kill all"))"
|
<WButton Text="@(SmartTranslateService.Translate("Kill all"))"
|
||||||
@@ -38,19 +52,7 @@
|
|||||||
</WButton>
|
</WButton>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<div class="card mb-5 bg-secondary">
|
<div class="card-body">
|
||||||
<div class="card-body d-flex align-items-center">
|
|
||||||
@if (IsRunning)
|
|
||||||
{
|
|
||||||
<h4><TL>Currently scanning</TL>: @(Node?.Name)</h4>
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
<TL>Scan complete</TL>
|
|
||||||
}
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
<div class="card card-body">
|
|
||||||
<div class="table-responsive">
|
<div class="table-responsive">
|
||||||
<Table TableItem="RunningServer" Items="RunningServers" PageSize="25" TableClass="table table-row-bordered table-row-gray-100 align-middle gs-0 gy-3" TableHeadClass="fw-bold text-muted">
|
<Table TableItem="RunningServer" Items="RunningServers" PageSize="25" TableClass="table table-row-bordered table-row-gray-100 align-middle gs-0 gy-3" TableHeadClass="fw-bold text-muted">
|
||||||
<Column TableItem="RunningServer" Title="@(SmartTranslateService.Translate("Name"))" Field="@(x => x.Server.Name)" Sortable="true" Filterable="true">
|
<Column TableItem="RunningServer" Title="@(SmartTranslateService.Translate("Name"))" Field="@(x => x.Server.Name)" Sortable="true" Filterable="true">
|
||||||
@@ -97,7 +99,7 @@
|
|||||||
</Table>
|
</Table>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</OnlyAdmin>
|
</div>
|
||||||
|
|
||||||
@code
|
@code
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -17,7 +17,8 @@
|
|||||||
@inject NavigationManager NavigationManager
|
@inject NavigationManager NavigationManager
|
||||||
@inject UserRepository UserRepository
|
@inject UserRepository UserRepository
|
||||||
|
|
||||||
<OnlyAdmin>
|
@attribute [PermissionRequired(nameof(Permissions.AdminNewServer))]
|
||||||
|
|
||||||
<LazyLoader Load="Load">
|
<LazyLoader Load="Load">
|
||||||
<SmartForm Model="Model" OnValidSubmit="Create">
|
<SmartForm Model="Model" OnValidSubmit="Create">
|
||||||
<div class="row mb-5">
|
<div class="row mb-5">
|
||||||
@@ -173,7 +174,6 @@
|
|||||||
</div>
|
</div>
|
||||||
</SmartForm>
|
</SmartForm>
|
||||||
</LazyLoader>
|
</LazyLoader>
|
||||||
</OnlyAdmin>
|
|
||||||
|
|
||||||
@code
|
@code
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -10,7 +10,8 @@
|
|||||||
@inject StatisticsViewService StatisticsViewService
|
@inject StatisticsViewService StatisticsViewService
|
||||||
@inject SmartTranslateService SmartTranslateService
|
@inject SmartTranslateService SmartTranslateService
|
||||||
|
|
||||||
<OnlyAdmin>
|
@attribute [PermissionRequired(nameof(Permissions.AdminStatistics))]
|
||||||
|
|
||||||
<div class="row mt-4 mb-2">
|
<div class="row mt-4 mb-2">
|
||||||
<div class="col-12 col-lg-6 col-xl">
|
<div class="col-12 col-lg-6 col-xl">
|
||||||
<div class="card card-body">
|
<div class="card card-body">
|
||||||
@@ -81,7 +82,6 @@
|
|||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</LazyLoader>
|
</LazyLoader>
|
||||||
</OnlyAdmin>
|
|
||||||
|
|
||||||
@code
|
@code
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -10,7 +10,8 @@
|
|||||||
@inject SubscriptionRepository SubscriptionRepository
|
@inject SubscriptionRepository SubscriptionRepository
|
||||||
@inject SubscriptionService SubscriptionService
|
@inject SubscriptionService SubscriptionService
|
||||||
|
|
||||||
<OnlyAdmin>
|
@attribute [PermissionRequired(nameof(Permissions.AdminSubscriptionEdit))]
|
||||||
|
|
||||||
<div class="card card-body p-10">
|
<div class="card card-body p-10">
|
||||||
<LazyLoader Load="Load">
|
<LazyLoader Load="Load">
|
||||||
@if (Subscription == null)
|
@if (Subscription == null)
|
||||||
@@ -158,7 +159,6 @@
|
|||||||
}
|
}
|
||||||
</LazyLoader>
|
</LazyLoader>
|
||||||
</div>
|
</div>
|
||||||
</OnlyAdmin>
|
|
||||||
|
|
||||||
@code
|
@code
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -9,7 +9,8 @@
|
|||||||
@inject SubscriptionRepository SubscriptionRepository
|
@inject SubscriptionRepository SubscriptionRepository
|
||||||
@inject SubscriptionService SubscriptionService
|
@inject SubscriptionService SubscriptionService
|
||||||
|
|
||||||
<OnlyAdmin>
|
@attribute [PermissionRequired(nameof(Permissions.AdminSubscriptions))]
|
||||||
|
|
||||||
<div class="card">
|
<div class="card">
|
||||||
<LazyLoader @ref="LazyLoader" Load="Load">
|
<LazyLoader @ref="LazyLoader" Load="Load">
|
||||||
<div class="card-header border-0 pt-5">
|
<div class="card-header border-0 pt-5">
|
||||||
@@ -54,7 +55,6 @@
|
|||||||
</div>
|
</div>
|
||||||
</LazyLoader>
|
</LazyLoader>
|
||||||
</div>
|
</div>
|
||||||
</OnlyAdmin>
|
|
||||||
|
|
||||||
@code
|
@code
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -8,7 +8,8 @@
|
|||||||
@inject SubscriptionRepository SubscriptionRepository
|
@inject SubscriptionRepository SubscriptionRepository
|
||||||
@inject SubscriptionService SubscriptionService
|
@inject SubscriptionService SubscriptionService
|
||||||
|
|
||||||
<OnlyAdmin>
|
@attribute [PermissionRequired(nameof(Permissions.AdminNewSubscription))]
|
||||||
|
|
||||||
<div class="card card-body p-10">
|
<div class="card card-body p-10">
|
||||||
<SmartForm Model="Model" OnValidSubmit="OnSubmit">
|
<SmartForm Model="Model" OnValidSubmit="OnSubmit">
|
||||||
<label class="form-label">
|
<label class="form-label">
|
||||||
@@ -145,7 +146,6 @@
|
|||||||
</div>
|
</div>
|
||||||
</SmartForm>
|
</SmartForm>
|
||||||
</div>
|
</div>
|
||||||
</OnlyAdmin>
|
|
||||||
|
|
||||||
@code
|
@code
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -8,7 +8,8 @@
|
|||||||
|
|
||||||
@implements IDisposable
|
@implements IDisposable
|
||||||
|
|
||||||
<OnlyAdmin>
|
@attribute [PermissionRequired(nameof(Permissions.AdminSupport))]
|
||||||
|
|
||||||
<LazyLoader @ref="LazyLoader" Load="Load">
|
<LazyLoader @ref="LazyLoader" Load="Load">
|
||||||
<div class="card">
|
<div class="card">
|
||||||
<div class="card-body">
|
<div class="card-body">
|
||||||
@@ -70,7 +71,6 @@
|
|||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</LazyLoader>
|
</LazyLoader>
|
||||||
</OnlyAdmin>
|
|
||||||
|
|
||||||
@code
|
@code
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -14,7 +14,8 @@
|
|||||||
|
|
||||||
@implements IDisposable
|
@implements IDisposable
|
||||||
|
|
||||||
<OnlyAdmin>
|
@attribute [PermissionRequired(nameof(Permissions.AdminSupportView))]
|
||||||
|
|
||||||
<LazyLoader Load="Load">
|
<LazyLoader Load="Load">
|
||||||
@if (User == null)
|
@if (User == null)
|
||||||
{
|
{
|
||||||
@@ -220,7 +221,6 @@
|
|||||||
</div>
|
</div>
|
||||||
}
|
}
|
||||||
</LazyLoader>
|
</LazyLoader>
|
||||||
</OnlyAdmin>
|
|
||||||
|
|
||||||
@code
|
@code
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -1,106 +0,0 @@
|
|||||||
@page "/admin/system/auditlog"
|
|
||||||
|
|
||||||
@using Moonlight.Shared.Components.Navigations
|
|
||||||
@using Moonlight.App.Repositories.LogEntries
|
|
||||||
@using Moonlight.App.Services
|
|
||||||
@using Moonlight.App.Database.Entities.LogsEntries
|
|
||||||
@using BlazorTable
|
|
||||||
@using Moonlight.App.Helpers
|
|
||||||
@using Moonlight.App.Models.Misc
|
|
||||||
@using Moonlight.Shared.Components.AuditLogEntrys
|
|
||||||
|
|
||||||
@inject AuditLogEntryRepository AuditLogEntryRepository
|
|
||||||
|
|
||||||
<OnlyAdmin>
|
|
||||||
<AdminSystemNavigation Index="2"/>
|
|
||||||
|
|
||||||
<div class="card">
|
|
||||||
<div class="card-header card-header-stretch">
|
|
||||||
<div class="card-title d-flex align-items-center">
|
|
||||||
<span class="me-3 lh-0">
|
|
||||||
<i class="bx bx-md bx-calendar"></i>
|
|
||||||
</span>
|
|
||||||
<h3 class="fw-bold m-0 text-gray-800">@(Formatter.FormatDateOnly(DateTime))</h3>
|
|
||||||
</div>
|
|
||||||
<div class="card-toolbar m-0">
|
|
||||||
<ul class="nav nav-tabs nav-line-tabs nav-stretch fs-6 border-0 fw-bold">
|
|
||||||
<li class="nav-item">
|
|
||||||
<button @onclick="Left" class="nav-link justify-content-center text-active-gray-800">
|
|
||||||
<i class="bx bx-md bx-left-arrow"></i>
|
|
||||||
</button>
|
|
||||||
</li>
|
|
||||||
<li class="nav-item">
|
|
||||||
<button @onclick="Right" class="nav-link justify-content-center text-active-gray-800">
|
|
||||||
<i class="bx bx-md bx-right-arrow"></i>
|
|
||||||
</button>
|
|
||||||
</li>
|
|
||||||
</ul>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
<div class="card-body">
|
|
||||||
<LazyLoader @ref="LazyLoader" Load="Load">
|
|
||||||
@if (AuditLogEntries.Any())
|
|
||||||
{
|
|
||||||
<div class="timeline">
|
|
||||||
@foreach (var entry in AuditLogEntries)
|
|
||||||
{
|
|
||||||
switch (entry.Type)
|
|
||||||
{
|
|
||||||
case AuditLogType.Login:
|
|
||||||
<AuditLogEntryLogin Entry="entry"/>
|
|
||||||
break;
|
|
||||||
case AuditLogType.Register:
|
|
||||||
<AuditLogEntryRegister Entry="entry"/>
|
|
||||||
break;
|
|
||||||
case AuditLogType.ChangePassword:
|
|
||||||
<AuditLogEntryChangePassword Entry="entry"/>
|
|
||||||
break;
|
|
||||||
case AuditLogType.ChangePowerState:
|
|
||||||
<AuditLogEntryChangePowerState Entry="entry"/>
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
</div>
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
<div class="alert alert-primary">
|
|
||||||
<TL>No records found for this day</TL>
|
|
||||||
</div>
|
|
||||||
}
|
|
||||||
</LazyLoader>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
</OnlyAdmin>
|
|
||||||
|
|
||||||
@code
|
|
||||||
{
|
|
||||||
private AuditLogEntry[] AuditLogEntries;
|
|
||||||
private LazyLoader LazyLoader;
|
|
||||||
private DateTime DateTime = DateTime.Today;
|
|
||||||
|
|
||||||
private Task Load(LazyLoader arg)
|
|
||||||
{
|
|
||||||
AuditLogEntries = AuditLogEntryRepository
|
|
||||||
.Get()
|
|
||||||
.Where(x => x.CreatedAt.Date == DateTime.Date)
|
|
||||||
.OrderByDescending(x => x.Id)
|
|
||||||
.ToArray();
|
|
||||||
|
|
||||||
return Task.CompletedTask;
|
|
||||||
}
|
|
||||||
|
|
||||||
private async Task Left()
|
|
||||||
{
|
|
||||||
DateTime = DateTime.AddDays(1);
|
|
||||||
|
|
||||||
await LazyLoader.Reload();
|
|
||||||
}
|
|
||||||
|
|
||||||
private async Task Right()
|
|
||||||
{
|
|
||||||
DateTime = DateTime.AddDays(-1);
|
|
||||||
|
|
||||||
await LazyLoader.Reload();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -9,7 +9,8 @@
|
|||||||
@inject ToastService ToastService
|
@inject ToastService ToastService
|
||||||
@inject SmartTranslateService SmartTranslateService
|
@inject SmartTranslateService SmartTranslateService
|
||||||
|
|
||||||
<OnlyAdmin>
|
@attribute [PermissionRequired(nameof(Permissions.AdminSysConfiguration))]
|
||||||
|
|
||||||
<AdminSystemNavigation Index="8"/>
|
<AdminSystemNavigation Index="8"/>
|
||||||
|
|
||||||
<LazyLoader Load="Load">
|
<LazyLoader Load="Load">
|
||||||
@@ -28,7 +29,6 @@
|
|||||||
</SmartForm>
|
</SmartForm>
|
||||||
</div>
|
</div>
|
||||||
</LazyLoader>
|
</LazyLoader>
|
||||||
</OnlyAdmin>
|
|
||||||
|
|
||||||
@code
|
@code
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -4,7 +4,8 @@
|
|||||||
|
|
||||||
@inject DiscordBotService DiscordBotService
|
@inject DiscordBotService DiscordBotService
|
||||||
|
|
||||||
<OnlyAdmin>
|
@attribute [PermissionRequired(nameof(Permissions.AdminSysDiscordBot))]
|
||||||
|
|
||||||
<AdminSystemNavigation Index="6"/>
|
<AdminSystemNavigation Index="6"/>
|
||||||
|
|
||||||
<div class="mt-3 card card-body">
|
<div class="mt-3 card card-body">
|
||||||
@@ -20,7 +21,6 @@
|
|||||||
OnClick="VoidCommands">
|
OnClick="VoidCommands">
|
||||||
</WButton>
|
</WButton>
|
||||||
</div>
|
</div>
|
||||||
</OnlyAdmin>
|
|
||||||
|
|
||||||
@code
|
@code
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -7,7 +7,8 @@
|
|||||||
@inject HostSystemHelper HostSystemHelper
|
@inject HostSystemHelper HostSystemHelper
|
||||||
@inject MoonlightService MoonlightService
|
@inject MoonlightService MoonlightService
|
||||||
|
|
||||||
<OnlyAdmin>
|
@attribute [PermissionRequired(nameof(Permissions.AdminSystem))]
|
||||||
|
|
||||||
<AdminSystemNavigation Index="0"/>
|
<AdminSystemNavigation Index="0"/>
|
||||||
|
|
||||||
<LazyLoader Load="Load">
|
<LazyLoader Load="Load">
|
||||||
@@ -92,7 +93,6 @@
|
|||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</LazyLoader>
|
</LazyLoader>
|
||||||
</OnlyAdmin>
|
|
||||||
|
|
||||||
@code
|
@code
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -5,18 +5,20 @@
|
|||||||
@using Moonlight.App.Helpers.Files
|
@using Moonlight.App.Helpers.Files
|
||||||
@using Moonlight.App.Helpers
|
@using Moonlight.App.Helpers
|
||||||
@using BlazorTable
|
@using BlazorTable
|
||||||
@using Moonlight.App.Database.Entities
|
|
||||||
@using Moonlight.App.Models.Misc
|
@using Moonlight.App.Models.Misc
|
||||||
@using Moonlight.App.Services
|
@using Moonlight.App.Services
|
||||||
@using Moonlight.App.Services.Interop
|
@using Moonlight.App.Services.Interop
|
||||||
@using Moonlight.App.Services.Mail
|
@using Moonlight.App.Services.Mail
|
||||||
|
@using Moonlight.App.Services.Sessions
|
||||||
|
|
||||||
@inject SmartTranslateService SmartTranslateService
|
@inject SmartTranslateService SmartTranslateService
|
||||||
@inject ToastService ToastService
|
@inject ToastService ToastService
|
||||||
@inject AlertService AlertService
|
@inject AlertService AlertService
|
||||||
@inject MailService MailService
|
@inject MailService MailService
|
||||||
|
@inject IdentityService IdentityService
|
||||||
|
|
||||||
|
@attribute [PermissionRequired(nameof(Permissions.AdminSysMail))]
|
||||||
|
|
||||||
<OnlyAdmin>
|
|
||||||
<AdminSystemNavigation Index="9"/>
|
<AdminSystemNavigation Index="9"/>
|
||||||
|
|
||||||
<div class="card mb-3">
|
<div class="card mb-3">
|
||||||
@@ -88,12 +90,10 @@
|
|||||||
OnSubmit="OnSubmitTemplateEdit"/>
|
OnSubmit="OnSubmitTemplateEdit"/>
|
||||||
}
|
}
|
||||||
</LazyLoader>
|
</LazyLoader>
|
||||||
</OnlyAdmin>
|
|
||||||
|
|
||||||
@code
|
@code
|
||||||
{
|
{
|
||||||
[CascadingParameter]
|
|
||||||
public User User { get; set; }
|
|
||||||
|
|
||||||
private MailTemplate[] MailTemplateFiles;
|
private MailTemplate[] MailTemplateFiles;
|
||||||
private FileAccess FileAccess;
|
private FileAccess FileAccess;
|
||||||
@@ -174,7 +174,7 @@
|
|||||||
|
|
||||||
private async Task SendTestMail()
|
private async Task SendTestMail()
|
||||||
{
|
{
|
||||||
await MailService.SendMailRaw(User, "<html><body>If you see this mail, your moonlight mail configuration is ready to use</body></html>");
|
await MailService.SendMailRaw(IdentityService.User, "<html><body>If you see this mail, your moonlight mail configuration is ready to use</body></html>");
|
||||||
await AlertService.Info(SmartTranslateService.Translate("A test mail has been sent to the email address of your account"));
|
await AlertService.Info(SmartTranslateService.Translate("A test mail has been sent to the email address of your account"));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -1,134 +0,0 @@
|
|||||||
@page "/admin/system/malware"
|
|
||||||
|
|
||||||
@using Moonlight.Shared.Components.Navigations
|
|
||||||
@using Moonlight.App.Services.Background
|
|
||||||
@using Moonlight.App.Services
|
|
||||||
@using BlazorTable
|
|
||||||
@using Moonlight.App.Database.Entities
|
|
||||||
@using Moonlight.App.Events
|
|
||||||
@using Moonlight.App.Models.Misc
|
|
||||||
|
|
||||||
@inject MalwareScanService MalwareScanService
|
|
||||||
@inject SmartTranslateService SmartTranslateService
|
|
||||||
@inject EventSystem Event
|
|
||||||
|
|
||||||
@implements IDisposable
|
|
||||||
|
|
||||||
<OnlyAdmin>
|
|
||||||
<AdminSystemNavigation Index="2"/>
|
|
||||||
|
|
||||||
<div class="row">
|
|
||||||
<div class="col-12 col-lg-6">
|
|
||||||
<div class="card">
|
|
||||||
<div class="card-body">
|
|
||||||
@if (MalwareScanService.IsRunning)
|
|
||||||
{
|
|
||||||
<span class="fs-3 spinner-border align-middle me-3"></span>
|
|
||||||
}
|
|
||||||
|
|
||||||
<span class="fs-3">@(MalwareScanService.Status)</span>
|
|
||||||
</div>
|
|
||||||
<div class="card-footer">
|
|
||||||
@if (MalwareScanService.IsRunning)
|
|
||||||
{
|
|
||||||
<button class="btn btn-success disabled">
|
|
||||||
<TL>Scan in progress</TL>
|
|
||||||
</button>
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
<WButton Text="@(SmartTranslateService.Translate("Start scan"))"
|
|
||||||
CssClasses="btn-success"
|
|
||||||
OnClick="MalwareScanService.Start">
|
|
||||||
</WButton>
|
|
||||||
}
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
<div class="col-12 col-lg-6">
|
|
||||||
<div class="card">
|
|
||||||
<div class="card-header">
|
|
||||||
<span class="card-title">
|
|
||||||
<TL>Results</TL>
|
|
||||||
</span>
|
|
||||||
</div>
|
|
||||||
<div class="card-body">
|
|
||||||
<LazyLoader @ref="LazyLoaderResults" Load="LoadResults">
|
|
||||||
<div class="table-responsive">
|
|
||||||
<Table TableItem="Server" Items="ScanResults.Keys" PageSize="25" TableClass="table table-row-bordered table-row-gray-100 align-middle gs-0 gy-3" TableHeadClass="fw-bold text-muted">
|
|
||||||
<Column TableItem="Server" Title="@(SmartTranslateService.Translate("Server"))" Field="@(x => x.Id)" Sortable="false" Filterable="false">
|
|
||||||
<Template>
|
|
||||||
<a href="/server/@(context.Uuid)">@(context.Name)</a>
|
|
||||||
</Template>
|
|
||||||
</Column>
|
|
||||||
<Column TableItem="Server" Title="@(SmartTranslateService.Translate("Results"))" Field="@(x => x.Id)" Sortable="false" Filterable="false">
|
|
||||||
<Template>
|
|
||||||
<div class="row">
|
|
||||||
@foreach (var result in ScanResults[context])
|
|
||||||
{
|
|
||||||
<div class="col-12 col-md-6 p-3">
|
|
||||||
<div class="accordion" id="scanResult@(result.GetHashCode())">
|
|
||||||
<div class="accordion-item">
|
|
||||||
<h2 class="accordion-header" id="scanResult-header@(result.GetHashCode())">
|
|
||||||
<button class="accordion-button fs-4 fw-semibold collapsed" type="button" data-bs-toggle="collapse" data-bs-target="#scanResult-body@(result.GetHashCode())" aria-expanded="false" aria-controls="scanResult-body@(result.GetHashCode())">
|
|
||||||
<span>@(result.Title)</span>
|
|
||||||
</button>
|
|
||||||
</h2>
|
|
||||||
<div id="scanResult-body@(result.GetHashCode())" class="accordion-collapse collapse" aria-labelledby="scanResult-header@(result.GetHashCode())" data-bs-parent="#scanResult">
|
|
||||||
<div class="accordion-body">
|
|
||||||
<p>
|
|
||||||
@(result.Description)
|
|
||||||
</p>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
}
|
|
||||||
</div>
|
|
||||||
</Template>
|
|
||||||
</Column>
|
|
||||||
<Pager ShowPageNumber="true" ShowTotalCount="true"/>
|
|
||||||
</Table>
|
|
||||||
</div>
|
|
||||||
</LazyLoader>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
</OnlyAdmin>
|
|
||||||
|
|
||||||
@code
|
|
||||||
{
|
|
||||||
private readonly Dictionary<Server, MalwareScanResult[]> ScanResults = new();
|
|
||||||
|
|
||||||
private LazyLoader LazyLoaderResults;
|
|
||||||
|
|
||||||
protected override async Task OnInitializedAsync()
|
|
||||||
{
|
|
||||||
await Event.On<Object>("malwareScan.status", this, async o => { await InvokeAsync(StateHasChanged); });
|
|
||||||
|
|
||||||
await Event.On<Object>("malwareScan.result", this, async o => { await LazyLoaderResults.Reload(); });
|
|
||||||
}
|
|
||||||
|
|
||||||
private Task LoadResults(LazyLoader arg)
|
|
||||||
{
|
|
||||||
ScanResults.Clear();
|
|
||||||
|
|
||||||
lock (MalwareScanService.ScanResults)
|
|
||||||
{
|
|
||||||
foreach (var result in MalwareScanService.ScanResults)
|
|
||||||
{
|
|
||||||
ScanResults.Add(result.Key, result.Value);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
return Task.CompletedTask;
|
|
||||||
}
|
|
||||||
|
|
||||||
public async void Dispose()
|
|
||||||
{
|
|
||||||
await Event.Off("malwareScan.status", this);
|
|
||||||
await Event.Off("malwareScan.result", this);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -10,7 +10,8 @@
|
|||||||
@inject NavigationManager NavigationManager
|
@inject NavigationManager NavigationManager
|
||||||
@inject NewsEntryRepository NewsEntryRepository
|
@inject NewsEntryRepository NewsEntryRepository
|
||||||
|
|
||||||
<OnlyAdmin>
|
@attribute [PermissionRequired(nameof(Permissions.AdminSysNewsEdit))]
|
||||||
|
|
||||||
<LazyLoader Load="Load">
|
<LazyLoader Load="Load">
|
||||||
@if (Entry == null)
|
@if (Entry == null)
|
||||||
{
|
{
|
||||||
@@ -49,7 +50,6 @@
|
|||||||
</div>
|
</div>
|
||||||
}
|
}
|
||||||
</LazyLoader>
|
</LazyLoader>
|
||||||
</OnlyAdmin>
|
|
||||||
|
|
||||||
@code
|
@code
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -12,7 +12,8 @@
|
|||||||
@inject SmartTranslateService SmartTranslateService
|
@inject SmartTranslateService SmartTranslateService
|
||||||
@inject AlertService AlertService
|
@inject AlertService AlertService
|
||||||
|
|
||||||
<OnlyAdmin>
|
@attribute [PermissionRequired(nameof(Permissions.AdminSysNews))]
|
||||||
|
|
||||||
<AdminSystemNavigation Index="7"/>
|
<AdminSystemNavigation Index="7"/>
|
||||||
|
|
||||||
<div class="card card-body mb-6">
|
<div class="card card-body mb-6">
|
||||||
@@ -55,7 +56,6 @@
|
|||||||
</div>
|
</div>
|
||||||
}
|
}
|
||||||
</LazyLoader>
|
</LazyLoader>
|
||||||
</OnlyAdmin>
|
|
||||||
|
|
||||||
@code
|
@code
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -9,7 +9,8 @@
|
|||||||
@inject NavigationManager NavigationManager
|
@inject NavigationManager NavigationManager
|
||||||
@inject NewsEntryRepository NewsEntryRepository
|
@inject NewsEntryRepository NewsEntryRepository
|
||||||
|
|
||||||
<OnlyAdmin>
|
@attribute [PermissionRequired(nameof(Permissions.AdminSysNewsNew))]
|
||||||
|
|
||||||
<div class="card mb-6">
|
<div class="card mb-6">
|
||||||
<div class="card-header">
|
<div class="card-header">
|
||||||
<h3 class="card-title w-75">
|
<h3 class="card-title w-75">
|
||||||
@@ -30,7 +31,6 @@
|
|||||||
</WButton>
|
</WButton>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</OnlyAdmin>
|
|
||||||
|
|
||||||
@code
|
@code
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -11,7 +11,8 @@
|
|||||||
@inject ConfigService ConfigService
|
@inject ConfigService ConfigService
|
||||||
@inject AlertService AlertService
|
@inject AlertService AlertService
|
||||||
|
|
||||||
<OnlyAdmin>
|
@attribute [PermissionRequired(nameof(Permissions.AdminSysResources))]
|
||||||
|
|
||||||
<AdminSystemNavigation Index="5"/>
|
<AdminSystemNavigation Index="5"/>
|
||||||
|
|
||||||
<div class="card card-body mb-6">
|
<div class="card card-body mb-6">
|
||||||
@@ -28,7 +29,6 @@
|
|||||||
<FileManager Access="@(new HostFileAccess(PathBuilder.Dir("storage")))">
|
<FileManager Access="@(new HostFileAccess(PathBuilder.Dir("storage")))">
|
||||||
</FileManager>
|
</FileManager>
|
||||||
</div>
|
</div>
|
||||||
</OnlyAdmin>
|
|
||||||
|
|
||||||
@code
|
@code
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -3,7 +3,8 @@
|
|||||||
@using Moonlight.Shared.Components.Navigations
|
@using Moonlight.Shared.Components.Navigations
|
||||||
@using global::Sentry
|
@using global::Sentry
|
||||||
|
|
||||||
<OnlyAdmin>
|
@attribute [PermissionRequired(nameof(Permissions.AdminSysSentry))]
|
||||||
|
|
||||||
<AdminSystemNavigation Index="1"/>
|
<AdminSystemNavigation Index="1"/>
|
||||||
|
|
||||||
<div class="row">
|
<div class="row">
|
||||||
@@ -29,7 +30,6 @@
|
|||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</OnlyAdmin>
|
|
||||||
|
|
||||||
@code
|
@code
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -1,18 +1,22 @@
|
|||||||
@page "/admin/users/edit/{Id:int}"
|
@page "/admin/users/edit/{Id:int}"
|
||||||
@using Moonlight.App.Repositories
|
@using Moonlight.App.Repositories
|
||||||
@using Moonlight.App.Database.Entities
|
@using Moonlight.App.Database.Entities
|
||||||
|
@using Moonlight.App.Models.Forms
|
||||||
@using Moonlight.App.Models.Misc
|
@using Moonlight.App.Models.Misc
|
||||||
@using Moonlight.App.Services
|
@using Moonlight.App.Services
|
||||||
@using Moonlight.App.Services.Interop
|
@using Moonlight.App.Services.Interop
|
||||||
@using Moonlight.App.Services.Sessions
|
@using Moonlight.App.Services.Sessions
|
||||||
|
@using Mappy.Net
|
||||||
|
|
||||||
@inject UserRepository UserRepository
|
@inject Repository<User> UserRepository
|
||||||
|
@inject Repository<PermissionGroup> PermissionGroupRepository
|
||||||
@inject UserService UserService
|
@inject UserService UserService
|
||||||
@inject SessionServerService SessionServerService
|
@inject SessionServerService SessionServerService
|
||||||
@inject ToastService ToastService
|
@inject ToastService ToastService
|
||||||
@inject SmartTranslateService SmartTranslateService
|
@inject SmartTranslateService SmartTranslateService
|
||||||
|
|
||||||
<OnlyAdmin>
|
@attribute [PermissionRequired(nameof(Permissions.AdminUserEdit))]
|
||||||
|
|
||||||
<LazyLoader Load="Load">
|
<LazyLoader Load="Load">
|
||||||
@if (User == null)
|
@if (User == null)
|
||||||
{
|
{
|
||||||
@@ -32,6 +36,7 @@
|
|||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
<SmartForm Model="Model" OnValidSubmit="Update">
|
||||||
<div class="mt-5 row">
|
<div class="mt-5 row">
|
||||||
<div class="col-xl-6 mb-5 mb-xl-10">
|
<div class="col-xl-6 mb-5 mb-xl-10">
|
||||||
<div class="card card-body p-10">
|
<div class="card card-body p-10">
|
||||||
@@ -39,19 +44,19 @@
|
|||||||
<label class="form-label">
|
<label class="form-label">
|
||||||
<TL>First name</TL>
|
<TL>First name</TL>
|
||||||
</label>
|
</label>
|
||||||
<input @bind="User.FirstName" type="text" class="form-control">
|
<InputText @bind-Value="Model.FirstName" class="form-control"/>
|
||||||
</div>
|
</div>
|
||||||
<div class="mb-10">
|
<div class="mb-10">
|
||||||
<label class="form-label">
|
<label class="form-label">
|
||||||
<TL>Last name</TL>
|
<TL>Last name</TL>
|
||||||
</label>
|
</label>
|
||||||
<input @bind="User.LastName" type="text" class="form-control">
|
<InputText @bind-Value="Model.LastName" class="form-control"/>
|
||||||
</div>
|
</div>
|
||||||
<div class="mb-10">
|
<div class="mb-10">
|
||||||
<label class="form-label">
|
<label class="form-label">
|
||||||
<TL>Email</TL>
|
<TL>Email</TL>
|
||||||
</label>
|
</label>
|
||||||
<input @bind="User.Email" type="email" class="form-control">
|
<InputText @bind-Value="Model.Email" type="email" class="form-control"/>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<div class="mt-5 card card-body p-10">
|
<div class="mt-5 card card-body p-10">
|
||||||
@@ -86,16 +91,28 @@
|
|||||||
</WButton>
|
</WButton>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
<div class="mt-5 card card-body p-10">
|
||||||
|
<div class="input-group">
|
||||||
|
<SmartDropdown T="PermissionGroup"
|
||||||
|
@bind-Value="Model.PermissionGroup"
|
||||||
|
Items="PermissionGroups"
|
||||||
|
DisplayFunc="@(x => x.Name)"
|
||||||
|
SearchProp="@(x => x.Name)">
|
||||||
|
</SmartDropdown>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
<div class="mt-5 card card-body p-10">
|
<div class="mt-5 card card-body p-10">
|
||||||
<div class="d-flex justify-content-end">
|
<div class="d-flex justify-content-end">
|
||||||
<a href="/admin/users" class="btn btn-danger me-3">
|
<a href="/admin/users" class="btn btn-danger me-3">
|
||||||
<TL>Cancel</TL>
|
<TL>Cancel</TL>
|
||||||
</a>
|
</a>
|
||||||
<WButton Text="@(SmartTranslateService.Translate("Update"))"
|
<WButton Text="@(SmartTranslateService.Translate("Edit permissions"))"
|
||||||
WorkingText="@(SmartTranslateService.Translate("Updating"))"
|
CssClasses="btn-primary me-3"
|
||||||
CssClasses="btn-success"
|
OnClick="EditPermissions">
|
||||||
OnClick="Update">
|
|
||||||
</WButton>
|
</WButton>
|
||||||
|
<button type="submit" class="btn btn-success">
|
||||||
|
<TL>Update</TL>
|
||||||
|
</button>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
@@ -105,34 +122,34 @@
|
|||||||
<label class="form-label">
|
<label class="form-label">
|
||||||
<TL>Address</TL>
|
<TL>Address</TL>
|
||||||
</label>
|
</label>
|
||||||
<input @bind="User.Address" type="text" class="form-control">
|
<InputText @bind-Value="Model.Address" class="form-control"/>
|
||||||
</div>
|
</div>
|
||||||
<div class="mb-10">
|
<div class="mb-10">
|
||||||
<label class="form-label">
|
<label class="form-label">
|
||||||
<TL>City</TL>
|
<TL>City</TL>
|
||||||
</label>
|
</label>
|
||||||
<input @bind="User.City" type="text" class="form-control">
|
<InputText @bind-Value="Model.City" class="form-control"/>
|
||||||
</div>
|
</div>
|
||||||
<div class="mb-10">
|
<div class="mb-10">
|
||||||
<label class="form-label">
|
<label class="form-label">
|
||||||
<TL>State</TL>
|
<TL>State</TL>
|
||||||
</label>
|
</label>
|
||||||
<input @bind="User.State" type="text" class="form-control">
|
<InputText @bind-Value="Model.State" class="form-control"/>
|
||||||
</div>
|
</div>
|
||||||
<div class="mb-10">
|
<div class="mb-10">
|
||||||
<label class="form-label">
|
<label class="form-label">
|
||||||
<TL>Country</TL>
|
<TL>Country</TL>
|
||||||
</label>
|
</label>
|
||||||
<input @bind="User.Country" type="text" class="form-control">
|
<InputText @bind-Value="Model.Country" class="form-control"/>
|
||||||
</div>
|
</div>
|
||||||
<div class="mb-10">
|
<div class="mb-10">
|
||||||
<input @bind="User.TotpEnabled" type="checkbox" class="form-check-input">
|
<input @bind="Model.TotpEnabled" type="checkbox" class="form-check-input">
|
||||||
<label class="form-label">
|
<label class="form-label">
|
||||||
<TL>Totp</TL>
|
<TL>Totp</TL>
|
||||||
</label>
|
</label>
|
||||||
</div>
|
</div>
|
||||||
<div class="mb-10">
|
<div class="mb-10">
|
||||||
<input @bind="User.Admin" type="checkbox" class="form-check-input">
|
<input @bind="Model.Admin" type="checkbox" class="form-check-input">
|
||||||
<label class="form-label">
|
<label class="form-label">
|
||||||
<TL>Admin</TL>
|
<TL>Admin</TL>
|
||||||
</label>
|
</label>
|
||||||
@@ -143,14 +160,17 @@
|
|||||||
<label class="form-label">
|
<label class="form-label">
|
||||||
<TL>Discord id</TL>
|
<TL>Discord id</TL>
|
||||||
</label>
|
</label>
|
||||||
<input @bind="User.DiscordId" type="number" class="form-control">
|
|
||||||
|
<input @bind="Model.DiscordId" type="number" class="form-control">
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
</SmartForm>
|
||||||
}
|
}
|
||||||
|
|
||||||
|
<PermissionEditor @ref="PermissionEditor" OnSave="SavePermissions"/>
|
||||||
</LazyLoader>
|
</LazyLoader>
|
||||||
</OnlyAdmin>
|
|
||||||
|
|
||||||
@code
|
@code
|
||||||
{
|
{
|
||||||
@@ -158,13 +178,25 @@
|
|||||||
public int Id { get; set; }
|
public int Id { get; set; }
|
||||||
|
|
||||||
private User? User;
|
private User? User;
|
||||||
|
private UserEditDataModel Model { get; set; } = new();
|
||||||
private string NewPassword = "";
|
private string NewPassword = "";
|
||||||
|
|
||||||
|
private PermissionGroup[] PermissionGroups;
|
||||||
|
|
||||||
|
private PermissionEditor PermissionEditor;
|
||||||
|
|
||||||
private Task Load(LazyLoader arg)
|
private Task Load(LazyLoader arg)
|
||||||
{
|
{
|
||||||
User = UserRepository.Get().FirstOrDefault(x => x.Id == Id);
|
User = UserRepository.Get().FirstOrDefault(x => x.Id == Id);
|
||||||
|
|
||||||
|
if (User != null)
|
||||||
|
{
|
||||||
|
Model = Mapper.Map<UserEditDataModel>(User);
|
||||||
|
PermissionGroups = PermissionGroupRepository
|
||||||
|
.Get()
|
||||||
|
.ToArray();
|
||||||
|
}
|
||||||
|
|
||||||
return Task.CompletedTask;
|
return Task.CompletedTask;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -181,6 +213,7 @@
|
|||||||
|
|
||||||
private async Task Update()
|
private async Task Update()
|
||||||
{
|
{
|
||||||
|
User = Mapper.Map(User, Model);
|
||||||
UserRepository.Update(User!);
|
UserRepository.Update(User!);
|
||||||
|
|
||||||
await ToastService.Success(SmartTranslateService.Translate("Successfully updated user"));
|
await ToastService.Success(SmartTranslateService.Translate("Successfully updated user"));
|
||||||
@@ -195,4 +228,20 @@
|
|||||||
|
|
||||||
await ToastService.Success(SmartTranslateService.Translate("Successfully updated password"));
|
await ToastService.Success(SmartTranslateService.Translate("Successfully updated password"));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private async Task EditPermissions()
|
||||||
|
{
|
||||||
|
PermissionEditor.InitialData = User!.Permissions;
|
||||||
|
await PermissionEditor.Launch();
|
||||||
|
}
|
||||||
|
|
||||||
|
private async Task SavePermissions(byte[] data)
|
||||||
|
{
|
||||||
|
User!.Permissions = data;
|
||||||
|
UserRepository.Update(User);
|
||||||
|
|
||||||
|
await SessionServerService.ReloadUserSessions(User);
|
||||||
|
|
||||||
|
await ToastService.Success(SmartTranslateService.Translate("Successfully updated user"));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
@@ -9,7 +9,8 @@
|
|||||||
@inject UserRepository UserRepository
|
@inject UserRepository UserRepository
|
||||||
@inject SmartTranslateService SmartTranslateService
|
@inject SmartTranslateService SmartTranslateService
|
||||||
|
|
||||||
<OnlyAdmin>
|
@attribute [PermissionRequired(nameof(Permissions.AdminUsers))]
|
||||||
|
|
||||||
<AdminSessionNavigation Index="0"/>
|
<AdminSessionNavigation Index="0"/>
|
||||||
|
|
||||||
<div class="card">
|
<div class="card">
|
||||||
@@ -52,7 +53,6 @@
|
|||||||
</div>
|
</div>
|
||||||
</LazyLoader>
|
</LazyLoader>
|
||||||
</div>
|
</div>
|
||||||
</OnlyAdmin>
|
|
||||||
|
|
||||||
@code
|
@code
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -8,7 +8,8 @@
|
|||||||
@inject ToastService ToastService
|
@inject ToastService ToastService
|
||||||
@inject UserService UserService
|
@inject UserService UserService
|
||||||
|
|
||||||
<OnlyAdmin>
|
@attribute [PermissionRequired(nameof(Permissions.AdminNewUser))]
|
||||||
|
|
||||||
<div class="row mb-5">
|
<div class="row mb-5">
|
||||||
<div class="card card-body p-10">
|
<div class="card card-body p-10">
|
||||||
<label class="form-label">
|
<label class="form-label">
|
||||||
@@ -51,7 +52,6 @@
|
|||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</OnlyAdmin>
|
|
||||||
|
|
||||||
@code
|
@code
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -13,7 +13,8 @@
|
|||||||
@inject AlertService AlertService
|
@inject AlertService AlertService
|
||||||
@inject ToastService ToastService
|
@inject ToastService ToastService
|
||||||
|
|
||||||
<OnlyAdmin>
|
@attribute [PermissionRequired(nameof(Permissions.AdminUserSessions))]
|
||||||
|
|
||||||
<AdminSessionNavigation Index="1"/>
|
<AdminSessionNavigation Index="1"/>
|
||||||
|
|
||||||
<div class="card">
|
<div class="card">
|
||||||
@@ -97,7 +98,6 @@
|
|||||||
</div>
|
</div>
|
||||||
</LazyLoader>
|
</LazyLoader>
|
||||||
</div>
|
</div>
|
||||||
</OnlyAdmin>
|
|
||||||
|
|
||||||
@code
|
@code
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -1,16 +1,18 @@
|
|||||||
@page "/admin/users/view/{Id:int}"
|
@page "/admin/users/view/{Id:int}"
|
||||||
@using Moonlight.App.Database.Entities
|
@using Moonlight.App.Database.Entities
|
||||||
@using Moonlight.App.Helpers
|
|
||||||
@using Moonlight.App.Repositories
|
@using Moonlight.App.Repositories
|
||||||
@using Moonlight.App.Repositories.Servers
|
|
||||||
@using Microsoft.EntityFrameworkCore
|
@using Microsoft.EntityFrameworkCore
|
||||||
@using Moonlight.App.Repositories.Domains
|
@using Moonlight.App.Helpers
|
||||||
|
@using Moonlight.App.Services.Files
|
||||||
|
|
||||||
@inject UserRepository UserRepository
|
@inject Repository<User> UserRepository
|
||||||
@inject ServerRepository ServerRepository
|
@inject Repository<Server> ServerRepository
|
||||||
@inject DomainRepository DomainRepository
|
@inject Repository<Domain> DomainRepository
|
||||||
|
@inject Repository<WebSpace> WebSpaceRepository
|
||||||
|
@inject ResourceService ResourceService
|
||||||
|
|
||||||
|
@attribute [PermissionRequired(nameof(Permissions.AdminUserView))]
|
||||||
|
|
||||||
<OnlyAdmin>
|
|
||||||
<LazyLoader Load="Load">
|
<LazyLoader Load="Load">
|
||||||
@if (User == null)
|
@if (User == null)
|
||||||
{
|
{
|
||||||
@@ -20,33 +22,103 @@
|
|||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
<div class="row">
|
<div class="d-flex flex-column flex-lg-row">
|
||||||
<div class="col-md-4">
|
<div class="flex-column flex-lg-row-auto w-lg-250px w-xl-350px mb-10">
|
||||||
<div class="card card-body mb-5">
|
<div class="card mb-5 mb-xl-8">
|
||||||
<div class="d-flex flex-column align-items-center text-center">
|
<div class="card-body">
|
||||||
<img src="/api/moonlight/avatar/@(User.Id)" class="rounded-circle" alt="Profile picture" width="150">
|
<div class="d-flex flex-center flex-column py-5">
|
||||||
|
<div class="symbol symbol-100px symbol-circle mb-7">
|
||||||
|
<img src="@(ResourceService.Avatar(User))" alt="Avatar">
|
||||||
|
</div>
|
||||||
|
<span class="fs-3 text-gray-800 fw-bold mb-3">
|
||||||
|
@(User.FirstName) @(User.LastName)
|
||||||
|
</span>
|
||||||
|
@if (User.Admin)
|
||||||
|
{
|
||||||
|
<div class="mb-5">
|
||||||
|
<div class="badge badge-lg badge-light-primary d-inline">
|
||||||
|
<TL>Admin</TL>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<div class="card card-body mb-5">
|
}
|
||||||
<div class="btn-group">
|
</div>
|
||||||
<a class="btn btn-primary" href="/admin/users/edit/@(User.Id)">
|
<div>
|
||||||
|
<div class="pb-5 fs-6">
|
||||||
|
<div class="fw-bold mt-5">
|
||||||
|
<TL>Account ID</TL>
|
||||||
|
</div>
|
||||||
|
<div class="text-gray-600">@(User.Id)</div>
|
||||||
|
|
||||||
|
<div class="fw-bold mt-5">Email</div>
|
||||||
|
<div class="text-gray-600">
|
||||||
|
@(User.Email)
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div class="fw-bold mt-5">
|
||||||
|
<TL>Address</TL>
|
||||||
|
</div>
|
||||||
|
<div class="text-gray-600">@(User.Address), <br>@(User.City)<br>@(User.State)<br>@(User.Country)</div>
|
||||||
|
|
||||||
|
<div class="fw-bold mt-5">
|
||||||
|
<TL>Status</TL>
|
||||||
|
</div>
|
||||||
|
<div class="text-gray-600">
|
||||||
|
@(User.Status)
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div class="fw-bold mt-5">
|
||||||
|
<TL>TOTP</TL>
|
||||||
|
</div>
|
||||||
|
<div class="text-gray-600">
|
||||||
|
@(User.TotpEnabled)
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div class="fw-bold mt-5">
|
||||||
|
<TL>Discord ID</TL>
|
||||||
|
</div>
|
||||||
|
<div class="text-gray-600">
|
||||||
|
@(User.DiscordId)
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div class="fw-bold mt-5">
|
||||||
|
<TL>Last Login IP</TL>
|
||||||
|
</div>
|
||||||
|
<div class="text-gray-600">
|
||||||
|
@(User.LastIp) <TL>at</TL> @(Formatter.FormatDate(User.LastVisitedAt))
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div class="fw-bold mt-5">
|
||||||
|
<TL>Register IP</TL>
|
||||||
|
</div>
|
||||||
|
<div class="text-gray-600">
|
||||||
|
@(User.RegisterIp) <TL>at</TL> @(Formatter.FormatDate(User.CreatedAt))
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
<div class="flex-lg-row-fluid ms-lg-15">
|
||||||
|
<div class="card mb-3">
|
||||||
|
<div class="card-header border-0">
|
||||||
|
<span class="card-title"></span>
|
||||||
|
<div class="card-toolbar">
|
||||||
|
<a href="/admin/users/edit/@(User.Id)" class="btn btn-primary">
|
||||||
<TL>Edit</TL>
|
<TL>Edit</TL>
|
||||||
</a>
|
</a>
|
||||||
<a class="btn btn-secondary" href="/admin/users">
|
|
||||||
<TL>Back to list</TL>
|
|
||||||
</a>
|
|
||||||
<a class="btn btn-primary" href="/admin/support/view/@(User.Id)">
|
|
||||||
<TL>Open support</TL>
|
|
||||||
</a>
|
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<div class="card card-xl-stretch mb-5">
|
</div>
|
||||||
<div class="card-header border-0">
|
|
||||||
<h3 class="card-title fw-bold text-dark">
|
<div class="accordion mb-3" id="serversList">
|
||||||
|
<div class="accordion-item">
|
||||||
|
<h2 class="accordion-header" id="serversList-header">
|
||||||
|
<button class="accordion-button fs-4 fw-semibold collapsed" type="button" data-bs-toggle="collapse" data-bs-target="#serversList-body" aria-expanded="false" aria-controls="serversList-body">
|
||||||
<TL>Servers</TL>
|
<TL>Servers</TL>
|
||||||
</h3>
|
</button>
|
||||||
</div>
|
</h2>
|
||||||
<div class="card-body pt-2">
|
<div id="serversList-body" class="accordion-collapse collapse" aria-labelledby="serversList-header" data-bs-parent="#serversList">
|
||||||
|
<div class="accordion-body">
|
||||||
@foreach (var server in Servers)
|
@foreach (var server in Servers)
|
||||||
{
|
{
|
||||||
<div class="d-flex align-items-center">
|
<div class="d-flex align-items-center">
|
||||||
@@ -62,13 +134,18 @@ else
|
|||||||
}
|
}
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<div class="card card-xl-stretch">
|
|
||||||
<div class="card-header border-0">
|
|
||||||
<h3 class="card-title fw-bold text-dark">
|
|
||||||
<TL>Domains</TL>
|
|
||||||
</h3>
|
|
||||||
</div>
|
</div>
|
||||||
<div class="card-body pt-2">
|
</div>
|
||||||
|
|
||||||
|
<div class="accordion mb-3" id="domainsList">
|
||||||
|
<div class="accordion-item">
|
||||||
|
<h2 class="accordion-header" id="domainsList-header">
|
||||||
|
<button class="accordion-button fs-4 fw-semibold collapsed" type="button" data-bs-toggle="collapse" data-bs-target="#domainsList-body" aria-expanded="false" aria-controls="domainsList-body">
|
||||||
|
<TL>Domains</TL>
|
||||||
|
</button>
|
||||||
|
</h2>
|
||||||
|
<div id="domainsList-body" class="accordion-collapse collapse" aria-labelledby="domainsList-header" data-bs-parent="#domainsList">
|
||||||
|
<div class="accordion-body">
|
||||||
@foreach (var domain in Domains)
|
@foreach (var domain in Domains)
|
||||||
{
|
{
|
||||||
<div class="d-flex align-items-center">
|
<div class="d-flex align-items-center">
|
||||||
@@ -85,152 +162,30 @@ else
|
|||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<div class="col-md-8">
|
|
||||||
<div class="card mb-3">
|
|
||||||
<div class="card-body fs-6">
|
|
||||||
<div class="row">
|
|
||||||
<label class="col-lg-4 fw-semibold text-muted">
|
|
||||||
<TL>First name</TL>
|
|
||||||
</label>
|
|
||||||
<div class="col-lg-8">
|
|
||||||
<span class="fw-bold fs-6 text-gray-800">@(User.FirstName)</span>
|
|
||||||
</div>
|
</div>
|
||||||
</div>
|
|
||||||
<div class="separator my-4"></div>
|
|
||||||
<div class="row">
|
|
||||||
<label class="col-lg-4 fw-semibold text-muted">
|
|
||||||
<TL>Last name</TL>
|
|
||||||
</label>
|
|
||||||
<div class="col-lg-8">
|
|
||||||
<span class="fw-bold fs-6 text-gray-800">@(User.LastName)</span>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
<div class="separator my-4"></div>
|
|
||||||
<div class="row">
|
|
||||||
<label class="col-lg-4 fw-semibold text-muted">
|
|
||||||
<TL>Email</TL>
|
|
||||||
</label>
|
|
||||||
<div class="col-lg-8">
|
|
||||||
<span class="fw-bold fs-6 text-gray-800">@(User.Email)</span>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
<div class="separator my-4"></div>
|
|
||||||
<div class="row">
|
|
||||||
<label class="col-lg-4 fw-semibold text-muted">
|
|
||||||
<TL>Address</TL>
|
|
||||||
</label>
|
|
||||||
<div class="col-lg-8">
|
|
||||||
<span class="fw-bold fs-6 text-gray-800">@(User.Address)</span>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
<div class="separator my-4"></div>
|
|
||||||
<div class="row">
|
|
||||||
<label class="col-lg-4 fw-semibold text-muted">
|
|
||||||
<TL>City</TL>
|
|
||||||
</label>
|
|
||||||
<div class="col-lg-8">
|
|
||||||
<span class="fw-bold fs-6 text-gray-800">@(User.City)</span>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
<div class="separator my-4"></div>
|
|
||||||
<div class="row">
|
|
||||||
<label class="col-lg-4 fw-semibold text-muted">
|
|
||||||
<TL>State</TL>
|
|
||||||
</label>
|
|
||||||
<div class="col-lg-8">
|
|
||||||
<span class="fw-bold fs-6 text-gray-800">@(User.State)</span>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
<div class="separator my-4"></div>
|
|
||||||
<div class="row">
|
|
||||||
<label class="col-lg-4 fw-semibold text-muted">
|
|
||||||
<TL>Country</TL>
|
|
||||||
</label>
|
|
||||||
<div class="col-lg-8">
|
|
||||||
<span class="fw-bold fs-6 text-gray-800">@(User.Country)</span>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
<div class="separator my-4"></div>
|
|
||||||
<div class="row">
|
|
||||||
<label class="col-lg-4 fw-semibold text-muted">
|
|
||||||
<TL>Admin</TL>
|
|
||||||
</label>
|
|
||||||
<div class="col-lg-8">
|
|
||||||
<span class="fw-bold fs-6 text-gray-800">
|
|
||||||
@if (User.Admin)
|
|
||||||
{
|
|
||||||
<span>✅</span>
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
<span>❌</span>
|
|
||||||
}
|
|
||||||
</span>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
<div class="separator my-4"></div>
|
|
||||||
<div class="row">
|
|
||||||
<label class="col-lg-4 fw-semibold text-muted">
|
|
||||||
<TL>Status</TL>
|
|
||||||
</label>
|
|
||||||
<div class="col-lg-8">
|
|
||||||
<span class="fw-bold fs-6 text-gray-800">@(User.Status)</span>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
<div class="separator my-4"></div>
|
|
||||||
<div class="row">
|
|
||||||
<label class="col-lg-4 fw-semibold text-muted">
|
|
||||||
<TL>Totp</TL>
|
|
||||||
</label>
|
|
||||||
<div class="col-lg-8">
|
|
||||||
<span class="fw-bold fs-6 text-gray-800">@(User.TotpEnabled)</span>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
<div class="separator my-4"></div>
|
|
||||||
<div class="row">
|
|
||||||
<label class="col-lg-4 fw-semibold text-muted">
|
|
||||||
<TL>Discord</TL>
|
|
||||||
</label>
|
|
||||||
<div class="col-lg-8">
|
|
||||||
<span class="fw-bold fs-6 text-gray-800">@(User.DiscordId)</span>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
<div class="separator my-4"></div>
|
|
||||||
<div class="row">
|
|
||||||
<label class="col-lg-4 fw-semibold text-muted">
|
|
||||||
<TL>Subscription</TL>
|
|
||||||
</label>
|
|
||||||
<div class="col-lg-8">
|
|
||||||
<span class="fw-bold fs-6 text-gray-800">
|
|
||||||
|
|
||||||
</span>
|
<div class="accordion mb-3" id="webspacesList">
|
||||||
|
<div class="accordion-item">
|
||||||
|
<h2 class="accordion-header" id="webspacesList-header">
|
||||||
|
<button class="accordion-button fs-4 fw-semibold collapsed" type="button" data-bs-toggle="collapse" data-bs-target="#webspacesList-body" aria-expanded="false" aria-controls="webspacesList-body">
|
||||||
|
<TL>Webspaces</TL>
|
||||||
|
</button>
|
||||||
|
</h2>
|
||||||
|
<div id="webspacesList-body" class="accordion-collapse collapse" aria-labelledby="webspacesList-header" data-bs-parent="#webspacesList">
|
||||||
|
<div class="accordion-body">
|
||||||
|
@foreach (var webSpace in WebSpaces)
|
||||||
|
{
|
||||||
|
<div class="d-flex align-items-center">
|
||||||
|
<div class="flex-grow-1">
|
||||||
|
<a href="/webspace/@(webSpace.Id)" class="fs-6">@(webSpace.Domain) - @(webSpace.CloudPanel.Name)</a>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
if (webSpace != WebSpaces.Last())
|
||||||
|
{
|
||||||
<div class="separator my-4"></div>
|
<div class="separator my-4"></div>
|
||||||
<div class="row">
|
}
|
||||||
<label class="col-lg-4 fw-semibold text-muted">
|
}
|
||||||
<TL>Created at</TL>
|
|
||||||
</label>
|
|
||||||
<div class="col-lg-8">
|
|
||||||
<span class="fw-bold fs-6 text-gray-800">@(Formatter.FormatDate(User.CreatedAt))</span>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
<div class="separator my-4"></div>
|
|
||||||
<div class="row">
|
|
||||||
<label class="col-lg-4 fw-semibold text-muted">
|
|
||||||
<TL>Register ip</TL>
|
|
||||||
</label>
|
|
||||||
<div class="col-lg-8">
|
|
||||||
<span class="fw-bold fs-6 text-gray-800">@(User.RegisterIp)</span>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
<div class="separator my-4"></div>
|
|
||||||
<div class="row">
|
|
||||||
<label class="col-lg-4 fw-semibold text-muted">
|
|
||||||
<TL>Last ip</TL>
|
|
||||||
</label>
|
|
||||||
<div class="col-lg-8">
|
|
||||||
<span class="fw-bold fs-6 text-gray-800">@(User.LastIp)</span>
|
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
@@ -239,7 +194,6 @@ else
|
|||||||
</div>
|
</div>
|
||||||
}
|
}
|
||||||
</LazyLoader>
|
</LazyLoader>
|
||||||
</OnlyAdmin>
|
|
||||||
|
|
||||||
@code
|
@code
|
||||||
{
|
{
|
||||||
@@ -249,6 +203,7 @@ else
|
|||||||
private User? User;
|
private User? User;
|
||||||
private Server[] Servers;
|
private Server[] Servers;
|
||||||
private Domain[] Domains;
|
private Domain[] Domains;
|
||||||
|
private WebSpace[] WebSpaces;
|
||||||
|
|
||||||
private Task Load(LazyLoader arg)
|
private Task Load(LazyLoader arg)
|
||||||
{
|
{
|
||||||
@@ -269,6 +224,13 @@ else
|
|||||||
.Include(x => x.Owner)
|
.Include(x => x.Owner)
|
||||||
.Where(x => x.Owner.Id == User.Id)
|
.Where(x => x.Owner.Id == User.Id)
|
||||||
.ToArray();
|
.ToArray();
|
||||||
|
|
||||||
|
WebSpaces = WebSpaceRepository
|
||||||
|
.Get()
|
||||||
|
.Include(x => x.CloudPanel)
|
||||||
|
.Include(x => x.Owner)
|
||||||
|
.Where(x => x.Owner.Id == User.Id)
|
||||||
|
.ToArray();
|
||||||
}
|
}
|
||||||
|
|
||||||
return Task.CompletedTask;
|
return Task.CompletedTask;
|
||||||
|
|||||||
@@ -11,7 +11,8 @@
|
|||||||
@inject Repository<WebSpace> WebSpaceRepository
|
@inject Repository<WebSpace> WebSpaceRepository
|
||||||
@inject WebSpaceService WebSpaceService
|
@inject WebSpaceService WebSpaceService
|
||||||
|
|
||||||
<OnlyAdmin>
|
@attribute [PermissionRequired(nameof(Permissions.AdminWebspaces))]
|
||||||
|
|
||||||
<AdminWebspacesNavigation Index="0"/>
|
<AdminWebspacesNavigation Index="0"/>
|
||||||
|
|
||||||
<div class="card">
|
<div class="card">
|
||||||
@@ -66,7 +67,6 @@
|
|||||||
</LazyLoader>
|
</LazyLoader>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</OnlyAdmin>
|
|
||||||
|
|
||||||
@code
|
@code
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -9,7 +9,8 @@
|
|||||||
@inject UserRepository UserRepository
|
@inject UserRepository UserRepository
|
||||||
@inject NavigationManager NavigationManager
|
@inject NavigationManager NavigationManager
|
||||||
|
|
||||||
<OnlyAdmin>
|
@attribute [PermissionRequired(nameof(Permissions.AdminNewWebspace))]
|
||||||
|
|
||||||
<div class="card card-body p-10">
|
<div class="card card-body p-10">
|
||||||
<LazyLoader Load="Load">
|
<LazyLoader Load="Load">
|
||||||
<SmartForm Model="Model" OnValidSubmit="OnValidSubmit">
|
<SmartForm Model="Model" OnValidSubmit="OnValidSubmit">
|
||||||
@@ -37,7 +38,6 @@
|
|||||||
</SmartForm>
|
</SmartForm>
|
||||||
</LazyLoader>
|
</LazyLoader>
|
||||||
</div>
|
</div>
|
||||||
</OnlyAdmin>
|
|
||||||
|
|
||||||
@code
|
@code
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -8,7 +8,8 @@
|
|||||||
@inject Repository<CloudPanel> CloudPanelRepository
|
@inject Repository<CloudPanel> CloudPanelRepository
|
||||||
@inject NavigationManager NavigationManager
|
@inject NavigationManager NavigationManager
|
||||||
|
|
||||||
<OnlyAdmin>
|
@attribute [PermissionRequired(nameof(Permissions.AdminWebspacesServerEdit))]
|
||||||
|
|
||||||
<LazyLoader Load="Load">
|
<LazyLoader Load="Load">
|
||||||
@if (CloudPanel == null)
|
@if (CloudPanel == null)
|
||||||
{
|
{
|
||||||
@@ -63,7 +64,6 @@
|
|||||||
</div>
|
</div>
|
||||||
}
|
}
|
||||||
</LazyLoader>
|
</LazyLoader>
|
||||||
</OnlyAdmin>
|
|
||||||
|
|
||||||
@code
|
@code
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -10,7 +10,8 @@
|
|||||||
@inject Repository<CloudPanel> CloudPanelRepository
|
@inject Repository<CloudPanel> CloudPanelRepository
|
||||||
@inject WebSpaceService WebSpaceService
|
@inject WebSpaceService WebSpaceService
|
||||||
|
|
||||||
<OnlyAdmin>
|
@attribute [PermissionRequired(nameof(Permissions.AdminWebspacesServers))]
|
||||||
|
|
||||||
<AdminWebspacesNavigation Index="1"/>
|
<AdminWebspacesNavigation Index="1"/>
|
||||||
|
|
||||||
<div class="card">
|
<div class="card">
|
||||||
@@ -79,7 +80,6 @@
|
|||||||
</LazyLoader>
|
</LazyLoader>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</OnlyAdmin>
|
|
||||||
|
|
||||||
@code
|
@code
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -7,7 +7,8 @@
|
|||||||
@inject Repository<CloudPanel> CloudPanelRepository
|
@inject Repository<CloudPanel> CloudPanelRepository
|
||||||
@inject NavigationManager NavigationManager
|
@inject NavigationManager NavigationManager
|
||||||
|
|
||||||
<OnlyAdmin>
|
@attribute [PermissionRequired(nameof(Permissions.AdminWebspacesServerNew))]
|
||||||
|
|
||||||
<div class="card card-body p-10">
|
<div class="card card-body p-10">
|
||||||
<SmartForm Model="Model" OnValidSubmit="OnValidSubmit">
|
<SmartForm Model="Model" OnValidSubmit="OnValidSubmit">
|
||||||
<label class="form-label">
|
<label class="form-label">
|
||||||
@@ -41,7 +42,6 @@
|
|||||||
</div>
|
</div>
|
||||||
</SmartForm>
|
</SmartForm>
|
||||||
</div>
|
</div>
|
||||||
</OnlyAdmin>
|
|
||||||
|
|
||||||
@code
|
@code
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -4,6 +4,7 @@
|
|||||||
@using Moonlight.App.Models.Forms
|
@using Moonlight.App.Models.Forms
|
||||||
@using Moonlight.App.Repositories.Domains
|
@using Moonlight.App.Repositories.Domains
|
||||||
@using Microsoft.EntityFrameworkCore
|
@using Microsoft.EntityFrameworkCore
|
||||||
|
@using Moonlight.App.Services.Sessions
|
||||||
|
|
||||||
@inject SubscriptionService SubscriptionService
|
@inject SubscriptionService SubscriptionService
|
||||||
@inject DomainService DomainService
|
@inject DomainService DomainService
|
||||||
@@ -11,6 +12,7 @@
|
|||||||
@inject SharedDomainRepository SharedDomainRepository
|
@inject SharedDomainRepository SharedDomainRepository
|
||||||
@inject NavigationManager NavigationManager
|
@inject NavigationManager NavigationManager
|
||||||
@inject SmartTranslateService SmartTranslateService
|
@inject SmartTranslateService SmartTranslateService
|
||||||
|
@inject IdentityService IdentityService
|
||||||
|
|
||||||
<LazyLoader Load="Load">
|
<LazyLoader Load="Load">
|
||||||
@if (!SharedDomains.Any())
|
@if (!SharedDomains.Any())
|
||||||
@@ -114,8 +116,7 @@
|
|||||||
|
|
||||||
@code
|
@code
|
||||||
{
|
{
|
||||||
[CascadingParameter]
|
|
||||||
public User User { get; set; }
|
|
||||||
|
|
||||||
private SharedDomain[] SharedDomains;
|
private SharedDomain[] SharedDomains;
|
||||||
|
|
||||||
@@ -130,12 +131,12 @@
|
|||||||
Model = new();
|
Model = new();
|
||||||
|
|
||||||
await lazyLoader.SetText(SmartTranslateService.Translate("Loading your subscription"));
|
await lazyLoader.SetText(SmartTranslateService.Translate("Loading your subscription"));
|
||||||
Subscription = await SubscriptionService.GetActiveSubscription(User);
|
Subscription = await SubscriptionService.GetActiveSubscription(IdentityService.User);
|
||||||
|
|
||||||
AllowOrder = DomainRepository
|
AllowOrder = DomainRepository
|
||||||
.Get()
|
.Get()
|
||||||
.Include(x => x.Owner)
|
.Include(x => x.Owner)
|
||||||
.Count(x => x.Owner.Id == User.Id) < (await SubscriptionService.GetLimit(User, "domains")).Amount;
|
.Count(x => x.Owner.Id == IdentityService.User.Id) < (await SubscriptionService.GetLimit(IdentityService.User, "domains")).Amount;
|
||||||
|
|
||||||
await lazyLoader.SetText("Loading shared domains");
|
await lazyLoader.SetText("Loading shared domains");
|
||||||
SharedDomains = SharedDomainRepository.Get().ToArray();
|
SharedDomains = SharedDomainRepository.Get().ToArray();
|
||||||
@@ -146,9 +147,9 @@
|
|||||||
if (DomainRepository
|
if (DomainRepository
|
||||||
.Get()
|
.Get()
|
||||||
.Include(x => x.Owner)
|
.Include(x => x.Owner)
|
||||||
.Count(x => x.Owner.Id == User.Id) < (await SubscriptionService.GetLimit(User, "domains")).Amount)
|
.Count(x => x.Owner.Id == IdentityService.User.Id) < (await SubscriptionService.GetLimit(IdentityService.User, "domains")).Amount)
|
||||||
{
|
{
|
||||||
var domain = await DomainService.Create(Model.Name, Model.SharedDomain, User);
|
var domain = await DomainService.Create(Model.Name, Model.SharedDomain, IdentityService.User);
|
||||||
|
|
||||||
NavigationManager.NavigateTo($"/domain/{domain.Id}");
|
NavigationManager.NavigateTo($"/domain/{domain.Id}");
|
||||||
}
|
}
|
||||||
|
|||||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user