Software functions UI done.
This commit is contained in:
+16
@@ -0,0 +1,16 @@
|
|||||||
|
namespace LaaProductionWeb.API.Areas.Account.Controllers
|
||||||
|
{
|
||||||
|
using LaaProductionWeb.Standart.Interfaces;
|
||||||
|
using Microsoft.AspNetCore.Mvc;
|
||||||
|
|
||||||
|
[ApiController]
|
||||||
|
[Area("Account")]
|
||||||
|
[Route("[area]/[controller]")]
|
||||||
|
public class AccountBaseController : ControllerBase
|
||||||
|
{
|
||||||
|
protected readonly IAccountService accountService;
|
||||||
|
|
||||||
|
public AccountBaseController(IAccountService accountService)
|
||||||
|
=> this.accountService = accountService;
|
||||||
|
}
|
||||||
|
}
|
||||||
+40
@@ -0,0 +1,40 @@
|
|||||||
|
namespace LaaProductionWeb.API.Areas.Account.Controllers
|
||||||
|
{
|
||||||
|
using LaaProductionWeb.Standart.Interfaces;
|
||||||
|
|
||||||
|
using Microsoft.AspNetCore.Mvc;
|
||||||
|
|
||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Linq;
|
||||||
|
using System.Text;
|
||||||
|
|
||||||
|
public class FunctionsController : AccountBaseController
|
||||||
|
{
|
||||||
|
public FunctionsController(IAccountService accountService) : base(accountService)
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
[HttpGet]
|
||||||
|
public ActionResult<IEnumerable<string>> Get([FromHeader(Name = "Authorization")]string bearer)
|
||||||
|
{
|
||||||
|
var values = bearer
|
||||||
|
.Split(new[] { ' ' }, StringSplitOptions.RemoveEmptyEntries)
|
||||||
|
.Select(x => Encoding.UTF8.GetString(Convert.FromBase64String(x)))
|
||||||
|
.LastOrDefault()
|
||||||
|
?.Split(new[] { ':' }, StringSplitOptions.RemoveEmptyEntries)
|
||||||
|
?? Array.Empty<string>();
|
||||||
|
|
||||||
|
if (values.Length != 3 || !short.TryParse(values[0], out short appId))
|
||||||
|
{
|
||||||
|
return this.BadRequest("Endpoint expects bearer authorization header with appId:username:password base64 encoded.");
|
||||||
|
}
|
||||||
|
|
||||||
|
var username = values[1];
|
||||||
|
var password = values[2];
|
||||||
|
var functions = this.accountService.FindUserFunctions(appId, username, password);
|
||||||
|
|
||||||
|
return this.Ok(functions);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,39 @@
|
|||||||
|
namespace LaaProductionWeb.API.Areas.Account.Controllers
|
||||||
|
{
|
||||||
|
using LaaProductionWeb.Standart.Interfaces;
|
||||||
|
|
||||||
|
using Microsoft.AspNetCore.Mvc;
|
||||||
|
|
||||||
|
public class PWDController : AccountBaseController
|
||||||
|
{
|
||||||
|
public PWDController(IAccountService accountService) : base(accountService)
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
[HttpPost]
|
||||||
|
public IActionResult Post([FromForm(Name = "username")]string username, [FromForm(Name = "password")]string password)
|
||||||
|
{
|
||||||
|
if (string.IsNullOrWhiteSpace(password))
|
||||||
|
{
|
||||||
|
return this.BadRequest("Invalid password.");
|
||||||
|
}
|
||||||
|
else if (this.accountService.ResetPassword(username, password) == 1)
|
||||||
|
{
|
||||||
|
return this.Ok();
|
||||||
|
}
|
||||||
|
|
||||||
|
return this.BadRequest("Password was not reseted.");
|
||||||
|
}
|
||||||
|
|
||||||
|
[HttpDelete("{username}")]
|
||||||
|
public IActionResult Delete(string username)
|
||||||
|
{
|
||||||
|
if (this.accountService.ResetPassword(username) == 1)
|
||||||
|
{
|
||||||
|
return this.Ok();
|
||||||
|
}
|
||||||
|
|
||||||
|
return this.BadRequest("Password was not reseted.");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -13,6 +13,7 @@
|
|||||||
|
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
<ProjectReference Include="..\LaaProductionWeb.Data\LaaProductionWeb.Data.csproj" />
|
<ProjectReference Include="..\LaaProductionWeb.Data\LaaProductionWeb.Data.csproj" />
|
||||||
|
<ProjectReference Include="..\LaaProductionWeb.Standart\LaaProductionWeb.Standart.csproj" />
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
|
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
@@ -30,4 +31,8 @@
|
|||||||
</EmbeddedResource>
|
</EmbeddedResource>
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
|
|
||||||
|
<ItemGroup>
|
||||||
|
<Folder Include="Areas\Account\Models\" />
|
||||||
|
</ItemGroup>
|
||||||
|
|
||||||
</Project>
|
</Project>
|
||||||
|
|||||||
@@ -8,6 +8,8 @@
|
|||||||
using LaaProductionWeb.API.Areas.Shipment.Models;
|
using LaaProductionWeb.API.Areas.Shipment.Models;
|
||||||
using LaaProductionWeb.API.Models;
|
using LaaProductionWeb.API.Models;
|
||||||
using LaaProductionWeb.API.Models.SMTP;
|
using LaaProductionWeb.API.Models.SMTP;
|
||||||
|
using LaaProductionWeb.Standart.Interfaces;
|
||||||
|
using LaaProductionWeb.Standart;
|
||||||
|
|
||||||
using Microsoft.AspNetCore.Builder;
|
using Microsoft.AspNetCore.Builder;
|
||||||
using Microsoft.AspNetCore.Hosting;
|
using Microsoft.AspNetCore.Hosting;
|
||||||
@@ -28,6 +30,7 @@
|
|||||||
var connectionString = this.configuration
|
var connectionString = this.configuration
|
||||||
.GetConnectionString(nameof(ConnectionStrings.DefaultConnection));
|
.GetConnectionString(nameof(ConnectionStrings.DefaultConnection));
|
||||||
services.AddTransient<ISqlClient, SqlClient>(_ => new SqlClient(connectionString));
|
services.AddTransient<ISqlClient, SqlClient>(_ => new SqlClient(connectionString));
|
||||||
|
services.AddTransient<IAccountService, AccountService>();
|
||||||
services.AddTransient<IWildcardModel, WildcardModel>();
|
services.AddTransient<IWildcardModel, WildcardModel>();
|
||||||
services.AddTransient<IScanModel, ScanModel>();
|
services.AddTransient<IScanModel, ScanModel>();
|
||||||
services.AddTransient(serviceProvider =>
|
services.AddTransient(serviceProvider =>
|
||||||
@@ -56,8 +59,8 @@
|
|||||||
|
|
||||||
app.UseMvc(routes =>
|
app.UseMvc(routes =>
|
||||||
{
|
{
|
||||||
routes.MapRoute(name: "default", template: "{controller=Home}/{action=Index}/{id?}");
|
routes.MapRoute(name: "areas", template: "{area:exists}/{controller}/{action}/{id?}");
|
||||||
routes.MapRoute(name: "areas", template: "{area:exists}/{controller=Home}/{action=Index}/{id?}");
|
routes.MapRoute(name: "default", template: "{controller}/{action}/{id?}");
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -2,9 +2,6 @@
|
|||||||
{
|
{
|
||||||
using LaaProductionWeb.Data.Interfaces;
|
using LaaProductionWeb.Data.Interfaces;
|
||||||
using LaaProductionWeb.Services.Interfaces;
|
using LaaProductionWeb.Services.Interfaces;
|
||||||
using LaaProductionWeb.Services.Models;
|
|
||||||
|
|
||||||
using System.Collections.Generic;
|
|
||||||
|
|
||||||
public class AccountService : IAccountService
|
public class AccountService : IAccountService
|
||||||
{
|
{
|
||||||
@@ -13,30 +10,6 @@
|
|||||||
public AccountService(ISqlClient sqlClient)
|
public AccountService(ISqlClient sqlClient)
|
||||||
=> this.sqlClient = sqlClient;
|
=> this.sqlClient = sqlClient;
|
||||||
|
|
||||||
public Employee FindEmployee(int userId)
|
|
||||||
{
|
|
||||||
var employeIdentity = this.sqlClient.FirstOrDefault($@"
|
|
||||||
SELECT TOP 1
|
|
||||||
[MitarbeiterNr]
|
|
||||||
, [Vorname] + ' ' + [Name]
|
|
||||||
FROM [Mitarbeiter]
|
|
||||||
WHERE [MitarbeiterNr] = @{nameof(userId)}",
|
|
||||||
parameters => parameters.Add(nameof(userId), userId),
|
|
||||||
reader => new KeyValuePair<int, string>(
|
|
||||||
key: reader.GetValue<short>(),
|
|
||||||
value: reader.GetString()));
|
|
||||||
|
|
||||||
var permissions = this.sqlClient.ExecuteReader($@"
|
|
||||||
SELECT [MitarbeiterRechte].[Recht]
|
|
||||||
FROM [MitarbeiterRechte]
|
|
||||||
WHERE [MitarbeiterNr] = @{nameof(employeIdentity.Key)}
|
|
||||||
AND [MitarbeiterRechte].[Recht] LIKE 'WEB_%'",
|
|
||||||
parameters => parameters.Add(nameof(employeIdentity.Key), employeIdentity.Key),
|
|
||||||
reader => reader.GetString());
|
|
||||||
|
|
||||||
return new Employee(employeIdentity.Value, permissions);
|
|
||||||
}
|
|
||||||
|
|
||||||
public int Login(string username, string password)
|
public int Login(string username, string password)
|
||||||
=> this.sqlClient.FirstOrDefault($@"
|
=> this.sqlClient.FirstOrDefault($@"
|
||||||
SELECT TOP 1 [MitarbeiterNr]
|
SELECT TOP 1 [MitarbeiterNr]
|
||||||
|
|||||||
@@ -4,8 +4,6 @@
|
|||||||
|
|
||||||
public interface IAccountService : ITransient
|
public interface IAccountService : ITransient
|
||||||
{
|
{
|
||||||
Employee FindEmployee(int userId);
|
|
||||||
|
|
||||||
int Login(string username, string password);
|
int Login(string username, string password);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -10,6 +10,8 @@
|
|||||||
|
|
||||||
void DeleteFunction(int funcId);
|
void DeleteFunction(int funcId);
|
||||||
|
|
||||||
|
IEnumerable<string> FindSoftwareForUser(short appId, string username, string password);
|
||||||
|
|
||||||
IEnumerable<SoftwareFunction> GetAllSoftwareFunctions();
|
IEnumerable<SoftwareFunction> GetAllSoftwareFunctions();
|
||||||
|
|
||||||
IEnumerable<SoftwareFunction> GetSoftwareFunctions(short appId);
|
IEnumerable<SoftwareFunction> GetSoftwareFunctions(short appId);
|
||||||
@@ -17,9 +19,6 @@
|
|||||||
SoftwareOverview GetSoftwareOverview(short appId);
|
SoftwareOverview GetSoftwareOverview(short appId);
|
||||||
|
|
||||||
IEnumerable<Software> GetSoftwareVersions(short appId);
|
IEnumerable<Software> GetSoftwareVersions(short appId);
|
||||||
|
|
||||||
Software GetSoftwareWithFunctions(short appId);
|
|
||||||
|
|
||||||
IEnumerable<SoftwareOverview> GetSoftwares();
|
IEnumerable<SoftwareOverview> GetSoftwares();
|
||||||
|
|
||||||
IEnumerable<SoftwareUser> GetUsers(string username = null);
|
IEnumerable<SoftwareUser> GetUsers(string username = null);
|
||||||
|
|||||||
@@ -119,6 +119,10 @@
|
|||||||
<Project>{4B5BF112-D3BE-4E84-9A8E-74A0E314BBA7}</Project>
|
<Project>{4B5BF112-D3BE-4E84-9A8E-74A0E314BBA7}</Project>
|
||||||
<Name>LaaProductionWeb.Data</Name>
|
<Name>LaaProductionWeb.Data</Name>
|
||||||
</ProjectReference>
|
</ProjectReference>
|
||||||
|
<ProjectReference Include="..\LaaProductionWeb.Standart\LaaProductionWeb.Standart.csproj">
|
||||||
|
<Project>{b779d025-bd3a-4a0d-bcc1-a5d4c731f697}</Project>
|
||||||
|
<Name>LaaProductionWeb.Standart</Name>
|
||||||
|
</ProjectReference>
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
|
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
|
||||||
</Project>
|
</Project>
|
||||||
@@ -1,13 +1,13 @@
|
|||||||
namespace LaaProductionWeb.Services
|
namespace LaaProductionWeb.Services
|
||||||
{
|
{
|
||||||
using System;
|
|
||||||
using System.Collections.Generic;
|
|
||||||
using System.Security.Cryptography;
|
|
||||||
using System.Text;
|
|
||||||
|
|
||||||
using LaaProductionWeb.Data.Interfaces;
|
using LaaProductionWeb.Data.Interfaces;
|
||||||
using LaaProductionWeb.Services.Interfaces;
|
using LaaProductionWeb.Services.Interfaces;
|
||||||
using LaaProductionWeb.Services.Models.Software;
|
using LaaProductionWeb.Services.Models.Software;
|
||||||
|
using LaaProductionWeb.Standart;
|
||||||
|
|
||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Security.Cryptography;
|
||||||
|
|
||||||
public class SoftwareService : ISoftwareService
|
public class SoftwareService : ISoftwareService
|
||||||
{
|
{
|
||||||
@@ -36,6 +36,11 @@
|
|||||||
.AddParameter(nameof(funcId), funcId)
|
.AddParameter(nameof(funcId), funcId)
|
||||||
.ExecuteNonQuery();
|
.ExecuteNonQuery();
|
||||||
|
|
||||||
|
public IEnumerable<string> FindSoftwareForUser(short appId, string username, string password)
|
||||||
|
{
|
||||||
|
throw new NotImplementedException();
|
||||||
|
}
|
||||||
|
|
||||||
public IEnumerable<SoftwareFunction> GetAllSoftwareFunctions()
|
public IEnumerable<SoftwareFunction> GetAllSoftwareFunctions()
|
||||||
=> this.sqlClient
|
=> this.sqlClient
|
||||||
.CreateCommand($@"
|
.CreateCommand($@"
|
||||||
@@ -69,19 +74,16 @@
|
|||||||
public SoftwareOverview GetSoftwareOverview(short appId)
|
public SoftwareOverview GetSoftwareOverview(short appId)
|
||||||
=> this.sqlClient
|
=> this.sqlClient
|
||||||
.CreateCommand($@"
|
.CreateCommand($@"
|
||||||
SELECT DISTINCT
|
SELECT [vsa].[AppID]
|
||||||
[VSA].[AppId] AS [AppId]
|
, [vsa].[SoftwareAccess_Program]
|
||||||
, [VSA].[SoftwareAccess_Program] AS [Name]
|
, COUNT([vsa].[AppID])
|
||||||
, COUNT([VSA].[SoftwareAccess_ID]) AS [Versions]
|
, (SELECT COUNT(1)
|
||||||
, COUNT([SF].[Id]) AS [Functions]
|
FROM [SoftwareFunctions]
|
||||||
, COUNT([UF].[UserId]) AS [Users]
|
WHERE [AppId] = [vsa].[AppID]) AS [CountF]
|
||||||
FROM [VersionSoftwareAccess] AS [VSA]
|
FROM [VersionSoftwareAccess] AS [vsa]
|
||||||
LEFT JOIN [SoftwareFunctions] AS [SF] ON [SF].[AppId] = [VSA].[AppId]
|
WHERE [vsa].[AppID] = @{nameof(appId)}
|
||||||
LEFT JOIN [UsersFunctions] AS [UF] ON [UF].[SoftwareFunctionId] = [SF].[Id]
|
GROUP BY [vsa].[AppID]
|
||||||
WHERE [VSA].[AppId] = @{nameof(appId)}
|
, [vsa].[SoftwareAccess_Program]")
|
||||||
GROUP BY [VSA].[AppId]
|
|
||||||
, [VSA].[SoftwareAccess_Program]
|
|
||||||
ORDER BY [SoftwareAccess_Program]")
|
|
||||||
.AddParameter(nameof(appId), appId)
|
.AddParameter(nameof(appId), appId)
|
||||||
.FirstOrDefault(x => new SoftwareOverview
|
.FirstOrDefault(x => new SoftwareOverview
|
||||||
{
|
{
|
||||||
@@ -121,73 +123,18 @@
|
|||||||
Description = x.GetString()
|
Description = x.GetString()
|
||||||
});
|
});
|
||||||
|
|
||||||
public Software GetSoftwareWithFunctions(short appId)
|
|
||||||
=> this.sqlClient
|
|
||||||
.CreateCommand($@"
|
|
||||||
SELECT TOP 1
|
|
||||||
[SoftwareAccess_ID]
|
|
||||||
, [AppID]
|
|
||||||
, [SoftwareAccess_Program]
|
|
||||||
, [SoftwareAccess_MajorVersion]
|
|
||||||
, [SoftwareAccess_MinorVersion]
|
|
||||||
, [SoftwareAccess_BuildVersion]
|
|
||||||
, [SoftwareAccess_VaildTo]
|
|
||||||
, [SoftwareAccess_Desc]
|
|
||||||
FROM [VersionSoftwareAccess]
|
|
||||||
WHERE [AppId] = @{nameof(appId)}
|
|
||||||
ORDER BY [SoftwareAccess_VaildTo] DESC
|
|
||||||
, [SoftwareAccess_BuildVersion]
|
|
||||||
, [SoftwareAccess_MinorVersion]
|
|
||||||
, [SoftwareAccess_MajorVersion]")
|
|
||||||
.AddParameter(nameof(appId), appId)
|
|
||||||
.FirstOrDefault(x => new Software
|
|
||||||
{
|
|
||||||
Id = x.GetInt(),
|
|
||||||
AppId = x.GetSmallint(),
|
|
||||||
FullName = x.GetString(),
|
|
||||||
MajorV = x.GetInt(),
|
|
||||||
MinorV = x.GetInt(),
|
|
||||||
BuildV = x.GetInt(),
|
|
||||||
ValidTo = x.GetDate(),
|
|
||||||
Description = x.GetString(),
|
|
||||||
Functions = this.sqlClient
|
|
||||||
.CreateCommand($@"
|
|
||||||
SELECT [Id]
|
|
||||||
, [AppId]
|
|
||||||
, [Function]
|
|
||||||
FROM [SoftwareFunctions]
|
|
||||||
WHERE [AppId] = @{nameof(appId)}")
|
|
||||||
.AddParameter(nameof(appId), appId)
|
|
||||||
.ExecuteReader(f => new SoftwareFunction
|
|
||||||
{
|
|
||||||
Id = f.GetInt(),
|
|
||||||
AppId = f.GetSmallint(),
|
|
||||||
Function = f.GetString()
|
|
||||||
})
|
|
||||||
});
|
|
||||||
|
|
||||||
public IEnumerable<SoftwareOverview> GetSoftwares()
|
public IEnumerable<SoftwareOverview> GetSoftwares()
|
||||||
=> this.sqlClient
|
=> this.sqlClient
|
||||||
.CreateCommand(@"
|
.CreateCommand(@"
|
||||||
SELECT [VSA].[AppId] AS [AppId]
|
SELECT [VSA].[AppId] AS [AppId]
|
||||||
, [VSA].[Program] AS [Program]
|
, [VSA].[SoftwareAccess_Program] AS [Program]
|
||||||
, [VSA].[Versions] AS [Versions]
|
, COUNT([VSA].[AppId]) AS [Versions]
|
||||||
, COUNT([SF].[Id]) AS [Functions]
|
, (SELECT COUNT(1)
|
||||||
FROM (SELECT DISTINCT
|
FROM [SoftwareFunctions]
|
||||||
[AppID] AS [AppId]
|
WHERE [AppId] = [VSA].[AppID]) AS [Functions]
|
||||||
, [SoftwareAccess_Program] AS [Program]
|
FROM [VersionSoftwareAccess] AS [VSA]
|
||||||
, COUNT([AppID]) AS [Versions]
|
|
||||||
FROM [VersionSoftwareAccess]
|
|
||||||
GROUP BY [AppID]
|
|
||||||
, [SoftwareAccess_Program])
|
|
||||||
AS [VSA]
|
|
||||||
LEFT JOIN [SoftwareFunctions] AS [SF]
|
|
||||||
ON [SF].[AppId] = [VSA].[AppId]
|
|
||||||
LEFT JOIN [UsersFunctions] AS [UF]
|
|
||||||
ON [UF].[SoftwareFunctionId] = [SF].[Id]
|
|
||||||
GROUP BY [VSA].[AppId]
|
GROUP BY [VSA].[AppId]
|
||||||
, [VSA].[Program]
|
, [VSA].[SoftwareAccess_Program]")
|
||||||
, [VSA].[Versions]")
|
|
||||||
.ExecuteReader(x => new SoftwareOverview
|
.ExecuteReader(x => new SoftwareOverview
|
||||||
{
|
{
|
||||||
AppId = x.GetSmallint(),
|
AppId = x.GetSmallint(),
|
||||||
@@ -324,8 +271,7 @@
|
|||||||
|
|
||||||
public int ResetPassword(short userId, string password)
|
public int ResetPassword(short userId, string password)
|
||||||
{
|
{
|
||||||
var sha256 = SHA256.Create();
|
password = SHA256.Create().ComputeHash(password);
|
||||||
password = sha256.ComputeHash(password);
|
|
||||||
|
|
||||||
return this.sqlClient
|
return this.sqlClient
|
||||||
.CreateCommand($@"
|
.CreateCommand($@"
|
||||||
@@ -387,15 +333,4 @@
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
internal static class CryptographyExtensions
|
|
||||||
{
|
|
||||||
public static string ComputeHash(this HashAlgorithm hashAlgorithm, string value)
|
|
||||||
{
|
|
||||||
var valueBuffer = Encoding.UTF8.GetBytes(value);
|
|
||||||
var hashBuffer = hashAlgorithm.ComputeHash(valueBuffer);
|
|
||||||
|
|
||||||
return Convert.ToBase64String(hashBuffer);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -0,0 +1,52 @@
|
|||||||
|
namespace LaaProductionWeb.Standart
|
||||||
|
{
|
||||||
|
using LaaProductionWeb.Data.Interfaces;
|
||||||
|
using LaaProductionWeb.Standart.Interfaces;
|
||||||
|
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Security.Cryptography;
|
||||||
|
|
||||||
|
public class AccountService : IAccountService
|
||||||
|
{
|
||||||
|
private readonly ISqlClient sqlClient;
|
||||||
|
|
||||||
|
public AccountService(ISqlClient sqlClient)
|
||||||
|
=> this.sqlClient = sqlClient;
|
||||||
|
|
||||||
|
public IEnumerable<string> FindUserFunctions(short appId, string username, string password)
|
||||||
|
=> this.sqlClient
|
||||||
|
.CreateCommand($@"
|
||||||
|
SELECT [SF].[Function]
|
||||||
|
FROM [Mitarbeiter] AS [U]
|
||||||
|
JOIN [UsersFunctions] AS [UF]
|
||||||
|
ON [UF].[UserId] = [U].[MitarbeiterNr]
|
||||||
|
JOIN [SoftwareFunctions] AS [SF]
|
||||||
|
ON [SF].[Id] = [UF].[SoftwareFunctionId]
|
||||||
|
WHERE [U].[Benutzername] = @{nameof(username)}
|
||||||
|
AND [U].[PasswordHash] = @{nameof(password)}
|
||||||
|
AND [SF].[AppId] = @{nameof(appId)}")
|
||||||
|
.AddParameter(nameof(username), username)
|
||||||
|
.AddParameter(nameof(password), SHA256.Create().ComputeHash(password))
|
||||||
|
.AddParameter(nameof(appId), appId)
|
||||||
|
.ExecuteReader(x => x.GetString());
|
||||||
|
|
||||||
|
public int ResetPassword(string username)
|
||||||
|
=> this.sqlClient
|
||||||
|
.CreateCommand($@"
|
||||||
|
UPDATE [Mitarbeiter]
|
||||||
|
SET [PasswordHash] = NULL
|
||||||
|
WHERE [Benutzername] = @{nameof(username)}")
|
||||||
|
.AddParameter(nameof(username), username)
|
||||||
|
.ExecuteNonQuery();
|
||||||
|
|
||||||
|
public int ResetPassword(string username, string password)
|
||||||
|
=> this.sqlClient
|
||||||
|
.CreateCommand($@"
|
||||||
|
UPDATE [Mitarbeiter]
|
||||||
|
SET [PasswordHash] = @{nameof(password)}
|
||||||
|
WHERE [Benutzername] = @{nameof(username)}")
|
||||||
|
.AddParameter(nameof(username), username)
|
||||||
|
.AddParameter(nameof(password), SHA256.Create().ComputeHash(password))
|
||||||
|
.ExecuteNonQuery();
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,13 @@
|
|||||||
|
namespace LaaProductionWeb.Standart.Interfaces
|
||||||
|
{
|
||||||
|
using System.Collections.Generic;
|
||||||
|
|
||||||
|
public interface IAccountService
|
||||||
|
{
|
||||||
|
IEnumerable<string> FindUserFunctions(short appId, string username, string passwordHash);
|
||||||
|
|
||||||
|
int ResetPassword(string username);
|
||||||
|
|
||||||
|
int ResetPassword(string username, string password);
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,11 @@
|
|||||||
|
<Project Sdk="Microsoft.NET.Sdk">
|
||||||
|
|
||||||
|
<PropertyGroup>
|
||||||
|
<TargetFramework>netstandard2.0</TargetFramework>
|
||||||
|
</PropertyGroup>
|
||||||
|
|
||||||
|
<ItemGroup>
|
||||||
|
<ProjectReference Include="..\LaaProductionWeb.Data\LaaProductionWeb.Data.csproj" />
|
||||||
|
</ItemGroup>
|
||||||
|
|
||||||
|
</Project>
|
||||||
@@ -0,0 +1,12 @@
|
|||||||
|
namespace LaaProductionWeb.Standart
|
||||||
|
{
|
||||||
|
using System;
|
||||||
|
using System.Security.Cryptography;
|
||||||
|
using System.Text;
|
||||||
|
|
||||||
|
public static class StandartExtensions
|
||||||
|
{
|
||||||
|
public static string ComputeHash(this HashAlgorithm hashAlgorithm, string value)
|
||||||
|
=> Convert.ToBase64String(hashAlgorithm.ComputeHash(Encoding.UTF8.GetBytes(value)));
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -18,6 +18,8 @@ Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "LaaProductionWeb.API", "Laa
|
|||||||
EndProject
|
EndProject
|
||||||
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "LaaProductionWeb.API.UnitTests", "LaaProductionWeb.API.UnitTests\LaaProductionWeb.API.UnitTests.csproj", "{EF371C00-4452-4506-A7B6-C2F94C170D2C}"
|
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "LaaProductionWeb.API.UnitTests", "LaaProductionWeb.API.UnitTests\LaaProductionWeb.API.UnitTests.csproj", "{EF371C00-4452-4506-A7B6-C2F94C170D2C}"
|
||||||
EndProject
|
EndProject
|
||||||
|
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "LaaProductionWeb.Standart", "LaaProductionWeb.Standart\LaaProductionWeb.Standart.csproj", "{B779D025-BD3A-4A0D-BCC1-A5D4C731F697}"
|
||||||
|
EndProject
|
||||||
Global
|
Global
|
||||||
GlobalSection(SolutionConfigurationPlatforms) = preSolution
|
GlobalSection(SolutionConfigurationPlatforms) = preSolution
|
||||||
Debug|Any CPU = Debug|Any CPU
|
Debug|Any CPU = Debug|Any CPU
|
||||||
@@ -44,6 +46,10 @@ Global
|
|||||||
{EF371C00-4452-4506-A7B6-C2F94C170D2C}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
{EF371C00-4452-4506-A7B6-C2F94C170D2C}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
||||||
{EF371C00-4452-4506-A7B6-C2F94C170D2C}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
{EF371C00-4452-4506-A7B6-C2F94C170D2C}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
||||||
{EF371C00-4452-4506-A7B6-C2F94C170D2C}.Release|Any CPU.Build.0 = Release|Any CPU
|
{EF371C00-4452-4506-A7B6-C2F94C170D2C}.Release|Any CPU.Build.0 = Release|Any CPU
|
||||||
|
{B779D025-BD3A-4A0D-BCC1-A5D4C731F697}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
|
||||||
|
{B779D025-BD3A-4A0D-BCC1-A5D4C731F697}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
||||||
|
{B779D025-BD3A-4A0D-BCC1-A5D4C731F697}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
||||||
|
{B779D025-BD3A-4A0D-BCC1-A5D4C731F697}.Release|Any CPU.Build.0 = Release|Any CPU
|
||||||
EndGlobalSection
|
EndGlobalSection
|
||||||
GlobalSection(SolutionProperties) = preSolution
|
GlobalSection(SolutionProperties) = preSolution
|
||||||
HideSolutionNode = FALSE
|
HideSolutionNode = FALSE
|
||||||
|
|||||||
@@ -78,15 +78,15 @@ tr {
|
|||||||
position: relative;
|
position: relative;
|
||||||
}
|
}
|
||||||
|
|
||||||
tr.is_scaned_0::after {
|
tr.is_scaned_0::after {
|
||||||
position: absolute;
|
position: absolute;
|
||||||
display: block;
|
display: block;
|
||||||
content: '';
|
content: '';
|
||||||
width: 100%;
|
width: 100%;
|
||||||
height: 100%;
|
height: 100%;
|
||||||
left: 0;
|
left: 0;
|
||||||
top: 0;
|
top: 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
.a-4 {
|
.a-4 {
|
||||||
width: 21cm;
|
width: 21cm;
|
||||||
@@ -105,12 +105,12 @@ table.table table.table {
|
|||||||
border-bottom: 0 !important;
|
border-bottom: 0 !important;
|
||||||
}
|
}
|
||||||
|
|
||||||
table.table table.table th:first-child,
|
table.table table.table th:first-child,
|
||||||
table.table table.table td:first-child {
|
table.table table.table td:first-child {
|
||||||
border-left: 0 !important;
|
border-left: 0 !important;
|
||||||
}
|
}
|
||||||
|
|
||||||
table.table table.table th:last-child,
|
table.table table.table th:last-child,
|
||||||
table.table table.table td:last-child {
|
table.table table.table td:last-child {
|
||||||
border-right: 0 !important;
|
border-right: 0 !important;
|
||||||
}
|
}
|
||||||
@@ -145,3 +145,32 @@ label.bi-search:before {
|
|||||||
position: relative !important;
|
position: relative !important;
|
||||||
left: -.5rem !important;
|
left: -.5rem !important;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
.list-group.list-group-transparent {
|
||||||
|
--bs-list-group-color: gray;
|
||||||
|
--bs-list-group-bg: transparent !important;
|
||||||
|
--bs-list-group-action-color: black !important;
|
||||||
|
--bs-list-group-action-hover-color: #495057 !important;
|
||||||
|
--bs-list-group-action-hover-bg: transparent !important;
|
||||||
|
--bs-list-group-action-active-color: black !important;
|
||||||
|
--bs-list-group-action-active-bg: transparent !important;
|
||||||
|
--bs-list-group-active-color: black !important;
|
||||||
|
--bs-list-group-active-bg: transparent !important;
|
||||||
|
--bs-list-group-active-border-color: black !important;
|
||||||
|
}
|
||||||
|
|
||||||
|
.list-group-item.active {
|
||||||
|
border-top-color: var(--bs-list-group-border-color);
|
||||||
|
}
|
||||||
|
|
||||||
|
.bi-small::before {
|
||||||
|
font-size: 80%;
|
||||||
|
}
|
||||||
|
|
||||||
|
span.td-error {
|
||||||
|
position: absolute;
|
||||||
|
bottom: -.5rem;
|
||||||
|
font-size: 75%;
|
||||||
|
color: var(--bs-danger);
|
||||||
|
background-color: white;
|
||||||
|
}
|
||||||
|
|||||||
@@ -1,17 +0,0 @@
|
|||||||
namespace LaaProductionWeb.Areas.API
|
|
||||||
{
|
|
||||||
using System.Web.Mvc;
|
|
||||||
|
|
||||||
public class APIAreaRegistration : AreaRegistration
|
|
||||||
{
|
|
||||||
public override string AreaName => "API";
|
|
||||||
|
|
||||||
public override void RegisterArea(AreaRegistrationContext context)
|
|
||||||
{
|
|
||||||
context.MapRoute(
|
|
||||||
"API_default",
|
|
||||||
"API/{controller}/{action}/{id}",
|
|
||||||
new { action = "Index", id = UrlParameter.Optional });
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,27 +0,0 @@
|
|||||||
namespace LaaProductionWeb.Areas.API.Controllers
|
|
||||||
{
|
|
||||||
using LaaProductionWeb.App_Infrastructure;
|
|
||||||
using LaaProductionWeb.Services.Interfaces;
|
|
||||||
|
|
||||||
using System.Web.Mvc;
|
|
||||||
|
|
||||||
public class PWDController : Controller
|
|
||||||
{
|
|
||||||
private readonly ISoftwareService softwareService;
|
|
||||||
|
|
||||||
public PWDController()
|
|
||||||
=> this.softwareService = ServiceProvider.Current.GetService<ISoftwareService>();
|
|
||||||
|
|
||||||
[HttpGet]
|
|
||||||
public bool Get()
|
|
||||||
=> true;
|
|
||||||
|
|
||||||
[HttpPost]
|
|
||||||
public bool Post(short id, string value)
|
|
||||||
=> this.softwareService.ResetPassword(id, value) == 1;
|
|
||||||
|
|
||||||
[HttpDelete]
|
|
||||||
public bool Delete(short id)
|
|
||||||
=> this.softwareService.ResetPassword(id) == 1;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
+31
-23
@@ -9,6 +9,7 @@
|
|||||||
using System.Web.Mvc;
|
using System.Web.Mvc;
|
||||||
|
|
||||||
[RouteArea("Administration")]
|
[RouteArea("Administration")]
|
||||||
|
[Authorize(Roles = UserRoles.WEB_Admin)]
|
||||||
public class SoftwareController : Controller
|
public class SoftwareController : Controller
|
||||||
{
|
{
|
||||||
private readonly ISoftwareService softwareService;
|
private readonly ISoftwareService softwareService;
|
||||||
@@ -38,35 +39,42 @@
|
|||||||
}
|
}
|
||||||
|
|
||||||
[HttpGet]
|
[HttpGet]
|
||||||
public ActionResult SoftwareVersions(short id)
|
public ActionResult SoftwareVersions(short? id)
|
||||||
{
|
{
|
||||||
var model = this.softwareService
|
var model = new SoftwareVersionsModel();
|
||||||
.GetSoftwareOverview(id)
|
|
||||||
.Map(x => new SoftwareVersionsModel
|
|
||||||
{
|
|
||||||
AppId = x.AppId,
|
|
||||||
Name = x.Name
|
|
||||||
.Split('.')
|
|
||||||
.LastOrDefault(),
|
|
||||||
Versions = x.Versions,
|
|
||||||
Functions = x.Functions
|
|
||||||
});
|
|
||||||
|
|
||||||
if (model != null)
|
if (id.HasValue)
|
||||||
{
|
{
|
||||||
model.SoftwareVersions = this.softwareService
|
var appId = id.Value;
|
||||||
.GetSoftwareVersions(id)
|
|
||||||
.Select(x => new SoftwareVersionModel
|
model = this.softwareService
|
||||||
|
.GetSoftwareOverview(appId)
|
||||||
|
.Map(x => new SoftwareVersionsModel
|
||||||
{
|
{
|
||||||
AppId = x.AppId,
|
AppId = x.AppId,
|
||||||
BuildV = x.BuildV,
|
Name = x.Name
|
||||||
Description = x.Description,
|
.Split('.')
|
||||||
FullName = x.FullName,
|
.LastOrDefault(),
|
||||||
Id = x.Id,
|
Versions = x.Versions,
|
||||||
MajorV = x.MajorV,
|
Functions = x.Functions
|
||||||
MinorV = x.MinorV,
|
|
||||||
ValidTo = x.ValidTo
|
|
||||||
});
|
});
|
||||||
|
|
||||||
|
if (model != null)
|
||||||
|
{
|
||||||
|
model.SoftwareVersions = this.softwareService
|
||||||
|
.GetSoftwareVersions(appId)
|
||||||
|
.Select(x => new SoftwareVersionModel
|
||||||
|
{
|
||||||
|
AppId = x.AppId,
|
||||||
|
BuildV = x.BuildV,
|
||||||
|
Description = x.Description,
|
||||||
|
FullName = x.FullName,
|
||||||
|
Id = x.Id,
|
||||||
|
MajorV = x.MajorV,
|
||||||
|
MinorV = x.MinorV,
|
||||||
|
ValidTo = x.ValidTo
|
||||||
|
});
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return this.View(model);
|
return this.View(model);
|
||||||
|
|||||||
+1
-5
@@ -24,10 +24,6 @@
|
|||||||
<td class="text-smallcaps small"><a href="~/Administration/Software/SoftwareFunctions/@this.Model.AppId">Functions</a></td>
|
<td class="text-smallcaps small"><a href="~/Administration/Software/SoftwareFunctions/@this.Model.AppId">Functions</a></td>
|
||||||
<td class="text-smallcaps small">@this.Model.Functions</td>
|
<td class="text-smallcaps small">@this.Model.Functions</td>
|
||||||
</tr>
|
</tr>
|
||||||
<tr>
|
|
||||||
<td class="text-smallcaps small">Users</td>
|
|
||||||
<td class="text-smallcaps small">@this.Model.Users</td>
|
|
||||||
</tr>
|
|
||||||
</tbody>
|
</tbody>
|
||||||
</table>
|
</table>
|
||||||
</div>
|
</div>
|
||||||
@@ -60,7 +56,7 @@
|
|||||||
<td>@version.MajorV</td>
|
<td>@version.MajorV</td>
|
||||||
<td>@version.MinorV</td>
|
<td>@version.MinorV</td>
|
||||||
<td>@version.BuildV</td>
|
<td>@version.BuildV</td>
|
||||||
<td>@version.ValidTo</td>
|
<td>@version.ValidTo.ToString("yyyy-MM-dd")</td>
|
||||||
<td>@version.Description</td>
|
<td>@version.Description</td>
|
||||||
</tr>
|
</tr>
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -161,8 +161,6 @@
|
|||||||
<Compile Include="Areas\Administration\Models\Software\UserFunctions.cs" />
|
<Compile Include="Areas\Administration\Models\Software\UserFunctions.cs" />
|
||||||
<Compile Include="Areas\Administration\Models\Software\UsersFunctionsInputModel.cs" />
|
<Compile Include="Areas\Administration\Models\Software\UsersFunctionsInputModel.cs" />
|
||||||
<Compile Include="Areas\Administration\Models\Software\UsersFunctionsModel.cs" />
|
<Compile Include="Areas\Administration\Models\Software\UsersFunctionsModel.cs" />
|
||||||
<Compile Include="Areas\API\APIAreaRegistration.cs" />
|
|
||||||
<Compile Include="Areas\API\Controllers\PWDController.cs" />
|
|
||||||
<Compile Include="Controllers\AdminController.cs" />
|
<Compile Include="Controllers\AdminController.cs" />
|
||||||
<Compile Include="Controllers\ApprovalsController.cs" />
|
<Compile Include="Controllers\ApprovalsController.cs" />
|
||||||
<Compile Include="Controllers\HomeController.cs" />
|
<Compile Include="Controllers\HomeController.cs" />
|
||||||
@@ -204,7 +202,6 @@
|
|||||||
<Content Include="Areas\Administration\Views\Software\UsersFunctions.cshtml" />
|
<Content Include="Areas\Administration\Views\Software\UsersFunctions.cshtml" />
|
||||||
<Content Include="Areas\Administration\Views\web.config" />
|
<Content Include="Areas\Administration\Views\web.config" />
|
||||||
<Content Include="Areas\Administration\Views\_ViewStart.cshtml" />
|
<Content Include="Areas\Administration\Views\_ViewStart.cshtml" />
|
||||||
<Content Include="Areas\API\Views\web.config" />
|
|
||||||
<None Include="packages.config" />
|
<None Include="packages.config" />
|
||||||
<Content Include="Views\Shared\_PrintLayout.cshtml" />
|
<Content Include="Views\Shared\_PrintLayout.cshtml" />
|
||||||
<Content Include="Views\Report\Helium.cshtml" />
|
<Content Include="Views\Report\Helium.cshtml" />
|
||||||
@@ -249,10 +246,7 @@
|
|||||||
<Name>LaaProductionWeb.Services</Name>
|
<Name>LaaProductionWeb.Services</Name>
|
||||||
</ProjectReference>
|
</ProjectReference>
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
<ItemGroup>
|
<ItemGroup />
|
||||||
<Folder Include="Areas\API\Models\" />
|
|
||||||
<Folder Include="Areas\API\Views\Shared\" />
|
|
||||||
</ItemGroup>
|
|
||||||
<PropertyGroup>
|
<PropertyGroup>
|
||||||
<VisualStudioVersion Condition="'$(VisualStudioVersion)' == ''">10.0</VisualStudioVersion>
|
<VisualStudioVersion Condition="'$(VisualStudioVersion)' == ''">10.0</VisualStudioVersion>
|
||||||
<VSToolsPath Condition="'$(VSToolsPath)' == ''">$(MSBuildExtensionsPath32)\Microsoft\VisualStudio\v$(VisualStudioVersion)</VSToolsPath>
|
<VSToolsPath Condition="'$(VSToolsPath)' == ''">$(MSBuildExtensionsPath32)\Microsoft\VisualStudio\v$(VisualStudioVersion)</VSToolsPath>
|
||||||
|
|||||||
Reference in New Issue
Block a user