diff --git a/src/Elektrifikatsiya/Elektrifikatsiya/App.razor b/src/Elektrifikatsiya/Elektrifikatsiya/App.razor index cf7da0a..8286e30 100644 --- a/src/Elektrifikatsiya/Elektrifikatsiya/App.razor +++ b/src/Elektrifikatsiya/Elektrifikatsiya/App.razor @@ -1,63 +1,64 @@ - - - - - - -

Sorry, there's nothing at this address.

-
-
- - - +@using Blazorise.Components + + + + + + +

Sorry, there's nothing at this address.

+
+
+ + +
@code { - private Theme theme = new() - { - BarOptions = new() - { - HorizontalHeight = "72px", - DarkColors = new() - { - ItemColorOptions = new() - { - ActiveBackgroundColor = "#1a237e", - ActiveColor = "#1a237e", - HoverColor = "#1a237e", - } + private Theme theme = new() + { + BarOptions = new() + { + HorizontalHeight = "72px", + DarkColors = new() + { + ItemColorOptions = new() + { + ActiveBackgroundColor = "#1a237e", + ActiveColor = "#1a237e", + HoverColor = "#1a237e", + } - } - }, - ColorOptions = new() - { - Primary = "#1a237e", - Secondary = "#A65529", - Success = "#23C02E", - Info = "#9BD8FE", - Warning = "#F8B86C", - Danger = "#F95741", - Light = "#F0F0F0", - Dark = "#535353", - }, - BackgroundOptions = new() - { - Primary = "#1a237e", - Secondary = "#A65529", - Success = "#23C02E", - Info = "#9BD8FE", - Warning = "#F8B86C", - Danger = "#F95741", - Light = "#F0F0F0", - Dark = "#535353", - }, - InputOptions = new() - { - CheckColor = "#1a237e", - }, - TextColorOptions = new() - { - Dark = "#000000", - Primary = "#1a237e" - } - }; + } + }, + ColorOptions = new() + { + Primary = "#1a237e", + Secondary = "#A65529", + Success = "#23C02E", + Info = "#9BD8FE", + Warning = "#F8B86C", + Danger = "#F95741", + Light = "#F0F0F0", + Dark = "#535353", + }, + BackgroundOptions = new() + { + Primary = "#1a237e", + Secondary = "#A65529", + Success = "#23C02E", + Info = "#9BD8FE", + Warning = "#F8B86C", + Danger = "#F95741", + Light = "#F0F0F0", + Dark = "#535353", + }, + InputOptions = new() + { + CheckColor = "#1a237e", + }, + TextColorOptions = new() + { + Dark = "#000000", + Primary = "#1a237e" + } + }; } \ No newline at end of file diff --git a/src/Elektrifikatsiya/Elektrifikatsiya/Models/Device.cs b/src/Elektrifikatsiya/Elektrifikatsiya/Models/Device.cs index 0176b78..41f3f38 100644 --- a/src/Elektrifikatsiya/Elektrifikatsiya/Models/Device.cs +++ b/src/Elektrifikatsiya/Elektrifikatsiya/Models/Device.cs @@ -7,10 +7,13 @@ public class Device { [Key] public string Key { get; private set; } + [Required] - public string Name { get; private set; } = string.Empty; + public string Name { get; private set; } + [Required] public IPAddress Address { get; private set; } + public int PowerUsage { get; set; } public string User { get; set; } public string Room { get; set; } diff --git a/src/Elektrifikatsiya/Elektrifikatsiya/Services/IAuthenticationService.cs b/src/Elektrifikatsiya/Elektrifikatsiya/Services/IAuthenticationService.cs index 2ccc8ec..611a36a 100644 --- a/src/Elektrifikatsiya/Elektrifikatsiya/Services/IAuthenticationService.cs +++ b/src/Elektrifikatsiya/Elektrifikatsiya/Services/IAuthenticationService.cs @@ -15,7 +15,9 @@ public interface IAuthenticationService /// /// Registers a new user. /// - /// The E-mail address of the user. + /// The name address of the user. + /// The password of the user. + /// The default role of the user. /// A to . Task RegisterUserAsync(string name, string password, Role role); @@ -23,7 +25,8 @@ public interface IAuthenticationService /// /// Logs a user in. /// - /// The E-mail address of the user. + /// The name of the user. + /// The password of the user. /// A to . Task LoginUserAsync(string name, string password); @@ -36,14 +39,13 @@ public interface IAuthenticationService /// /// Deletes the current user. /// - /// The deletion token. - /// A to and a that indicates if the operation was successful. + /// A to . Task DeleteUserAsync(); /// /// Checks if a user exists. /// - /// The E-mail address of the user. + /// The name address of the user. /// A to and a that indicates if the user exists. Task> UserExistsAsync(string name); diff --git a/src/Elektrifikatsiya/Elektrifikatsiya/Utilities/TokenGenerator.cs b/src/Elektrifikatsiya/Elektrifikatsiya/Utilities/TokenGenerator.cs index 99faf60..17e6a02 100644 --- a/src/Elektrifikatsiya/Elektrifikatsiya/Utilities/TokenGenerator.cs +++ b/src/Elektrifikatsiya/Elektrifikatsiya/Utilities/TokenGenerator.cs @@ -2,11 +2,24 @@ public static class TokenGenerator { + /// + /// Creates secure token and uses an UID to make it unique. + /// + /// The type of the token. + /// The UID of a user. + /// The length of the token. + /// public static string GenerateToken(string tokenType, int uid = 0, int length = 128) { return tokenType + "-" + SecureStringGenerator.CreateCryptographicRandomString(length, uid); } + /// + /// Checks if a token is valid. + /// + /// The token to validate. + /// The type the token should have. + /// public static bool ValidateToken(string? token, string tokenType) { if (token is null)