Implemented new permission and identity system
This commit is contained in:
@@ -24,7 +24,7 @@ public class BillingController : Controller
|
||||
[HttpGet("cancel")]
|
||||
public async Task<ActionResult> Cancel()
|
||||
{
|
||||
var user = await IdentityService.Get();
|
||||
var user = IdentityService.User;
|
||||
|
||||
if (user == null)
|
||||
return Redirect("/login");
|
||||
@@ -35,7 +35,7 @@ public class BillingController : Controller
|
||||
[HttpGet("success")]
|
||||
public async Task<ActionResult> Success()
|
||||
{
|
||||
var user = await IdentityService.Get();
|
||||
var user = IdentityService.User;
|
||||
|
||||
if (user == null)
|
||||
return Redirect("/login");
|
||||
|
||||
@@ -25,7 +25,7 @@ public class RegisterController : Controller
|
||||
[HttpGet]
|
||||
public async Task<ActionResult<TokenRegister>> Register()
|
||||
{
|
||||
var user = await IdentityService.Get();
|
||||
var user = IdentityService.User;
|
||||
|
||||
if (user == null)
|
||||
return NotFound();
|
||||
|
||||
@@ -54,7 +54,7 @@ public class OAuth2Controller : Controller
|
||||
{
|
||||
try
|
||||
{
|
||||
var currentUser = await IdentityService.Get();
|
||||
var currentUser = IdentityService.User;
|
||||
|
||||
if (currentUser != null)
|
||||
{
|
||||
|
||||
@@ -5,106 +5,379 @@ public static class Permissions
|
||||
public static Permission AdminDashboard = new()
|
||||
{
|
||||
Index = 0,
|
||||
Name = "Admin dashboard",
|
||||
Description = "See basic information about growth and status of the moonlight instance"
|
||||
Name = "Admin Dashboard",
|
||||
Description = "Access the main admin dashboard page"
|
||||
};
|
||||
|
||||
public static Permission SystemDashboard = new()
|
||||
public static Permission AdminStatistics = new()
|
||||
{
|
||||
Index = 1,
|
||||
Name = "System information",
|
||||
Description = "See information about the moonlight instance like the uptime and memory usage"
|
||||
Name = "Admin Statistics",
|
||||
Description = "View statistical information about the moonlight instance"
|
||||
};
|
||||
|
||||
public static Permission SystemSentry = new()
|
||||
{
|
||||
Index = 2,
|
||||
Name = "Settings for Sentry",
|
||||
Description = "See information about the sentry status"
|
||||
};
|
||||
|
||||
public static Permission SystemMalware = new()
|
||||
{
|
||||
Index = 3,
|
||||
Name = "Server malware scanner",
|
||||
Description = "Scan running servers for malware"
|
||||
};
|
||||
|
||||
public static Permission SystemSecurity = new()
|
||||
public static Permission AdminDomains = new()
|
||||
{
|
||||
Index = 4,
|
||||
Name = "System security settings",
|
||||
Description = "Ban ip addresses and view the security logs"
|
||||
Name = "Admin Domains",
|
||||
Description = "Manage domains in the admin area"
|
||||
};
|
||||
|
||||
public static Permission SystemResources = new()
|
||||
public static Permission AdminNewDomain = new()
|
||||
{
|
||||
Index = 5,
|
||||
Name = "Resources",
|
||||
Description = "Read and write moonlight resources like configuration files"
|
||||
Name = "Admin New Domain",
|
||||
Description = "Create a new domain in the admin area"
|
||||
};
|
||||
|
||||
public static Permission DiscordBot = new()
|
||||
public static Permission AdminSharedDomains = new()
|
||||
{
|
||||
Index = 6,
|
||||
Name = "Discord bot actions",
|
||||
Description = "Setup and remote control the discord bot if enabled"
|
||||
Name = "Admin Shared Domains",
|
||||
Description = "Manage shared domains in the admin area"
|
||||
};
|
||||
|
||||
public static Permission NewsMessages = new()
|
||||
public static Permission AdminNewSharedDomain = new()
|
||||
{
|
||||
Index = 7,
|
||||
Name = "News messages",
|
||||
Description = "Edit, view and delete messages for the user dashboard"
|
||||
Name = "Admin New Shared Domain",
|
||||
Description = "Create a new shared domain in the admin area"
|
||||
};
|
||||
|
||||
public static Permission SystemConfiguration = new()
|
||||
public static Permission AdminNodeDdos = new()
|
||||
{
|
||||
Index = 8,
|
||||
Name = "System configuration",
|
||||
Description = "Modify the moonlight configuration though the visual editor"
|
||||
Name = "Admin Node DDoS",
|
||||
Description = "Manage DDoS protection for nodes in the admin area"
|
||||
};
|
||||
|
||||
public static Permission SystemMail = new()
|
||||
public static Permission AdminNodeEdit = new()
|
||||
{
|
||||
Index = 9,
|
||||
Name = "System mail settings",
|
||||
Description = "Modify the mail templates and send test mails"
|
||||
Name = "Admin Node Edit",
|
||||
Description = "Edit node settings in the admin area"
|
||||
};
|
||||
|
||||
public static Permission ServersOverview = new()
|
||||
public static Permission AdminNodes = new()
|
||||
{
|
||||
Index = 10,
|
||||
Name = "Servers overview",
|
||||
Description = "View all servers and their owners"
|
||||
Name = "Admin Node",
|
||||
Description = "Access the node management page in the admin area"
|
||||
};
|
||||
|
||||
public static Permission ServerAdminEdit = new()
|
||||
public static Permission AdminNewNode = new()
|
||||
{
|
||||
Index = 11,
|
||||
Name = "Edit servers",
|
||||
Description = "View all servers and their owners"
|
||||
Name = "Admin New Node",
|
||||
Description = "Create a new node in the admin area"
|
||||
};
|
||||
|
||||
public static Permission ServerManager = new()
|
||||
public static Permission AdminNodeSetup = new()
|
||||
{
|
||||
Index = 12,
|
||||
Name = "Server manager",
|
||||
Description = "View all servers are currently running and stop/kill all running servers"
|
||||
Name = "Admin Node Setup",
|
||||
Description = "Set up a node in the admin area"
|
||||
};
|
||||
|
||||
public static Permission ServerCleanup = new()
|
||||
public static Permission AdminNodeView = new()
|
||||
{
|
||||
Index = 13,
|
||||
Name = "Server cleanup",
|
||||
Description = "View the stats about the cleanup system"
|
||||
Name = "Admin Node View",
|
||||
Description = "View node details in the admin area"
|
||||
};
|
||||
|
||||
public static Permission Nodes = new()
|
||||
public static Permission AdminNotificationDebugging = new()
|
||||
{
|
||||
Index = 14,
|
||||
Name = "Nodes",
|
||||
Description = "View stats about the nodes"
|
||||
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 AdminServerImageIndex = new()
|
||||
{
|
||||
Index = 21,
|
||||
Name = "Admin Server Image",
|
||||
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 AdminSysMalware = new()
|
||||
{
|
||||
Index = 39,
|
||||
Name = "Admin system 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 AdminSysSecurity = new()
|
||||
{
|
||||
Index = 41,
|
||||
Name = "Admin system Security",
|
||||
Description = "Manage security settings 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? FromString(string name)
|
||||
|
||||
@@ -39,7 +39,7 @@ public class RatingService
|
||||
if (!Enabled)
|
||||
return false;
|
||||
|
||||
var user = await IdentityService.Get();
|
||||
var user = IdentityService.User;
|
||||
|
||||
if (user == null)
|
||||
return false;
|
||||
@@ -62,7 +62,7 @@ public class RatingService
|
||||
|
||||
public async Task<bool> Rate(int rate)
|
||||
{
|
||||
var user = await IdentityService.Get();
|
||||
var user = IdentityService.User;
|
||||
|
||||
// Double check states:
|
||||
|
||||
|
||||
@@ -5,7 +5,6 @@ using JWT.Exceptions;
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
using Moonlight.App.Database.Entities;
|
||||
using Moonlight.App.Helpers;
|
||||
using Moonlight.App.Models.Misc;
|
||||
using Moonlight.App.Perms;
|
||||
using Moonlight.App.Repositories;
|
||||
using UAParser;
|
||||
@@ -19,8 +18,9 @@ public class IdentityService
|
||||
private readonly IHttpContextAccessor HttpContextAccessor;
|
||||
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; }
|
||||
@@ -40,15 +40,17 @@ public class IdentityService
|
||||
.Moonlight.Security.Token;
|
||||
}
|
||||
|
||||
public async Task<User?> Get()
|
||||
public async Task Load()
|
||||
{
|
||||
await LoadIp();
|
||||
await LoadDevice();
|
||||
await LoadUser();
|
||||
}
|
||||
|
||||
private async Task LoadUser()
|
||||
{
|
||||
try
|
||||
{
|
||||
if (UserCache != null)
|
||||
return UserCache;
|
||||
|
||||
ConstructPermissions();
|
||||
|
||||
var token = "none";
|
||||
|
||||
// Load token via http context if available
|
||||
@@ -68,13 +70,13 @@ public class IdentityService
|
||||
|
||||
if (token == "none")
|
||||
{
|
||||
return null;
|
||||
return;
|
||||
}
|
||||
|
||||
if (string.IsNullOrEmpty(token))
|
||||
return null;
|
||||
return;
|
||||
|
||||
var json = "";
|
||||
string json;
|
||||
|
||||
try
|
||||
{
|
||||
@@ -85,18 +87,18 @@ public class IdentityService
|
||||
}
|
||||
catch (TokenExpiredException)
|
||||
{
|
||||
return null;
|
||||
return;
|
||||
}
|
||||
catch (SignatureVerificationException)
|
||||
{
|
||||
Logger.Warn($"Detected a manipulated JWT: {token}", "security");
|
||||
return null;
|
||||
return;
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
Logger.Error("Error reading jwt");
|
||||
Logger.Error(e);
|
||||
return null;
|
||||
return;
|
||||
}
|
||||
|
||||
// To make it easier to use the json data
|
||||
@@ -111,7 +113,7 @@ public class IdentityService
|
||||
{
|
||||
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");
|
||||
return null;
|
||||
return;
|
||||
}
|
||||
|
||||
var iat = data.GetValue<long>("iat", -1);
|
||||
@@ -119,48 +121,54 @@ public class IdentityService
|
||||
if (iat == -1)
|
||||
{
|
||||
Logger.Debug("Legacy token found (without the time the token has been issued at)");
|
||||
return null;
|
||||
return;
|
||||
}
|
||||
|
||||
var iatD = DateTimeOffset.FromUnixTimeSeconds(iat).ToUniversalTime().DateTime;
|
||||
|
||||
if (iatD < user.TokenValidTime)
|
||||
return null;
|
||||
return;
|
||||
|
||||
UserCache = user;
|
||||
User = user;
|
||||
|
||||
ConstructPermissions();
|
||||
|
||||
user.LastIp = GetIp();
|
||||
UserRepository.Update(user);
|
||||
|
||||
return UserCache;
|
||||
User.LastIp = Ip;
|
||||
UserRepository.Update(User);
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
Logger.Error("Unexpected error while processing token");
|
||||
Logger.Error(e);
|
||||
return null;
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
public string GetIp()
|
||||
private Task LoadIp()
|
||||
{
|
||||
if (HttpContextAccessor.HttpContext == null)
|
||||
return "N/A";
|
||||
{
|
||||
Ip = "N/A";
|
||||
return Task.CompletedTask;
|
||||
}
|
||||
|
||||
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)
|
||||
return "N/A";
|
||||
{
|
||||
Device = "N/A";
|
||||
return Task.CompletedTask;
|
||||
}
|
||||
|
||||
try
|
||||
{
|
||||
@@ -170,26 +178,29 @@ public class IdentityService
|
||||
{
|
||||
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 info = uaParser.Parse(userAgent);
|
||||
|
||||
return $"{info.OS} - {info.Device}";
|
||||
Device = $"{info.OS} - {info.Device}";
|
||||
return Task.CompletedTask;
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
return "UserAgent not present";
|
||||
Device = "UserAgent not present";
|
||||
return Task.CompletedTask;
|
||||
}
|
||||
}
|
||||
|
||||
public Task SavePermissions()
|
||||
{
|
||||
if (UserCache != null)
|
||||
if (User != null)
|
||||
{
|
||||
UserCache.Permissions = UserPermissions.Data;
|
||||
UserRepository.Update(UserCache);
|
||||
User.Permissions = UserPermissions.Data;
|
||||
UserRepository.Update(User);
|
||||
ConstructPermissions();
|
||||
}
|
||||
|
||||
@@ -198,7 +209,7 @@ public class IdentityService
|
||||
|
||||
private void ConstructPermissions()
|
||||
{
|
||||
if (UserCache == null)
|
||||
if (User == null)
|
||||
{
|
||||
UserPermissions = new(Array.Empty<byte>());
|
||||
GroupPermissions = new(Array.Empty<byte>(), true);
|
||||
@@ -210,7 +221,7 @@ public class IdentityService
|
||||
var user = UserRepository
|
||||
.Get()
|
||||
.Include(x => x.PermissionGroup)
|
||||
.First(x => x.Id == UserCache.Id);
|
||||
.First(x => x.Id == User.Id);
|
||||
|
||||
UserPermissions = new PermissionStorage(user.Permissions);
|
||||
|
||||
@@ -219,7 +230,18 @@ public class IdentityService
|
||||
else
|
||||
GroupPermissions = new PermissionStorage(user.PermissionGroup.Permissions, true);
|
||||
|
||||
Logger.Debug($"{UserPermissions[Perms.Permissions.AdminDashboard]} {GroupPermissions[Perms.Permissions.AdminDashboard]}");
|
||||
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 PermissionStorage(BitHelper.OverwriteByteArrays(
|
||||
UserPermissions.Data,
|
||||
|
||||
@@ -19,7 +19,7 @@ public class IpBanService
|
||||
|
||||
public Task<bool> IsBanned()
|
||||
{
|
||||
var ip = IdentityService.GetIp();
|
||||
var ip = IdentityService.Ip;
|
||||
|
||||
return Task.FromResult(
|
||||
IpBanRepository
|
||||
|
||||
@@ -15,7 +15,7 @@ public class IpLocateService
|
||||
|
||||
public async Task<string> GetLocation()
|
||||
{
|
||||
var ip = IdentityService.GetIp();
|
||||
var ip = IdentityService.Ip;
|
||||
var location = "N/A";
|
||||
|
||||
if (ip != "N/A")
|
||||
|
||||
@@ -40,9 +40,9 @@ public class SessionClientService
|
||||
|
||||
public async Task Start()
|
||||
{
|
||||
User = await IdentityService.Get();
|
||||
Ip = IdentityService.GetIp();
|
||||
Device = IdentityService.GetDevice();
|
||||
User = IdentityService.User;
|
||||
Ip = IdentityService.Ip;
|
||||
Device = IdentityService.Device;
|
||||
|
||||
if (User != null) // Track users last visit
|
||||
{
|
||||
|
||||
@@ -34,7 +34,7 @@ public class SupportChatAdminService : IDisposable
|
||||
|
||||
public async Task Start(User recipient)
|
||||
{
|
||||
User = await IdentityService.Get();
|
||||
User = IdentityService.User;
|
||||
Recipient = recipient;
|
||||
|
||||
if (User != null)
|
||||
|
||||
@@ -33,7 +33,7 @@ public class SupportChatClientService : IDisposable
|
||||
|
||||
public async Task Start()
|
||||
{
|
||||
User = await IdentityService.Get();
|
||||
User = IdentityService.User;
|
||||
|
||||
if (User != null)
|
||||
{
|
||||
|
||||
@@ -25,32 +25,30 @@ public class TotpService
|
||||
return Task.FromResult(codeserver == code);
|
||||
}
|
||||
|
||||
public async Task<bool> GetEnabled()
|
||||
public Task<bool> GetEnabled()
|
||||
{
|
||||
var user = await IdentityService.Get();
|
||||
|
||||
return user!.TotpEnabled;
|
||||
return Task.FromResult(IdentityService.User.TotpEnabled);
|
||||
}
|
||||
|
||||
public async Task<string> GetSecret()
|
||||
public Task<string> GetSecret()
|
||||
{
|
||||
var user = await IdentityService.Get();
|
||||
|
||||
return user!.TotpSecret;
|
||||
return Task.FromResult(IdentityService.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));;
|
||||
|
||||
UserRepository.Update(user);
|
||||
|
||||
return Task.CompletedTask;
|
||||
}
|
||||
|
||||
public async Task Enable(string code)
|
||||
{
|
||||
var user = (await IdentityService.Get())!;
|
||||
var user = IdentityService.User;
|
||||
|
||||
if (!await Verify(user.TotpSecret, code))
|
||||
{
|
||||
@@ -61,9 +59,9 @@ public class TotpService
|
||||
UserRepository.Update(user);
|
||||
}
|
||||
|
||||
public async Task Disable()
|
||||
public Task Disable()
|
||||
{
|
||||
var user = (await IdentityService.Get())!;
|
||||
var user = IdentityService.User;
|
||||
|
||||
user.TotpEnabled = false;
|
||||
user.TotpSecret = "";
|
||||
@@ -71,5 +69,7 @@ public class TotpService
|
||||
UserRepository.Update(user);
|
||||
|
||||
//TODO: AuditLog
|
||||
|
||||
return Task.CompletedTask;
|
||||
}
|
||||
}
|
||||
@@ -85,8 +85,8 @@ public class UserService
|
||||
TotpSecret = "",
|
||||
UpdatedAt = DateTimeService.GetCurrent(),
|
||||
TokenValidTime = DateTimeService.GetCurrent().AddDays(-5),
|
||||
LastIp = IdentityService.GetIp(),
|
||||
RegisterIp = IdentityService.GetIp()
|
||||
LastIp = IdentityService.Ip,
|
||||
RegisterIp = IdentityService.Ip
|
||||
});
|
||||
|
||||
await MailService.SendMail(user!, "register", values => {});
|
||||
@@ -174,8 +174,8 @@ public class UserService
|
||||
|
||||
await MailService.SendMail(user!, "passwordChange", values =>
|
||||
{
|
||||
values.Add("Ip", IdentityService.GetIp());
|
||||
values.Add("Device", IdentityService.GetDevice());
|
||||
values.Add("Ip", IdentityService.Ip);
|
||||
values.Add("Device", IdentityService.Device);
|
||||
values.Add("Location", location);
|
||||
});
|
||||
|
||||
@@ -212,8 +212,8 @@ public class UserService
|
||||
{
|
||||
await MailService.SendMail(user!, "login", values =>
|
||||
{
|
||||
values.Add("Ip", IdentityService.GetIp());
|
||||
values.Add("Device", IdentityService.GetDevice());
|
||||
values.Add("Ip", IdentityService.Ip);
|
||||
values.Add("Device", IdentityService.Device);
|
||||
values.Add("Location", location);
|
||||
});
|
||||
}
|
||||
@@ -249,8 +249,8 @@ public class UserService
|
||||
|
||||
await MailService.SendMail(user, "passwordReset", values =>
|
||||
{
|
||||
values.Add("Ip", IdentityService.GetIp());
|
||||
values.Add("Device", IdentityService.GetDevice());
|
||||
values.Add("Ip", IdentityService.Ip);
|
||||
values.Add("Device", IdentityService.Device);
|
||||
values.Add("Location", location);
|
||||
values.Add("Password", newPassword);
|
||||
});
|
||||
|
||||
@@ -78,6 +78,8 @@
|
||||
<_ContentIncludedByDefault Remove="Shared\Components\News\NewsEditor.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>
|
||||
|
||||
@@ -49,9 +49,10 @@
|
||||
private PasswordModel Password = new();
|
||||
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()
|
||||
|
||||
@@ -50,9 +50,10 @@
|
||||
private User User;
|
||||
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()
|
||||
|
||||
@@ -57,7 +57,7 @@ else
|
||||
{
|
||||
receivedExceptions.Add(exception);
|
||||
|
||||
var user = await IdentityService.Get();
|
||||
var user = IdentityService.User;
|
||||
var id = user == null ? -1 : user.Id;
|
||||
|
||||
Logger.Error($"[{id}] An unhanded exception occured:");
|
||||
|
||||
@@ -1,5 +1,8 @@
|
||||
@using Moonlight.App.Database.Entities
|
||||
@using Moonlight.App.Models.Misc
|
||||
@using Moonlight.App.Services.Sessions
|
||||
|
||||
@inject IdentityService IdentityService
|
||||
|
||||
<div class="card mb-5 mb-xl-10">
|
||||
<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 flex-column">
|
||||
<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>
|
||||
}
|
||||
</div>
|
||||
<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" : "")">
|
||||
@(User.Email)
|
||||
<span class="d-flex align-items-center text-gray-400 mb-2 @(IdentityService.User.StreamerMode ? "blur" : "")">
|
||||
@(IdentityService.User.Email)
|
||||
</span>
|
||||
</div>
|
||||
</div>
|
||||
@@ -51,9 +54,6 @@
|
||||
|
||||
@code
|
||||
{
|
||||
[CascadingParameter]
|
||||
public User User { get; set; }
|
||||
|
||||
[Parameter]
|
||||
public int Index { get; set; } = 0;
|
||||
}
|
||||
@@ -106,7 +106,7 @@
|
||||
{
|
||||
if (firstRender)
|
||||
{
|
||||
User = await IdentityService.Get();
|
||||
User = IdentityService.User;
|
||||
|
||||
await InvokeAsync(StateHasChanged);
|
||||
}
|
||||
|
||||
@@ -54,7 +54,7 @@ else
|
||||
|
||||
if (!Allowed)
|
||||
{
|
||||
Logger.Warn($"{IdentityService.GetIp()} has tried to access {NavigationManager.Uri} without permission", "security");
|
||||
Logger.Warn($"{IdentityService.Ip} has tried to access {NavigationManager.Uri} without permission", "security");
|
||||
}
|
||||
|
||||
return Task.CompletedTask;
|
||||
|
||||
@@ -49,7 +49,7 @@
|
||||
{
|
||||
if (firstRender)
|
||||
{
|
||||
User = await IdentityService.Get();
|
||||
User = IdentityService.User;
|
||||
sidebar = await JsRuntime.InvokeAsync<string>("document.body.getAttribute", "data-kt-app-layout");
|
||||
StateHasChanged();
|
||||
}
|
||||
|
||||
@@ -228,7 +228,7 @@ else
|
||||
{
|
||||
if (firstRender)
|
||||
{
|
||||
User = await IdentityService.Get();
|
||||
User = IdentityService.User;
|
||||
|
||||
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>
|
||||
<CascadingValue Value="User">
|
||||
<PageTitle>@(string.IsNullOrEmpty(title) ? "Dashboard - " : title)Moonlight</PageTitle>
|
||||
|
||||
<div class="d-flex flex-column flex-root app-root" id="kt_app_root">
|
||||
@@ -70,25 +69,25 @@
|
||||
uri.LocalPath != "/passwordreset" &&
|
||||
uri.LocalPath != "/register")
|
||||
{
|
||||
if (User == null)
|
||||
if (IdentityService.User == null)
|
||||
{
|
||||
<Login></Login>
|
||||
}
|
||||
else
|
||||
{
|
||||
if (User.Status == UserStatus.Banned)
|
||||
if (IdentityService.User.Status == UserStatus.Banned)
|
||||
{
|
||||
<BannedAlert></BannedAlert>
|
||||
}
|
||||
else if (User.Status == UserStatus.Disabled)
|
||||
else if (IdentityService.User.Status == UserStatus.Disabled)
|
||||
{
|
||||
<DisabledAlert></DisabledAlert>
|
||||
}
|
||||
else if (User.Status == UserStatus.PasswordPending)
|
||||
else if (IdentityService.User.Status == UserStatus.PasswordPending)
|
||||
{
|
||||
<PasswordChangeView></PasswordChangeView>
|
||||
}
|
||||
else if (User.Status == UserStatus.DataPending)
|
||||
else if (IdentityService.User.Status == UserStatus.DataPending)
|
||||
{
|
||||
<UserDataSetView></UserDataSetView>
|
||||
}
|
||||
@@ -155,12 +154,10 @@
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</CascadingValue>
|
||||
</GlobalErrorBoundary>
|
||||
|
||||
@code
|
||||
{
|
||||
private User? User;
|
||||
private bool UserProcessed = false;
|
||||
|
||||
private bool IsIpBanned = false;
|
||||
@@ -204,7 +201,7 @@
|
||||
NavigationManager.NavigateTo(NavigationManager.Uri, true);
|
||||
});
|
||||
|
||||
User = await IdentityService.Get();
|
||||
await IdentityService.Load();
|
||||
UserProcessed = true;
|
||||
await InvokeAsync(StateHasChanged);
|
||||
|
||||
@@ -215,7 +212,10 @@
|
||||
await JsRuntime.InvokeVoidAsync("KTMenu.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();
|
||||
|
||||
@@ -225,14 +225,14 @@
|
||||
await DynamicBackgroundService.Reset();
|
||||
};
|
||||
|
||||
if (User != null)
|
||||
if (IdentityService.User != null)
|
||||
{
|
||||
await Event.On<SupportChatMessage>(
|
||||
$"supportChat.{User.Id}.message",
|
||||
$"supportChat.{IdentityService.User.Id}.message",
|
||||
this,
|
||||
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}");
|
||||
}
|
||||
@@ -259,9 +259,9 @@
|
||||
|
||||
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
|
||||
{
|
||||
private User? User;
|
||||
|
||||
protected override void OnInitialized()
|
||||
{
|
||||
AddBodyAttribute("data-kt-app-page-loading", "on");
|
||||
@@ -95,7 +93,7 @@
|
||||
{
|
||||
try
|
||||
{
|
||||
User = await IdentityService.Get();
|
||||
await IdentityService.Load();
|
||||
|
||||
await InvokeAsync(StateHasChanged);
|
||||
await Task.Delay(300);
|
||||
|
||||
@@ -1,5 +0,0 @@
|
||||
@page "/admin/databases"
|
||||
|
||||
<OnlyAdmin>
|
||||
|
||||
</OnlyAdmin>
|
||||
@@ -9,7 +9,8 @@
|
||||
@inject DomainService DomainService
|
||||
@inject SmartTranslateService SmartTranslateService
|
||||
|
||||
<OnlyAdmin>
|
||||
@attribute [PermissionRequired(nameof(Permissions.AdminDomains))]
|
||||
|
||||
<LazyLoader @ref="LazyLoader" Load="Load">
|
||||
<div class="row">
|
||||
<div class="card">
|
||||
@@ -61,7 +62,6 @@
|
||||
</div>
|
||||
</div>
|
||||
</LazyLoader>
|
||||
</OnlyAdmin>
|
||||
|
||||
@code
|
||||
{
|
||||
|
||||
@@ -11,7 +11,8 @@
|
||||
@inject NavigationManager NavigationManager
|
||||
@inject DomainService DomainService
|
||||
|
||||
<OnlyAdmin>
|
||||
@attribute [PermissionRequired(nameof(Permissions.AdminNewDomain))]
|
||||
|
||||
<div class="row mb-5">
|
||||
<div class="card card-body p-10">
|
||||
<LazyLoader Load="Load">
|
||||
@@ -48,7 +49,6 @@
|
||||
</LazyLoader>
|
||||
</div>
|
||||
</div>
|
||||
</OnlyAdmin>
|
||||
|
||||
@code
|
||||
{
|
||||
|
||||
@@ -12,7 +12,8 @@
|
||||
@inject AlertService AlertService
|
||||
@inject ToastService ToastService
|
||||
|
||||
<OnlyAdmin>
|
||||
@attribute [PermissionRequired(nameof(Permissions.AdminSharedDomains))]
|
||||
|
||||
<LazyLoader @ref="LazyLoader" Load="Load">
|
||||
<div class="card">
|
||||
<div class="card-header border-0 pt-5">
|
||||
@@ -44,7 +45,6 @@
|
||||
</div>
|
||||
</div>
|
||||
</LazyLoader>
|
||||
</OnlyAdmin>
|
||||
|
||||
@code
|
||||
{
|
||||
|
||||
@@ -12,6 +12,8 @@
|
||||
@inject ToastService ToastService
|
||||
@inject NavigationManager NavigationManager
|
||||
|
||||
@attribute [PermissionRequired(nameof(Permissions.AdminNewSharedDomain))]
|
||||
|
||||
<LazyLoader Load="Load" @ref="LazyLoader">
|
||||
<div class="row mb-5">
|
||||
<div class="card card-body">
|
||||
|
||||
@@ -5,7 +5,6 @@
|
||||
@using Moonlight.App.Database.Entities
|
||||
@using Moonlight.App.Helpers
|
||||
@using Moonlight.App.Models.Misc
|
||||
@using Moonlight.App.Perms
|
||||
@using Moonlight.App.Services
|
||||
@using Newtonsoft.Json
|
||||
|
||||
|
||||
@@ -15,7 +15,8 @@
|
||||
@inject SmartTranslateService SmartTranslateService
|
||||
@inject EventSystem Event
|
||||
|
||||
<OnlyAdmin>
|
||||
@attribute [PermissionRequired(nameof(Permissions.AdminNodeDdos))]
|
||||
|
||||
<AdminNodesNavigation Index="1"/>
|
||||
|
||||
<LazyLoader @ref="LazyLoader" Load="Load">
|
||||
@@ -69,7 +70,6 @@
|
||||
</div>
|
||||
</div>
|
||||
</LazyLoader>
|
||||
</OnlyAdmin>
|
||||
|
||||
@code
|
||||
{
|
||||
|
||||
@@ -9,7 +9,8 @@
|
||||
@inject SmartTranslateService SmartTranslateService
|
||||
@inject NavigationManager NavigationManager
|
||||
|
||||
<OnlyAdmin>
|
||||
@attribute [PermissionRequired(nameof(Permissions.AdminNodeEdit))]
|
||||
|
||||
<LazyLoader Load="Load" @ref="LazyLoader">
|
||||
@if (Node == null)
|
||||
{
|
||||
@@ -149,7 +150,6 @@
|
||||
</div>
|
||||
}
|
||||
</LazyLoader>
|
||||
</OnlyAdmin>
|
||||
|
||||
@code
|
||||
{
|
||||
|
||||
@@ -13,7 +13,8 @@
|
||||
@inject NodeService NodeService
|
||||
@inject SmartTranslateService SmartTranslateService
|
||||
|
||||
<OnlyAdmin>
|
||||
@attribute [PermissionRequired(nameof(Permissions.AdminNodes))]
|
||||
|
||||
<AdminNodesNavigation Index="0"/>
|
||||
|
||||
<LazyLoader @ref="LazyLoader" Load="Load">
|
||||
@@ -95,7 +96,6 @@
|
||||
</div>
|
||||
</div>
|
||||
</LazyLoader>
|
||||
</OnlyAdmin>
|
||||
|
||||
@code
|
||||
{
|
||||
|
||||
@@ -9,7 +9,8 @@
|
||||
@inject NodeRepository NodeRepository
|
||||
@inject NavigationManager NavigationManager
|
||||
|
||||
<OnlyAdmin>
|
||||
@attribute [PermissionRequired(nameof(Permissions.AdminNewNode))]
|
||||
|
||||
<div class="d-flex flex-center">
|
||||
<div class="card rounded-3 w-md-550px">
|
||||
<div class="card-body">
|
||||
@@ -73,7 +74,6 @@
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</OnlyAdmin>
|
||||
|
||||
@code
|
||||
{
|
||||
|
||||
@@ -6,11 +6,12 @@
|
||||
@inject NodeRepository NodeRepository
|
||||
@inject ConfigService ConfigService
|
||||
|
||||
@attribute [PermissionRequired(nameof(Permissions.AdminNodeSetup))]
|
||||
|
||||
@{
|
||||
var appUrl = ConfigService.Get().Moonlight.AppUrl;
|
||||
}
|
||||
|
||||
<OnlyAdmin>
|
||||
<LazyLoader Load="Load">
|
||||
@if (Node == null)
|
||||
{
|
||||
@@ -141,7 +142,6 @@
|
||||
</div>
|
||||
}
|
||||
</LazyLoader>
|
||||
</OnlyAdmin>
|
||||
|
||||
@code
|
||||
{
|
||||
|
||||
@@ -10,7 +10,8 @@
|
||||
@inject NodeRepository NodeRepository
|
||||
@inject NodeService NodeService
|
||||
|
||||
<OnlyAdmin>
|
||||
@attribute [PermissionRequired(nameof(Permissions.AdminNodeView))]
|
||||
|
||||
<LazyLoader Load="Load">
|
||||
@if (Node == null)
|
||||
{
|
||||
@@ -252,7 +253,6 @@ else
|
||||
</div>
|
||||
}
|
||||
</LazyLoader>
|
||||
</OnlyAdmin>
|
||||
|
||||
@code
|
||||
{
|
||||
|
||||
@@ -12,7 +12,8 @@
|
||||
|
||||
@implements IDisposable
|
||||
|
||||
<OnlyAdmin>
|
||||
@attribute [PermissionRequired(nameof(Permissions.AdminNotificationDebugging))]
|
||||
|
||||
<LazyLoader Load="Load">
|
||||
<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">
|
||||
@@ -31,8 +32,6 @@
|
||||
</Table>
|
||||
</div>
|
||||
</LazyLoader>
|
||||
</OnlyAdmin>
|
||||
|
||||
|
||||
@code
|
||||
{
|
||||
|
||||
@@ -7,7 +7,8 @@
|
||||
|
||||
@implements IDisposable
|
||||
|
||||
<OnlyAdmin>
|
||||
@attribute [PermissionRequired(nameof(Permissions.AdminServerCleanup))]
|
||||
|
||||
<div class="row g-5 g-xl-10 mb-5 mb-xl-10">
|
||||
<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;">
|
||||
@@ -76,7 +77,6 @@
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</OnlyAdmin>
|
||||
|
||||
@code
|
||||
{
|
||||
|
||||
@@ -13,7 +13,8 @@
|
||||
@inject ImageRepository ImageRepository
|
||||
@inject Repository<User> UserRepository
|
||||
|
||||
<OnlyAdmin>
|
||||
@attribute [PermissionRequired(nameof(Permissions.AdminServerEdit))]
|
||||
|
||||
<LazyLoader @ref="LazyLoader" Load="Load">
|
||||
@if (Server == null)
|
||||
{
|
||||
@@ -171,7 +172,6 @@
|
||||
</SmartForm>
|
||||
}
|
||||
</LazyLoader>
|
||||
</OnlyAdmin>
|
||||
|
||||
@code
|
||||
{
|
||||
|
||||
@@ -8,7 +8,7 @@
|
||||
@inject ServerRepository ServerRepository
|
||||
@inject SmartTranslateService SmartTranslateService
|
||||
|
||||
@attribute [PermissionRequired(nameof(Permissions.ServersOverview))]
|
||||
@attribute [PermissionRequired(nameof(Permissions.AdminServers))]
|
||||
|
||||
<div class="row">
|
||||
<LazyLoader Load="Load">
|
||||
|
||||
@@ -18,7 +18,8 @@
|
||||
@inject AlertService AlertService
|
||||
@inject ServerService ServerService
|
||||
|
||||
<OnlyAdmin>
|
||||
@attribute [PermissionRequired(nameof(Permissions.AdminServerManager))]
|
||||
|
||||
<div class="card mb-5">
|
||||
<div class="card-body">
|
||||
<WButton Text="@(SmartTranslateService.Translate("Refresh"))"
|
||||
@@ -97,7 +98,6 @@
|
||||
</Table>
|
||||
</div>
|
||||
</div>
|
||||
</OnlyAdmin>
|
||||
|
||||
@code
|
||||
{
|
||||
|
||||
@@ -17,7 +17,8 @@
|
||||
@inject NavigationManager NavigationManager
|
||||
@inject UserRepository UserRepository
|
||||
|
||||
<OnlyAdmin>
|
||||
@attribute [PermissionRequired(nameof(Permissions.AdminNewServer))]
|
||||
|
||||
<LazyLoader Load="Load">
|
||||
<SmartForm Model="Model" OnValidSubmit="Create">
|
||||
<div class="row mb-5">
|
||||
@@ -173,7 +174,6 @@
|
||||
</div>
|
||||
</SmartForm>
|
||||
</LazyLoader>
|
||||
</OnlyAdmin>
|
||||
|
||||
@code
|
||||
{
|
||||
|
||||
@@ -10,7 +10,8 @@
|
||||
@inject StatisticsViewService StatisticsViewService
|
||||
@inject SmartTranslateService SmartTranslateService
|
||||
|
||||
<OnlyAdmin>
|
||||
@attribute [PermissionRequired(nameof(Permissions.AdminStatistics))]
|
||||
|
||||
<div class="row mt-4 mb-2">
|
||||
<div class="col-12 col-lg-6 col-xl">
|
||||
<div class="card card-body">
|
||||
@@ -81,7 +82,6 @@
|
||||
</div>
|
||||
</div>
|
||||
</LazyLoader>
|
||||
</OnlyAdmin>
|
||||
|
||||
@code
|
||||
{
|
||||
|
||||
@@ -10,7 +10,8 @@
|
||||
@inject SubscriptionRepository SubscriptionRepository
|
||||
@inject SubscriptionService SubscriptionService
|
||||
|
||||
<OnlyAdmin>
|
||||
@attribute [PermissionRequired(nameof(Permissions.AdminSubscriptionEdit))]
|
||||
|
||||
<div class="card card-body p-10">
|
||||
<LazyLoader Load="Load">
|
||||
@if (Subscription == null)
|
||||
@@ -158,7 +159,6 @@
|
||||
}
|
||||
</LazyLoader>
|
||||
</div>
|
||||
</OnlyAdmin>
|
||||
|
||||
@code
|
||||
{
|
||||
|
||||
@@ -9,7 +9,8 @@
|
||||
@inject SubscriptionRepository SubscriptionRepository
|
||||
@inject SubscriptionService SubscriptionService
|
||||
|
||||
<OnlyAdmin>
|
||||
@attribute [PermissionRequired(nameof(Permissions.AdminSubscriptions))]
|
||||
|
||||
<div class="card">
|
||||
<LazyLoader @ref="LazyLoader" Load="Load">
|
||||
<div class="card-header border-0 pt-5">
|
||||
@@ -54,7 +55,6 @@
|
||||
</div>
|
||||
</LazyLoader>
|
||||
</div>
|
||||
</OnlyAdmin>
|
||||
|
||||
@code
|
||||
{
|
||||
|
||||
@@ -8,7 +8,8 @@
|
||||
@inject SubscriptionRepository SubscriptionRepository
|
||||
@inject SubscriptionService SubscriptionService
|
||||
|
||||
<OnlyAdmin>
|
||||
@attribute [PermissionRequired(nameof(Permissions.AdminNewSubscription))]
|
||||
|
||||
<div class="card card-body p-10">
|
||||
<SmartForm Model="Model" OnValidSubmit="OnSubmit">
|
||||
<label class="form-label">
|
||||
@@ -145,7 +146,6 @@
|
||||
</div>
|
||||
</SmartForm>
|
||||
</div>
|
||||
</OnlyAdmin>
|
||||
|
||||
@code
|
||||
{
|
||||
|
||||
@@ -8,7 +8,8 @@
|
||||
|
||||
@implements IDisposable
|
||||
|
||||
<OnlyAdmin>
|
||||
@attribute [PermissionRequired(nameof(Permissions.AdminSupport))]
|
||||
|
||||
<LazyLoader @ref="LazyLoader" Load="Load">
|
||||
<div class="card">
|
||||
<div class="card-body">
|
||||
@@ -70,7 +71,6 @@
|
||||
</div>
|
||||
</div>
|
||||
</LazyLoader>
|
||||
</OnlyAdmin>
|
||||
|
||||
@code
|
||||
{
|
||||
|
||||
@@ -14,7 +14,8 @@
|
||||
|
||||
@implements IDisposable
|
||||
|
||||
<OnlyAdmin>
|
||||
@attribute [PermissionRequired(nameof(Permissions.AdminSupportView))]
|
||||
|
||||
<LazyLoader Load="Load">
|
||||
@if (User == null)
|
||||
{
|
||||
@@ -220,7 +221,6 @@
|
||||
</div>
|
||||
}
|
||||
</LazyLoader>
|
||||
</OnlyAdmin>
|
||||
|
||||
@code
|
||||
{
|
||||
|
||||
@@ -9,7 +9,7 @@
|
||||
@inject ToastService ToastService
|
||||
@inject SmartTranslateService SmartTranslateService
|
||||
|
||||
@attribute [PermissionRequired(nameof(Permissions.SystemConfiguration))]
|
||||
@attribute [PermissionRequired(nameof(Permissions.AdminSysConfiguration))]
|
||||
|
||||
<AdminSystemNavigation Index="8"/>
|
||||
|
||||
|
||||
@@ -4,7 +4,7 @@
|
||||
|
||||
@inject DiscordBotService DiscordBotService
|
||||
|
||||
@attribute [PermissionRequired(nameof(Permissions.DiscordBot))]
|
||||
@attribute [PermissionRequired(nameof(Permissions.AdminSysDiscordBot))]
|
||||
|
||||
<AdminSystemNavigation Index="6"/>
|
||||
|
||||
|
||||
@@ -7,7 +7,7 @@
|
||||
@inject HostSystemHelper HostSystemHelper
|
||||
@inject MoonlightService MoonlightService
|
||||
|
||||
@attribute [PermissionRequired(nameof(Permissions.SystemDashboard))]
|
||||
@attribute [PermissionRequired(nameof(Permissions.AdminSystem))]
|
||||
|
||||
<AdminSystemNavigation Index="0"/>
|
||||
|
||||
|
||||
@@ -5,18 +5,19 @@
|
||||
@using Moonlight.App.Helpers.Files
|
||||
@using Moonlight.App.Helpers
|
||||
@using BlazorTable
|
||||
@using Moonlight.App.Database.Entities
|
||||
@using Moonlight.App.Models.Misc
|
||||
@using Moonlight.App.Services
|
||||
@using Moonlight.App.Services.Interop
|
||||
@using Moonlight.App.Services.Mail
|
||||
@using Moonlight.App.Services.Sessions
|
||||
|
||||
@inject SmartTranslateService SmartTranslateService
|
||||
@inject ToastService ToastService
|
||||
@inject AlertService AlertService
|
||||
@inject MailService MailService
|
||||
@inject IdentityService IdentityService
|
||||
|
||||
@attribute [PermissionRequired(nameof(Permissions.SystemMail))]
|
||||
@attribute [PermissionRequired(nameof(Permissions.AdminSysMail))]
|
||||
|
||||
<AdminSystemNavigation Index="9"/>
|
||||
|
||||
@@ -92,8 +93,7 @@
|
||||
|
||||
@code
|
||||
{
|
||||
[CascadingParameter]
|
||||
public User User { get; set; }
|
||||
|
||||
|
||||
private MailTemplate[] MailTemplateFiles;
|
||||
private FileAccess FileAccess;
|
||||
@@ -174,7 +174,7 @@
|
||||
|
||||
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"));
|
||||
}
|
||||
}
|
||||
@@ -14,7 +14,7 @@
|
||||
|
||||
@implements IDisposable
|
||||
|
||||
@attribute [PermissionRequired(nameof(Permissions.SystemMalware))]
|
||||
@attribute [PermissionRequired(nameof(Permissions.AdminSysMalware))]
|
||||
|
||||
<AdminSystemNavigation Index="2"/>
|
||||
|
||||
|
||||
@@ -10,7 +10,7 @@
|
||||
@inject NavigationManager NavigationManager
|
||||
@inject NewsEntryRepository NewsEntryRepository
|
||||
|
||||
@attribute [PermissionRequired(nameof(Permissions.NewsMessages))]
|
||||
@attribute [PermissionRequired(nameof(Permissions.AdminSysNewsEdit))]
|
||||
|
||||
<LazyLoader Load="Load">
|
||||
@if (Entry == null)
|
||||
|
||||
@@ -12,7 +12,7 @@
|
||||
@inject SmartTranslateService SmartTranslateService
|
||||
@inject AlertService AlertService
|
||||
|
||||
@attribute [PermissionRequired(nameof(Permissions.NewsMessages))]
|
||||
@attribute [PermissionRequired(nameof(Permissions.AdminSysNews))]
|
||||
|
||||
<AdminSystemNavigation Index="7"/>
|
||||
|
||||
|
||||
@@ -9,7 +9,7 @@
|
||||
@inject NavigationManager NavigationManager
|
||||
@inject NewsEntryRepository NewsEntryRepository
|
||||
|
||||
@attribute [PermissionRequired(nameof(Permissions.NewsMessages))]
|
||||
@attribute [PermissionRequired(nameof(Permissions.AdminSysNewsNew))]
|
||||
|
||||
<div class="card mb-6">
|
||||
<div class="card-header">
|
||||
|
||||
@@ -11,7 +11,7 @@
|
||||
@inject ConfigService ConfigService
|
||||
@inject AlertService AlertService
|
||||
|
||||
@attribute [PermissionRequired(nameof(Permissions.SystemResources))]
|
||||
@attribute [PermissionRequired(nameof(Permissions.AdminSysResources))]
|
||||
|
||||
<AdminSystemNavigation Index="5"/>
|
||||
|
||||
|
||||
@@ -13,7 +13,7 @@
|
||||
@inject EventSystem Event
|
||||
@inject ToastService ToastService
|
||||
|
||||
@attribute [PermissionRequired(nameof(Permissions.SystemSecurity))]
|
||||
@attribute [PermissionRequired(nameof(Permissions.AdminSysSecurity))]
|
||||
|
||||
<AdminSystemNavigation Index="3"/>
|
||||
|
||||
|
||||
@@ -3,7 +3,7 @@
|
||||
@using Moonlight.Shared.Components.Navigations
|
||||
@using global::Sentry
|
||||
|
||||
@attribute [PermissionRequired(nameof(Permissions.SystemSentry))]
|
||||
@attribute [PermissionRequired(nameof(Permissions.AdminSysSentry))]
|
||||
|
||||
<AdminSystemNavigation Index="1"/>
|
||||
|
||||
|
||||
@@ -12,7 +12,8 @@
|
||||
@inject ToastService ToastService
|
||||
@inject SmartTranslateService SmartTranslateService
|
||||
|
||||
<OnlyAdmin>
|
||||
@attribute [PermissionRequired(nameof(Permissions.AdminUserEdit))]
|
||||
|
||||
<LazyLoader Load="Load">
|
||||
@if (User == null)
|
||||
{
|
||||
@@ -156,7 +157,6 @@
|
||||
|
||||
<PermissionEditor @ref="PermissionEditor" OnSave="SavePermissions" />
|
||||
</LazyLoader>
|
||||
</OnlyAdmin>
|
||||
|
||||
@code
|
||||
{
|
||||
|
||||
@@ -9,7 +9,8 @@
|
||||
@inject UserRepository UserRepository
|
||||
@inject SmartTranslateService SmartTranslateService
|
||||
|
||||
<OnlyAdmin>
|
||||
@attribute [PermissionRequired(nameof(Permissions.AdminUsers))]
|
||||
|
||||
<AdminSessionNavigation Index="0"/>
|
||||
|
||||
<div class="card">
|
||||
@@ -52,7 +53,6 @@
|
||||
</div>
|
||||
</LazyLoader>
|
||||
</div>
|
||||
</OnlyAdmin>
|
||||
|
||||
@code
|
||||
{
|
||||
|
||||
@@ -8,7 +8,8 @@
|
||||
@inject ToastService ToastService
|
||||
@inject UserService UserService
|
||||
|
||||
<OnlyAdmin>
|
||||
@attribute [PermissionRequired(nameof(Permissions.AdminNewUser))]
|
||||
|
||||
<div class="row mb-5">
|
||||
<div class="card card-body p-10">
|
||||
<label class="form-label">
|
||||
@@ -51,7 +52,6 @@
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</OnlyAdmin>
|
||||
|
||||
@code
|
||||
{
|
||||
|
||||
@@ -13,7 +13,8 @@
|
||||
@inject AlertService AlertService
|
||||
@inject ToastService ToastService
|
||||
|
||||
<OnlyAdmin>
|
||||
@attribute [PermissionRequired(nameof(Permissions.AdminUserSessions))]
|
||||
|
||||
<AdminSessionNavigation Index="1"/>
|
||||
|
||||
<div class="card">
|
||||
@@ -97,7 +98,6 @@
|
||||
</div>
|
||||
</LazyLoader>
|
||||
</div>
|
||||
</OnlyAdmin>
|
||||
|
||||
@code
|
||||
{
|
||||
|
||||
@@ -10,7 +10,8 @@
|
||||
@inject ServerRepository ServerRepository
|
||||
@inject DomainRepository DomainRepository
|
||||
|
||||
<OnlyAdmin>
|
||||
@attribute [PermissionRequired(nameof(Permissions.AdminUserView))]
|
||||
|
||||
<LazyLoader Load="Load">
|
||||
@if (User == null)
|
||||
{
|
||||
@@ -239,7 +240,6 @@ else
|
||||
</div>
|
||||
}
|
||||
</LazyLoader>
|
||||
</OnlyAdmin>
|
||||
|
||||
@code
|
||||
{
|
||||
|
||||
@@ -11,7 +11,8 @@
|
||||
@inject Repository<WebSpace> WebSpaceRepository
|
||||
@inject WebSpaceService WebSpaceService
|
||||
|
||||
<OnlyAdmin>
|
||||
@attribute [PermissionRequired(nameof(Permissions.AdminWebspaces))]
|
||||
|
||||
<AdminWebspacesNavigation Index="0"/>
|
||||
|
||||
<div class="card">
|
||||
@@ -66,7 +67,6 @@
|
||||
</LazyLoader>
|
||||
</div>
|
||||
</div>
|
||||
</OnlyAdmin>
|
||||
|
||||
@code
|
||||
{
|
||||
|
||||
@@ -9,7 +9,8 @@
|
||||
@inject UserRepository UserRepository
|
||||
@inject NavigationManager NavigationManager
|
||||
|
||||
<OnlyAdmin>
|
||||
@attribute [PermissionRequired(nameof(Permissions.AdminNewWebspace))]
|
||||
|
||||
<div class="card card-body p-10">
|
||||
<LazyLoader Load="Load">
|
||||
<SmartForm Model="Model" OnValidSubmit="OnValidSubmit">
|
||||
@@ -37,7 +38,6 @@
|
||||
</SmartForm>
|
||||
</LazyLoader>
|
||||
</div>
|
||||
</OnlyAdmin>
|
||||
|
||||
@code
|
||||
{
|
||||
|
||||
@@ -8,7 +8,8 @@
|
||||
@inject Repository<CloudPanel> CloudPanelRepository
|
||||
@inject NavigationManager NavigationManager
|
||||
|
||||
<OnlyAdmin>
|
||||
@attribute [PermissionRequired(nameof(Permissions.AdminWebspacesServerEdit))]
|
||||
|
||||
<LazyLoader Load="Load">
|
||||
@if (CloudPanel == null)
|
||||
{
|
||||
@@ -63,7 +64,6 @@
|
||||
</div>
|
||||
}
|
||||
</LazyLoader>
|
||||
</OnlyAdmin>
|
||||
|
||||
@code
|
||||
{
|
||||
|
||||
@@ -10,7 +10,8 @@
|
||||
@inject Repository<CloudPanel> CloudPanelRepository
|
||||
@inject WebSpaceService WebSpaceService
|
||||
|
||||
<OnlyAdmin>
|
||||
@attribute [PermissionRequired(nameof(Permissions.AdminWebspacesServers))]
|
||||
|
||||
<AdminWebspacesNavigation Index="1"/>
|
||||
|
||||
<div class="card">
|
||||
@@ -79,7 +80,6 @@
|
||||
</LazyLoader>
|
||||
</div>
|
||||
</div>
|
||||
</OnlyAdmin>
|
||||
|
||||
@code
|
||||
{
|
||||
|
||||
@@ -7,7 +7,8 @@
|
||||
@inject Repository<CloudPanel> CloudPanelRepository
|
||||
@inject NavigationManager NavigationManager
|
||||
|
||||
<OnlyAdmin>
|
||||
@attribute [PermissionRequired(nameof(Permissions.AdminWebspacesServerNew))]
|
||||
|
||||
<div class="card card-body p-10">
|
||||
<SmartForm Model="Model" OnValidSubmit="OnValidSubmit">
|
||||
<label class="form-label">
|
||||
@@ -41,7 +42,6 @@
|
||||
</div>
|
||||
</SmartForm>
|
||||
</div>
|
||||
</OnlyAdmin>
|
||||
|
||||
@code
|
||||
{
|
||||
|
||||
@@ -4,6 +4,7 @@
|
||||
@using Moonlight.App.Models.Forms
|
||||
@using Moonlight.App.Repositories.Domains
|
||||
@using Microsoft.EntityFrameworkCore
|
||||
@using Moonlight.App.Services.Sessions
|
||||
|
||||
@inject SubscriptionService SubscriptionService
|
||||
@inject DomainService DomainService
|
||||
@@ -11,6 +12,7 @@
|
||||
@inject SharedDomainRepository SharedDomainRepository
|
||||
@inject NavigationManager NavigationManager
|
||||
@inject SmartTranslateService SmartTranslateService
|
||||
@inject IdentityService IdentityService
|
||||
|
||||
<LazyLoader Load="Load">
|
||||
@if (!SharedDomains.Any())
|
||||
@@ -114,8 +116,7 @@
|
||||
|
||||
@code
|
||||
{
|
||||
[CascadingParameter]
|
||||
public User User { get; set; }
|
||||
|
||||
|
||||
private SharedDomain[] SharedDomains;
|
||||
|
||||
@@ -130,12 +131,12 @@
|
||||
Model = new();
|
||||
|
||||
await lazyLoader.SetText(SmartTranslateService.Translate("Loading your subscription"));
|
||||
Subscription = await SubscriptionService.GetActiveSubscription(User);
|
||||
Subscription = await SubscriptionService.GetActiveSubscription(IdentityService.User);
|
||||
|
||||
AllowOrder = DomainRepository
|
||||
.Get()
|
||||
.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");
|
||||
SharedDomains = SharedDomainRepository.Get().ToArray();
|
||||
@@ -146,9 +147,9 @@
|
||||
if (DomainRepository
|
||||
.Get()
|
||||
.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}");
|
||||
}
|
||||
|
||||
@@ -7,11 +7,13 @@
|
||||
@using Moonlight.App.Repositories
|
||||
@using Moonlight.App.Repositories.Domains
|
||||
@using Markdig
|
||||
@using Moonlight.App.Services.Sessions
|
||||
|
||||
@inject ServerRepository ServerRepository
|
||||
@inject Repository<WebSpace> WebSpaceRepository
|
||||
@inject DomainRepository DomainRepository
|
||||
@inject NewsEntryRepository NewsEntryRepository
|
||||
@inject IdentityService IdentityService
|
||||
|
||||
<LazyLoader Load="Load">
|
||||
@if (NewsEntries.Any())
|
||||
@@ -243,9 +245,6 @@
|
||||
|
||||
@code
|
||||
{
|
||||
[CascadingParameter]
|
||||
public User User { get; set; }
|
||||
|
||||
private int ServerCount = 0;
|
||||
private int DomainCount = 0;
|
||||
private int WebSpaceCount = 0;
|
||||
@@ -258,17 +257,17 @@
|
||||
ServerCount = ServerRepository
|
||||
.Get()
|
||||
.Include(x => x.Owner)
|
||||
.Count(x => x.Owner.Id == User.Id);
|
||||
.Count(x => x.Owner.Id == IdentityService.User.Id);
|
||||
|
||||
DomainCount = DomainRepository
|
||||
.Get()
|
||||
.Include(x => x.Owner)
|
||||
.Count(x => x.Owner.Id == User.Id);
|
||||
.Count(x => x.Owner.Id == IdentityService.User.Id);
|
||||
|
||||
WebSpaceCount = WebSpaceRepository
|
||||
.Get()
|
||||
.Include(x => x.Owner)
|
||||
.Count(x => x.Owner.Id == User.Id);
|
||||
.Count(x => x.Owner.Id == IdentityService.User.Id);
|
||||
|
||||
NewsEntries = NewsEntryRepository.Get().ToList();
|
||||
|
||||
|
||||
@@ -4,13 +4,15 @@
|
||||
@using Moonlight.App.Database.Entities
|
||||
@using Moonlight.App.Repositories
|
||||
@using Moonlight.App.Services
|
||||
@using Moonlight.App.Services.Sessions
|
||||
|
||||
@inject Repository<User> UserRepository
|
||||
@inject SmartTranslateService SmartTranslateService
|
||||
@inject IdentityService IdentityService
|
||||
|
||||
<ProfileNavigation Index="1"/>
|
||||
|
||||
@if (User.DiscordId == 0)
|
||||
@if (IdentityService.User.DiscordId == 0)
|
||||
{
|
||||
<div class="row">
|
||||
<div class="col">
|
||||
@@ -64,13 +66,12 @@ else
|
||||
|
||||
@code
|
||||
{
|
||||
[CascadingParameter]
|
||||
public User User { get; set; }
|
||||
|
||||
|
||||
private async Task RemoveLink()
|
||||
{
|
||||
User.DiscordId = 0;
|
||||
UserRepository.Update(User);
|
||||
IdentityService.User.DiscordId = 0;
|
||||
UserRepository.Update(IdentityService.User);
|
||||
|
||||
await InvokeAsync(StateHasChanged);
|
||||
}
|
||||
|
||||
@@ -7,15 +7,17 @@
|
||||
@using Mappy.Net
|
||||
@using Moonlight.App.Exceptions
|
||||
@using Moonlight.App.Helpers
|
||||
@using Moonlight.App.Services.Sessions
|
||||
|
||||
@inject UserRepository UserRepository
|
||||
@inject Repository<User> UserRepository
|
||||
@inject IdentityService IdentityService
|
||||
|
||||
<ProfileNavigation Index="0" />
|
||||
|
||||
<LazyLoader Load="Load">
|
||||
<SmartForm OnValidSubmit="Save" Model="Model">
|
||||
<div class="card mb-5 mb-xl-10">
|
||||
<div class="card-body p-9 @(CurrentUser.StreamerMode ? "blur" : "")">
|
||||
<div class="card-body p-9 @(IdentityService.User.StreamerMode ? "blur" : "")">
|
||||
<div class="row">
|
||||
<div class="col-lg-6 fv-row fv-plugins-icon-container">
|
||||
<div class="mb-3">
|
||||
@@ -78,13 +80,9 @@
|
||||
{
|
||||
private UserDataModel Model = new();
|
||||
|
||||
[CascadingParameter]
|
||||
public User CurrentUser { get; set; }
|
||||
|
||||
|
||||
private Task Load(LazyLoader loader)
|
||||
{
|
||||
Model = Mapper.Map<UserDataModel>(CurrentUser);
|
||||
Model = Mapper.Map<UserDataModel>(IdentityService.User);
|
||||
|
||||
return Task.CompletedTask;
|
||||
}
|
||||
@@ -98,15 +96,15 @@
|
||||
.Get()
|
||||
.FirstOrDefault(x => x.Email == Model.Email);
|
||||
|
||||
if (userWithThatEmail != null && CurrentUser.Id != userWithThatEmail.Id)
|
||||
if (userWithThatEmail != null && IdentityService.User.Id != userWithThatEmail.Id)
|
||||
{
|
||||
Logger.Warn($"A user tried to lock another user out by changing the email. Email: {Model.Email}", "security");
|
||||
throw new DisplayException("A user with that email does already exist");
|
||||
}
|
||||
|
||||
CurrentUser = Mapper.Map(CurrentUser, Model);
|
||||
var user = Mapper.Map(IdentityService.User, Model);
|
||||
|
||||
UserRepository.Update(CurrentUser);
|
||||
UserRepository.Update(user);
|
||||
|
||||
return Task.CompletedTask;
|
||||
}
|
||||
|
||||
@@ -8,6 +8,7 @@
|
||||
@using Mappy.Net
|
||||
@using Moonlight.App.Models.Forms
|
||||
@using Moonlight.App.Repositories
|
||||
@using Moonlight.App.Services.Sessions
|
||||
|
||||
@inject TotpService TotpService
|
||||
@inject UserService UserService
|
||||
@@ -15,6 +16,7 @@
|
||||
@inject ModalService ModalService
|
||||
@inject Repository<User> UserRepository
|
||||
@inject SmartTranslateService SmartTranslateService
|
||||
@inject IdentityService IdentityService
|
||||
|
||||
<ProfileNavigation Index="2"/>
|
||||
|
||||
@@ -31,7 +33,7 @@
|
||||
<TL>2fa adds another layer of security to your account. You have to enter a 6 digit code in order to login.</TL>
|
||||
</p>
|
||||
<div class="d-flex justify-content-center">
|
||||
@if (User.TotpEnabled)
|
||||
@if (IdentityService.User.TotpEnabled)
|
||||
{
|
||||
<WButton Text="@(SmartTranslateService.Translate("Disable"))"
|
||||
WorkingText=""
|
||||
@@ -110,9 +112,9 @@
|
||||
</h2>
|
||||
</div>
|
||||
<div class="modal-body fs-6">
|
||||
@if (!User.TotpEnabled)
|
||||
@if (!IdentityService.User.TotpEnabled)
|
||||
{
|
||||
if (string.IsNullOrEmpty(User.TotpSecret))
|
||||
if (string.IsNullOrEmpty(IdentityService.User.TotpSecret))
|
||||
{
|
||||
<p>
|
||||
<TL>Make sure you have installed one of the following apps on your smartphone and press continue</TL>
|
||||
@@ -147,7 +149,7 @@
|
||||
|
||||
var qrCodeData = qrGenerator.CreateQrCode
|
||||
(
|
||||
$"otpauth://totp/{Uri.EscapeDataString(User.Email)}?secret={User.TotpSecret}&issuer={Uri.EscapeDataString("Moonlight")}",
|
||||
$"otpauth://totp/{Uri.EscapeDataString(IdentityService.User.Email)}?secret={IdentityService.User.TotpSecret}&issuer={Uri.EscapeDataString("Moonlight")}",
|
||||
QRCodeGenerator.ECCLevel.Q
|
||||
);
|
||||
|
||||
@@ -179,8 +181,7 @@
|
||||
|
||||
@code
|
||||
{
|
||||
[CascadingParameter]
|
||||
public User User { get; set; }
|
||||
|
||||
|
||||
private string TwoFactorCode = "";
|
||||
private string Password = "";
|
||||
@@ -188,7 +189,7 @@
|
||||
|
||||
protected override void OnParametersSet()
|
||||
{
|
||||
UserModel = Mapper.Map<UserPreferencesDataModel>(User);
|
||||
UserModel = Mapper.Map<UserPreferencesDataModel>(IdentityService.User);
|
||||
}
|
||||
|
||||
private async Task StartTwoFactorWizard()
|
||||
@@ -219,14 +220,14 @@
|
||||
|
||||
private async Task ChangePassword()
|
||||
{
|
||||
await UserService.ChangePassword(User, Password);
|
||||
await UserService.ChangePassword(IdentityService.User, Password);
|
||||
NavigationManager.NavigateTo(NavigationManager.Uri, true);
|
||||
}
|
||||
|
||||
private async Task SavePreferences()
|
||||
{
|
||||
User = Mapper.Map(User, UserModel);
|
||||
UserRepository.Update(User);
|
||||
var user = Mapper.Map(IdentityService.User, UserModel);
|
||||
UserRepository.Update(user);
|
||||
await InvokeAsync(StateHasChanged);
|
||||
NavigationManager.NavigateTo(NavigationManager.Uri, true);
|
||||
}
|
||||
|
||||
@@ -7,6 +7,7 @@
|
||||
@using Moonlight.App.Repositories
|
||||
@using Moonlight.App.Services.Interop
|
||||
@using Markdig
|
||||
@using Moonlight.App.Services.Sessions
|
||||
|
||||
@inject BillingService BillingService
|
||||
@inject Repository<Subscription> SubscriptionRepository
|
||||
@@ -14,6 +15,7 @@
|
||||
@inject PopupService PopupService
|
||||
@inject SubscriptionService SubscriptionService
|
||||
@inject SmartTranslateService SmartTranslateService
|
||||
@inject IdentityService IdentityService
|
||||
|
||||
<ProfileNavigation Index="3"/>
|
||||
|
||||
@@ -80,7 +82,7 @@
|
||||
{
|
||||
<div class="card">
|
||||
<div class="card-body">
|
||||
@if ((User.SubscriptionExpires - DateTime.UtcNow).TotalDays < 5)
|
||||
@if ((IdentityService.User.SubscriptionExpires - DateTime.UtcNow).TotalDays < 5)
|
||||
{
|
||||
<div class="notice d-flex bg-light-warning rounded border-warning border mb-12 p-6">
|
||||
<div class="d-flex flex-stack flex-grow-1 ">
|
||||
@@ -91,7 +93,7 @@
|
||||
<div class="fs-6 text-gray-700 ">
|
||||
<TL>Your subscription expires soon</TL>
|
||||
<span>
|
||||
@(Math.Round((User.SubscriptionExpires - DateTime.UtcNow).TotalDays)) <TL>left</TL>
|
||||
@(Math.Round((IdentityService.User.SubscriptionExpires - DateTime.UtcNow).TotalDays)) <TL>left</TL>
|
||||
</span>
|
||||
</div>
|
||||
</div>
|
||||
@@ -101,7 +103,7 @@
|
||||
<div class="row">
|
||||
<div class="col-lg-7">
|
||||
<h3 class="mb-2">
|
||||
<TL>Active until</TL> @(Formatter.FormatDateOnly(User.SubscriptionExpires))
|
||||
<TL>Active until</TL> @(Formatter.FormatDateOnly(IdentityService.User.SubscriptionExpires))
|
||||
</h3>
|
||||
<p class="fs-6 text-gray-600 fw-semibold mb-6 mb-lg-15">
|
||||
<TL>We will send you a email upon subscription expiration</TL>
|
||||
@@ -134,8 +136,7 @@
|
||||
|
||||
@code
|
||||
{
|
||||
[CascadingParameter]
|
||||
public User User { get; set; }
|
||||
|
||||
|
||||
private Subscription[] Subscriptions;
|
||||
private Subscription? CurrentSubscription;
|
||||
@@ -144,21 +145,21 @@
|
||||
private async Task Load(LazyLoader lazyLoader)
|
||||
{
|
||||
Subscriptions = SubscriptionRepository.Get().ToArray();
|
||||
CurrentSubscription = await SubscriptionService.GetActiveSubscription(User);
|
||||
CurrentSubscription = await SubscriptionService.GetActiveSubscription(IdentityService.User);
|
||||
}
|
||||
|
||||
private async Task Cancel()
|
||||
{
|
||||
if (await AlertService.ConfirmMath())
|
||||
{
|
||||
await SubscriptionService.CancelSubscription(User);
|
||||
await SubscriptionService.CancelSubscription(IdentityService.User);
|
||||
await LazyLoader.Reload();
|
||||
}
|
||||
}
|
||||
|
||||
private async Task StartCheckout(Subscription subscription)
|
||||
{
|
||||
var url = await BillingService.StartCheckout(User, subscription);
|
||||
var url = await BillingService.StartCheckout(IdentityService.User, subscription);
|
||||
|
||||
await PopupService.ShowCentered(
|
||||
url,
|
||||
|
||||
@@ -20,6 +20,7 @@
|
||||
@inject NavigationManager NavigationManager
|
||||
@inject DynamicBackgroundService DynamicBackgroundService
|
||||
@inject SmartTranslateService SmartTranslateService
|
||||
@inject IdentityService IdentityService
|
||||
|
||||
@implements IDisposable
|
||||
|
||||
@@ -143,8 +144,7 @@
|
||||
[Parameter]
|
||||
public string ServerUuid { get; set; }
|
||||
|
||||
[CascadingParameter]
|
||||
public User User { get; set; }
|
||||
|
||||
|
||||
[Parameter]
|
||||
public string? Route { get; set; }
|
||||
@@ -209,7 +209,7 @@
|
||||
|
||||
if (CurrentServer != null)
|
||||
{
|
||||
if (CurrentServer.Owner.Id != User!.Id && !User.Admin)
|
||||
if (CurrentServer.Owner.Id != IdentityService.User.Id && !IdentityService.User.Admin)
|
||||
CurrentServer = null;
|
||||
}
|
||||
|
||||
|
||||
@@ -5,10 +5,12 @@
|
||||
@using Moonlight.App.Services
|
||||
@using Moonlight.App.ApiClients.Wings
|
||||
@using Moonlight.App.Helpers.Wings
|
||||
@using Moonlight.App.Services.Sessions
|
||||
|
||||
@inject WingsApiHelper WingsApiHelper
|
||||
@inject WingsJwtHelper WingsJwtHelper
|
||||
@inject ConfigService ConfigService
|
||||
@inject IdentityService IdentityService
|
||||
|
||||
<FileManager Access="FileAccess"></FileManager>
|
||||
|
||||
@@ -17,13 +19,10 @@
|
||||
[CascadingParameter]
|
||||
public Server CurrentServer { get; set; }
|
||||
|
||||
[CascadingParameter]
|
||||
public User User { get; set; }
|
||||
|
||||
private FileAccess FileAccess;
|
||||
|
||||
protected override void OnInitialized()
|
||||
{
|
||||
FileAccess = new WingsFileAccess(WingsApiHelper, WingsJwtHelper, CurrentServer, ConfigService, User);
|
||||
FileAccess = new WingsFileAccess(WingsApiHelper, WingsJwtHelper, CurrentServer, ConfigService, IdentityService.User);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -3,8 +3,10 @@
|
||||
@using Moonlight.App.Helpers
|
||||
@using Moonlight.App.Helpers.Wings
|
||||
@using Moonlight.App.Helpers.Wings.Enums
|
||||
@using Moonlight.App.Services.Sessions
|
||||
|
||||
@inject SmartTranslateService TranslationService
|
||||
@inject IdentityService IdentityService
|
||||
|
||||
<div class="align-items-center">
|
||||
<div class="row">
|
||||
@@ -53,12 +55,12 @@
|
||||
<div class="row align-items-center">
|
||||
<div class="col fs-5">
|
||||
<span class="fw-bold"><TL>Shared IP</TL>:</span>
|
||||
<span class="ms-1 text-muted @(User.StreamerMode ? "blur" : "")">@($"{CurrentServer.Node.Fqdn}:{CurrentServer.MainAllocation?.Port ?? 0}")</span>
|
||||
<span class="ms-1 text-muted @(IdentityService.User.StreamerMode ? "blur" : "")">@($"{CurrentServer.Node.Fqdn}:{CurrentServer.MainAllocation?.Port ?? 0}")</span>
|
||||
</div>
|
||||
<div class="col fs-5">
|
||||
<span class="fw-bold"><TL>Server ID</TL>:</span>
|
||||
<span class="ms-1 text-muted">
|
||||
@if (User.Admin)
|
||||
@if (IdentityService.User.Admin)
|
||||
{
|
||||
<a href="/admin/servers/view/@(CurrentServer.Id)">@(CurrentServer.Id)</a>
|
||||
}
|
||||
@@ -196,8 +198,7 @@
|
||||
[CascadingParameter]
|
||||
public Server CurrentServer { get; set; }
|
||||
|
||||
[CascadingParameter]
|
||||
public User User { get; set; }
|
||||
|
||||
|
||||
[CascadingParameter]
|
||||
public WingsConsole Console { get; set; }
|
||||
|
||||
@@ -7,6 +7,7 @@
|
||||
@using Moonlight.App.Repositories.Servers
|
||||
@using Microsoft.EntityFrameworkCore
|
||||
@using Moonlight.App.Exceptions
|
||||
@using Moonlight.App.Services.Sessions
|
||||
|
||||
@inject SubscriptionService SubscriptionService
|
||||
@inject ImageRepository ImageRepository
|
||||
@@ -15,6 +16,7 @@
|
||||
@inject ServerRepository ServerRepository
|
||||
@inject NavigationManager NavigationManager
|
||||
@inject ServerService ServerService
|
||||
@inject IdentityService IdentityService
|
||||
|
||||
<LazyLoader Load="Load">
|
||||
@if (DeployNode == null)
|
||||
@@ -172,8 +174,7 @@
|
||||
|
||||
@code
|
||||
{
|
||||
[CascadingParameter]
|
||||
public User User { get; set; }
|
||||
|
||||
|
||||
private Node? DeployNode;
|
||||
private Subscription? Subscription;
|
||||
@@ -190,7 +191,7 @@
|
||||
Model = new();
|
||||
|
||||
await lazyLoader.SetText(SmartTranslateService.Translate("Loading your subscription"));
|
||||
Subscription = await SubscriptionService.GetActiveSubscription(User);
|
||||
Subscription = await SubscriptionService.GetActiveSubscription(IdentityService.User);
|
||||
|
||||
await lazyLoader.SetText(SmartTranslateService.Translate("Searching for deploy node"));
|
||||
DeployNode = await SmartDeployService.GetNode();
|
||||
@@ -200,7 +201,7 @@
|
||||
|
||||
foreach (var image in images)
|
||||
{
|
||||
var limit = await SubscriptionService.GetLimit(User, "image." + image.Id);
|
||||
var limit = await SubscriptionService.GetLimit(IdentityService.User, "image." + image.Id);
|
||||
|
||||
if (limit.Amount > 0)
|
||||
{
|
||||
@@ -208,7 +209,7 @@
|
||||
.Get()
|
||||
.Include(x => x.Owner)
|
||||
.Include(x => x.Image)
|
||||
.Where(x => x.Owner.Id == User.Id)
|
||||
.Where(x => x.Owner.Id == IdentityService.User.Id)
|
||||
.Count(x => x.Image.Id == image.Id);
|
||||
|
||||
Images.Add(image, limit);
|
||||
@@ -219,7 +220,7 @@
|
||||
|
||||
private async Task OnValidSubmit()
|
||||
{
|
||||
var limit = await SubscriptionService.GetLimit(User, "image." + Model.Image.Id);
|
||||
var limit = await SubscriptionService.GetLimit(IdentityService.User, "image." + Model.Image.Id);
|
||||
|
||||
if (limit.Amount > 0)
|
||||
{
|
||||
@@ -227,7 +228,7 @@
|
||||
.Get()
|
||||
.Include(x => x.Owner)
|
||||
.Include(x => x.Image)
|
||||
.Where(x => x.Owner.Id == User.Id)
|
||||
.Where(x => x.Owner.Id == IdentityService.User.Id)
|
||||
.Count(x => x.Image.Id == Model.Image.Id);
|
||||
|
||||
if (serversCount < limit.Amount)
|
||||
@@ -241,7 +242,7 @@
|
||||
cpu,
|
||||
memory,
|
||||
disk,
|
||||
User,
|
||||
IdentityService.User,
|
||||
Model.Image,
|
||||
DeployNode
|
||||
);
|
||||
|
||||
@@ -5,6 +5,7 @@
|
||||
@using Moonlight.App.Models.Misc
|
||||
@using Moonlight.App.Repositories
|
||||
@using Moonlight.App.Services
|
||||
@using Moonlight.App.Services.Sessions
|
||||
@using Newtonsoft.Json
|
||||
|
||||
@inject Repository<Server> ServerRepository
|
||||
@@ -12,6 +13,7 @@
|
||||
@inject SmartTranslateService SmartTranslateService
|
||||
@inject IServiceScopeFactory ServiceScopeFactory
|
||||
@inject IJSRuntime JsRuntime
|
||||
@inject IdentityService IdentityService
|
||||
|
||||
<LazyLoader @ref="LazyLoader" Load="Load">
|
||||
<div class="mx-auto">
|
||||
@@ -119,7 +121,7 @@
|
||||
<span class="card-text fs-6">
|
||||
@(Math.Round(server.Memory / 1024D, 2)) GB / @(Math.Round(server.Disk / 1024D, 2)) GB / @(server.Node.Name) <span class="text-gray-700">- @(server.Image.Name)</span>
|
||||
</span>
|
||||
<div class="card-text my-1 fs-6 fw-bold @(User.StreamerMode ? "blur" : "")">
|
||||
<div class="card-text my-1 fs-6 fw-bold @(IdentityService.User.StreamerMode ? "blur" : "")">
|
||||
@(server.Node.Fqdn):@(server.MainAllocation.Port)
|
||||
</div>
|
||||
<div class="card-text fs-6">
|
||||
@@ -186,8 +188,7 @@
|
||||
|
||||
@code
|
||||
{
|
||||
[CascadingParameter]
|
||||
public User User { get; set; }
|
||||
|
||||
|
||||
private Server[] AllServers;
|
||||
private LazyLoader LazyLoader;
|
||||
@@ -204,12 +205,12 @@
|
||||
.Include(x => x.MainAllocation)
|
||||
.Include(x => x.Node)
|
||||
.Include(x => x.Image)
|
||||
.Where(x => x.Owner.Id == User.Id)
|
||||
.Where(x => x.Owner.Id == IdentityService.User.Id)
|
||||
.OrderBy(x => x.Name)
|
||||
.ToArray();
|
||||
|
||||
|
||||
if (string.IsNullOrEmpty(User.ServerListLayoutJson))
|
||||
if (string.IsNullOrEmpty(IdentityService.User.ServerListLayoutJson))
|
||||
{
|
||||
ServerGroups.Add(new()
|
||||
{
|
||||
@@ -220,7 +221,7 @@
|
||||
else
|
||||
{
|
||||
ServerGroups = (JsonConvert.DeserializeObject<ServerGroup[]>(
|
||||
User.ServerListLayoutJson) ?? Array.Empty<ServerGroup>()).ToList();
|
||||
IdentityService.User.ServerListLayoutJson) ?? Array.Empty<ServerGroup>()).ToList();
|
||||
|
||||
await CheckServerGroups();
|
||||
}
|
||||
@@ -282,8 +283,8 @@
|
||||
|
||||
await CheckServerGroups();
|
||||
|
||||
User.ServerListLayoutJson = json;
|
||||
UserRepository.Update(User);
|
||||
IdentityService.User.ServerListLayoutJson = json;
|
||||
UserRepository.Update(IdentityService.User);
|
||||
|
||||
await LazyLoader.Reload();
|
||||
}
|
||||
|
||||
@@ -5,10 +5,12 @@
|
||||
@using Moonlight.App.Services.SupportChat
|
||||
@using System.Text.RegularExpressions
|
||||
@using Moonlight.App.Services.Files
|
||||
@using Moonlight.App.Services.Sessions
|
||||
|
||||
@inject ResourceService ResourceService
|
||||
@inject SupportChatClientService ClientService
|
||||
@inject SmartTranslateService SmartTranslateService
|
||||
@inject IdentityService IdentityService
|
||||
|
||||
@implements IDisposable
|
||||
|
||||
@@ -20,7 +22,7 @@
|
||||
<div class="scroll-y me-n5 pe-5" style="max-height: 55vh; display: flex; flex-direction: column-reverse;">
|
||||
@foreach (var message in Messages.ToArray())
|
||||
{
|
||||
if (message.Sender == null || message.Sender.Id != User.Id)
|
||||
if (message.Sender == null || message.Sender.Id != IdentityService.User.Id)
|
||||
{
|
||||
<div class="d-flex justify-content-start mb-10 ">
|
||||
<div class="d-flex flex-column align-items-start">
|
||||
@@ -199,9 +201,6 @@
|
||||
|
||||
@code
|
||||
{
|
||||
[CascadingParameter]
|
||||
public User User { get; set; }
|
||||
|
||||
private List<SupportChatMessage> Messages = new();
|
||||
private string[] Typing = Array.Empty<string>();
|
||||
|
||||
|
||||
@@ -4,10 +4,11 @@
|
||||
@using Moonlight.App.Services
|
||||
@using Moonlight.Shared.Components.WebsiteControl
|
||||
@using Microsoft.EntityFrameworkCore
|
||||
@using Moonlight.App.Services.Interop
|
||||
@using Moonlight.App.Services.Sessions
|
||||
|
||||
@inject Repository<WebSpace> WebSpaceRepository
|
||||
@inject WebSpaceService WebSpaceService
|
||||
@inject IdentityService IdentityService
|
||||
|
||||
<LazyLoader Load="Load">
|
||||
@if (CurrentWebspace == null)
|
||||
@@ -97,9 +98,6 @@
|
||||
[Parameter]
|
||||
public string? Route { get; set; }
|
||||
|
||||
[CascadingParameter]
|
||||
public User User { get; set; }
|
||||
|
||||
private WebSpace? CurrentWebspace;
|
||||
private bool HostOnline = false;
|
||||
|
||||
@@ -113,7 +111,7 @@
|
||||
|
||||
if (CurrentWebspace != null)
|
||||
{
|
||||
if (CurrentWebspace.Owner.Id != User!.Id && !User.Admin)
|
||||
if (CurrentWebspace.Owner.Id != IdentityService.User.Id && !IdentityService.User.Admin)
|
||||
CurrentWebspace = null;
|
||||
}
|
||||
|
||||
|
||||
@@ -4,6 +4,7 @@
|
||||
@using Moonlight.App.Models.Forms
|
||||
@using Moonlight.App.Repositories
|
||||
@using Microsoft.EntityFrameworkCore
|
||||
@using Moonlight.App.Services.Sessions
|
||||
|
||||
@inject SubscriptionService SubscriptionService
|
||||
@inject WebSpaceService WebSpaceService
|
||||
@@ -11,6 +12,7 @@
|
||||
@inject SmartDeployService SmartDeployService
|
||||
@inject SmartTranslateService SmartTranslateService
|
||||
@inject NavigationManager NavigationManager
|
||||
@inject IdentityService IdentityService
|
||||
|
||||
<LazyLoader Load="Load">
|
||||
@if (CloudPanel == null)
|
||||
@@ -110,8 +112,7 @@
|
||||
|
||||
@code
|
||||
{
|
||||
[CascadingParameter]
|
||||
public User User { get; set; }
|
||||
|
||||
|
||||
private Subscription? Subscription;
|
||||
private CloudPanel? CloudPanel;
|
||||
@@ -125,7 +126,7 @@
|
||||
Model = new();
|
||||
|
||||
await lazyLoader.SetText(SmartTranslateService.Translate("Loading your subscription"));
|
||||
Subscription = await SubscriptionService.GetActiveSubscription(User);
|
||||
Subscription = await SubscriptionService.GetActiveSubscription(IdentityService.User);
|
||||
|
||||
await lazyLoader.SetText(SmartTranslateService.Translate("Searching for deploy web host"));
|
||||
CloudPanel = await SmartDeployService.GetCloudPanel();
|
||||
@@ -133,7 +134,7 @@
|
||||
AllowOrder = WebSpaceRepository
|
||||
.Get()
|
||||
.Include(x => x.Owner)
|
||||
.Count(x => x.Owner.Id == User.Id) < (await SubscriptionService.GetLimit(User, "websites")).Amount;
|
||||
.Count(x => x.Owner.Id == IdentityService.User.Id) < (await SubscriptionService.GetLimit(IdentityService.User, "websites")).Amount;
|
||||
}
|
||||
|
||||
private async Task OnValidSubmit()
|
||||
@@ -141,9 +142,9 @@
|
||||
if (WebSpaceRepository
|
||||
.Get()
|
||||
.Include(x => x.Owner)
|
||||
.Count(x => x.Owner.Id == User.Id) < (await SubscriptionService.GetLimit(User, "websites")).Amount)
|
||||
.Count(x => x.Owner.Id == IdentityService.User.Id) < (await SubscriptionService.GetLimit(IdentityService.User, "websites")).Amount)
|
||||
{
|
||||
var webSpace = await WebSpaceService.Create(Model.BaseDomain, User, CloudPanel);
|
||||
var webSpace = await WebSpaceService.Create(Model.BaseDomain, IdentityService.User, CloudPanel);
|
||||
|
||||
NavigationManager.NavigateTo($"/webspace/{webSpace.Id}");
|
||||
}
|
||||
|
||||
@@ -2,8 +2,10 @@
|
||||
@using Moonlight.App.Database.Entities
|
||||
@using Moonlight.App.Repositories
|
||||
@using Microsoft.EntityFrameworkCore
|
||||
@using Moonlight.App.Services.Sessions
|
||||
|
||||
@inject Repository<WebSpace> WebSpaceRepository
|
||||
@inject IdentityService IdentityService
|
||||
|
||||
<LazyLoader Load="Load">
|
||||
@if (WebSpaces.Any())
|
||||
@@ -50,8 +52,7 @@
|
||||
|
||||
@code
|
||||
{
|
||||
[CascadingParameter]
|
||||
public User User { get; set; }
|
||||
|
||||
|
||||
private WebSpace[] WebSpaces;
|
||||
|
||||
@@ -61,7 +62,7 @@
|
||||
.Get()
|
||||
.Include(x => x.Owner)
|
||||
.Include(x => x.CloudPanel)
|
||||
.Where(x => x.Owner.Id == User.Id)
|
||||
.Where(x => x.Owner.Id == IdentityService.User.Id)
|
||||
.ToArray();
|
||||
|
||||
return Task.CompletedTask;
|
||||
|
||||
@@ -9,7 +9,6 @@
|
||||
@using Moonlight
|
||||
@using Moonlight.App.Perms
|
||||
@using Moonlight.Shared.Components
|
||||
@using Moonlight.Shared.Components.StateLogic
|
||||
@using Moonlight.Shared.Components.Alerts
|
||||
@using Moonlight.Shared.Components.Forms
|
||||
@using Moonlight.Shared.Components.Partials
|
||||
|
||||
Reference in New Issue
Block a user