mirror of
https://github.com/Stefan-5422/-T5-Elektrifikatsiya.git
synced 2026-09-04 08:55:59 +02:00
Merge pull request #28 from Stefan-5422/feature-login_service
Feature login service
This commit is contained in:
@@ -1,63 +1,64 @@
|
||||
<Blazorise.ThemeProvider Theme="@theme">
|
||||
<Router AppAssembly="typeof(App).Assembly">
|
||||
<Found Context="routeData">
|
||||
<RouteView RouteData="routeData" DefaultLayout="typeof(Elektrifikatsiya.Layouts.MainLayout)" />
|
||||
</Found>
|
||||
<NotFound>
|
||||
<p>Sorry, there's nothing at this address.</p>
|
||||
</NotFound>
|
||||
</Router>
|
||||
<MessageProvider />
|
||||
<NotificationProvider />
|
||||
<PageProgressProvider />
|
||||
@using Blazorise.Components
|
||||
<Blazorise.ThemeProvider Theme="@theme">
|
||||
<Router AppAssembly="typeof(App).Assembly">
|
||||
<Found Context="routeData">
|
||||
<RouteView RouteData="routeData" DefaultLayout="typeof(Elektrifikatsiya.Layouts.MainLayout)" />
|
||||
</Found>
|
||||
<NotFound>
|
||||
<p>Sorry, there's nothing at this address.</p>
|
||||
</NotFound>
|
||||
</Router>
|
||||
<MessageProvider />
|
||||
<NotificationProvider />
|
||||
<PageProgressProvider />
|
||||
</Blazorise.ThemeProvider>
|
||||
@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"
|
||||
}
|
||||
};
|
||||
}
|
||||
@@ -17,6 +17,13 @@
|
||||
<DockerComposeProjectPath>..\docker-compose.dcproj</DockerComposeProjectPath>
|
||||
</PropertyGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<Compile Remove="Model\**" />
|
||||
<Content Remove="Model\**" />
|
||||
<EmbeddedResource Remove="Model\**" />
|
||||
<None Remove="Model\**" />
|
||||
</ItemGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<PackageReference Include="Blazorise" Version="1.2.0" />
|
||||
<PackageReference Include="Blazorise.Charts" Version="1.2.0" />
|
||||
@@ -32,7 +39,6 @@
|
||||
|
||||
<ItemGroup>
|
||||
<Folder Include="Middleware\" />
|
||||
<Folder Include="Model\" />
|
||||
</ItemGroup>
|
||||
|
||||
</Project>
|
||||
|
||||
@@ -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; }
|
||||
|
||||
@@ -15,7 +15,9 @@ public interface IAuthenticationService
|
||||
/// <summary>
|
||||
/// Registers a new user.
|
||||
/// </summary>
|
||||
/// <param name="email">The E-mail address of the user.</param>
|
||||
/// <param name="name">The name address of the user.</param>
|
||||
/// <param name="password">The password of the user.</param>
|
||||
/// <param name="role">The default role of the user.</param>
|
||||
/// <returns>A <see cref="Task"/> to <see langword="await"/>.</returns>
|
||||
|
||||
Task<Result> RegisterUserAsync(string name, string password, Role role);
|
||||
@@ -23,7 +25,8 @@ public interface IAuthenticationService
|
||||
/// <summary>
|
||||
/// Logs a user in.
|
||||
/// </summary>
|
||||
/// <param name="name">The E-mail address of the user.</param>
|
||||
/// <param name="name">The name of the user.</param>
|
||||
/// <param name="password">The password of the user.</param>
|
||||
/// <returns>A <see cref="Task"/> to <see langword="await"/>.</returns>
|
||||
Task<Result> LoginUserAsync(string name, string password);
|
||||
|
||||
@@ -36,14 +39,13 @@ public interface IAuthenticationService
|
||||
/// <summary>
|
||||
/// Deletes the current user.
|
||||
/// </summary>
|
||||
/// <param name="deletionToken">The deletion token.</param>
|
||||
/// <returns>A <see cref="Task"/> to <see langword="await"/> and a <see cref="bool"/> that indicates if the operation was successful.</returns>
|
||||
/// <returns>A <see cref="Task"/> to <see langword="await"/>.</returns>
|
||||
Task<Result> DeleteUserAsync();
|
||||
|
||||
/// <summary>
|
||||
/// Checks if a user exists.
|
||||
/// </summary>
|
||||
/// <param name="name">The E-mail address of the user.</param>
|
||||
/// <param name="name">The name address of the user.</param>
|
||||
/// <returns>A <see cref="Task"/> to <see langword="await"/> and a <see cref="bool"/> that indicates if the user exists.</returns>
|
||||
Task<Result<bool>> UserExistsAsync(string name);
|
||||
|
||||
|
||||
@@ -2,11 +2,24 @@
|
||||
|
||||
public static class TokenGenerator
|
||||
{
|
||||
/// <summary>
|
||||
/// Creates secure token and uses an UID to make it unique.
|
||||
/// </summary>
|
||||
/// <param name="tokenType">The type of the token.</param>
|
||||
/// <param name="uid">The UID of a user.</param>
|
||||
/// <param name="length">The length of the token.</param>
|
||||
/// <returns></returns>
|
||||
public static string GenerateToken(string tokenType, int uid = 0, int length = 128)
|
||||
{
|
||||
return tokenType + "-" + SecureStringGenerator.CreateCryptographicRandomString(length, uid);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Checks if a token is valid.
|
||||
/// </summary>
|
||||
/// <param name="token">The token to validate.</param>
|
||||
/// <param name="tokenType">The type the token should have.</param>
|
||||
/// <returns></returns>
|
||||
public static bool ValidateToken(string? token, string tokenType)
|
||||
{
|
||||
if (token is null)
|
||||
|
||||
Reference in New Issue
Block a user