refractoring
This commit is contained in:
Binary file not shown.
Binary file not shown.
@@ -13,7 +13,7 @@ using System.Reflection;
|
|||||||
[assembly: System.Reflection.AssemblyCompanyAttribute("backendCs.Test")]
|
[assembly: System.Reflection.AssemblyCompanyAttribute("backendCs.Test")]
|
||||||
[assembly: System.Reflection.AssemblyConfigurationAttribute("Debug")]
|
[assembly: System.Reflection.AssemblyConfigurationAttribute("Debug")]
|
||||||
[assembly: System.Reflection.AssemblyFileVersionAttribute("1.0.0.0")]
|
[assembly: System.Reflection.AssemblyFileVersionAttribute("1.0.0.0")]
|
||||||
[assembly: System.Reflection.AssemblyInformationalVersionAttribute("1.0.0+cb7b3ad94c91aad561fa90871a3e078e741f566c")]
|
[assembly: System.Reflection.AssemblyInformationalVersionAttribute("1.0.0+926436860cd34dec9ccf3feac66e4c63bae7ba8f")]
|
||||||
[assembly: System.Reflection.AssemblyProductAttribute("backendCs.Test")]
|
[assembly: System.Reflection.AssemblyProductAttribute("backendCs.Test")]
|
||||||
[assembly: System.Reflection.AssemblyTitleAttribute("backendCs.Test")]
|
[assembly: System.Reflection.AssemblyTitleAttribute("backendCs.Test")]
|
||||||
[assembly: System.Reflection.AssemblyVersionAttribute("1.0.0.0")]
|
[assembly: System.Reflection.AssemblyVersionAttribute("1.0.0.0")]
|
||||||
|
|||||||
@@ -1 +1 @@
|
|||||||
d5818043832e259ded45b9771c78c909a325898a23799ca0c691beda0cd33197
|
52cff86724d2fd2424e9f1d9a690fe3422a59e7c4c8fd9c4b99335b5ce7acb7f
|
||||||
|
|||||||
+1
-1
@@ -8,6 +8,6 @@ build_property.PlatformNeutralAssembly =
|
|||||||
build_property.EnforceExtendedAnalyzerRules =
|
build_property.EnforceExtendedAnalyzerRules =
|
||||||
build_property._SupportedPlatformList = Linux,macOS,Windows
|
build_property._SupportedPlatformList = Linux,macOS,Windows
|
||||||
build_property.RootNamespace = backendCs.Test
|
build_property.RootNamespace = backendCs.Test
|
||||||
build_property.ProjectDir = /home/arch/projects/wip/timelog-interview-login/backendCs.Tests/
|
build_property.ProjectDir = /home/arch/projects/unfinished/timelog-interview-login/backendCs.Tests/
|
||||||
build_property.EnableComHosting =
|
build_property.EnableComHosting =
|
||||||
build_property.EnableGeneratedComInterfaceComImportInterop =
|
build_property.EnableGeneratedComInterfaceComImportInterop =
|
||||||
|
|||||||
Binary file not shown.
@@ -218,3 +218,113 @@
|
|||||||
/home/arch/projects/wip/timelog-interview-login/backendCs.Tests/obj/Debug/net8.0/backendCs.Test.pdb
|
/home/arch/projects/wip/timelog-interview-login/backendCs.Tests/obj/Debug/net8.0/backendCs.Test.pdb
|
||||||
/home/arch/projects/wip/timelog-interview-login/backendCs.Tests/obj/Debug/net8.0/backendCs.Test.genruntimeconfig.cache
|
/home/arch/projects/wip/timelog-interview-login/backendCs.Tests/obj/Debug/net8.0/backendCs.Test.genruntimeconfig.cache
|
||||||
/home/arch/projects/wip/timelog-interview-login/backendCs.Tests/obj/Debug/net8.0/ref/backendCs.Test.dll
|
/home/arch/projects/wip/timelog-interview-login/backendCs.Tests/obj/Debug/net8.0/ref/backendCs.Test.dll
|
||||||
|
/home/arch/projects/unfinished/timelog-interview-login/backendCs.Tests/bin/Debug/net8.0/Microsoft.VisualStudio.TestPlatform.MSTest.TestAdapter.dll
|
||||||
|
/home/arch/projects/unfinished/timelog-interview-login/backendCs.Tests/bin/Debug/net8.0/Microsoft.VisualStudio.TestPlatform.MSTestAdapter.PlatformServices.dll
|
||||||
|
/home/arch/projects/unfinished/timelog-interview-login/backendCs.Tests/bin/Debug/net8.0/Microsoft.TestPlatform.AdapterUtilities.dll
|
||||||
|
/home/arch/projects/unfinished/timelog-interview-login/backendCs.Tests/bin/Debug/net8.0/backendCs.Test.deps.json
|
||||||
|
/home/arch/projects/unfinished/timelog-interview-login/backendCs.Tests/bin/Debug/net8.0/backendCs.Test.runtimeconfig.json
|
||||||
|
/home/arch/projects/unfinished/timelog-interview-login/backendCs.Tests/bin/Debug/net8.0/backendCs.Test.dll
|
||||||
|
/home/arch/projects/unfinished/timelog-interview-login/backendCs.Tests/bin/Debug/net8.0/backendCs.Test.pdb
|
||||||
|
/home/arch/projects/unfinished/timelog-interview-login/backendCs.Tests/bin/Debug/net8.0/Microsoft.VisualStudio.CodeCoverage.Shim.dll
|
||||||
|
/home/arch/projects/unfinished/timelog-interview-login/backendCs.Tests/bin/Debug/net8.0/Microsoft.TestPlatform.CoreUtilities.dll
|
||||||
|
/home/arch/projects/unfinished/timelog-interview-login/backendCs.Tests/bin/Debug/net8.0/Microsoft.TestPlatform.PlatformAbstractions.dll
|
||||||
|
/home/arch/projects/unfinished/timelog-interview-login/backendCs.Tests/bin/Debug/net8.0/Microsoft.VisualStudio.TestPlatform.ObjectModel.dll
|
||||||
|
/home/arch/projects/unfinished/timelog-interview-login/backendCs.Tests/bin/Debug/net8.0/Microsoft.TestPlatform.CommunicationUtilities.dll
|
||||||
|
/home/arch/projects/unfinished/timelog-interview-login/backendCs.Tests/bin/Debug/net8.0/Microsoft.TestPlatform.CrossPlatEngine.dll
|
||||||
|
/home/arch/projects/unfinished/timelog-interview-login/backendCs.Tests/bin/Debug/net8.0/Microsoft.TestPlatform.Utilities.dll
|
||||||
|
/home/arch/projects/unfinished/timelog-interview-login/backendCs.Tests/bin/Debug/net8.0/Microsoft.VisualStudio.TestPlatform.Common.dll
|
||||||
|
/home/arch/projects/unfinished/timelog-interview-login/backendCs.Tests/bin/Debug/net8.0/testhost.dll
|
||||||
|
/home/arch/projects/unfinished/timelog-interview-login/backendCs.Tests/bin/Debug/net8.0/Microsoft.VisualStudio.TestPlatform.TestFramework.dll
|
||||||
|
/home/arch/projects/unfinished/timelog-interview-login/backendCs.Tests/bin/Debug/net8.0/Newtonsoft.Json.dll
|
||||||
|
/home/arch/projects/unfinished/timelog-interview-login/backendCs.Tests/bin/Debug/net8.0/NuGet.Frameworks.dll
|
||||||
|
/home/arch/projects/unfinished/timelog-interview-login/backendCs.Tests/bin/Debug/net8.0/cs/Microsoft.TestPlatform.CoreUtilities.resources.dll
|
||||||
|
/home/arch/projects/unfinished/timelog-interview-login/backendCs.Tests/bin/Debug/net8.0/cs/Microsoft.VisualStudio.TestPlatform.ObjectModel.resources.dll
|
||||||
|
/home/arch/projects/unfinished/timelog-interview-login/backendCs.Tests/bin/Debug/net8.0/de/Microsoft.TestPlatform.CoreUtilities.resources.dll
|
||||||
|
/home/arch/projects/unfinished/timelog-interview-login/backendCs.Tests/bin/Debug/net8.0/de/Microsoft.VisualStudio.TestPlatform.ObjectModel.resources.dll
|
||||||
|
/home/arch/projects/unfinished/timelog-interview-login/backendCs.Tests/bin/Debug/net8.0/es/Microsoft.TestPlatform.CoreUtilities.resources.dll
|
||||||
|
/home/arch/projects/unfinished/timelog-interview-login/backendCs.Tests/bin/Debug/net8.0/es/Microsoft.VisualStudio.TestPlatform.ObjectModel.resources.dll
|
||||||
|
/home/arch/projects/unfinished/timelog-interview-login/backendCs.Tests/bin/Debug/net8.0/fr/Microsoft.TestPlatform.CoreUtilities.resources.dll
|
||||||
|
/home/arch/projects/unfinished/timelog-interview-login/backendCs.Tests/bin/Debug/net8.0/fr/Microsoft.VisualStudio.TestPlatform.ObjectModel.resources.dll
|
||||||
|
/home/arch/projects/unfinished/timelog-interview-login/backendCs.Tests/bin/Debug/net8.0/it/Microsoft.TestPlatform.CoreUtilities.resources.dll
|
||||||
|
/home/arch/projects/unfinished/timelog-interview-login/backendCs.Tests/bin/Debug/net8.0/it/Microsoft.VisualStudio.TestPlatform.ObjectModel.resources.dll
|
||||||
|
/home/arch/projects/unfinished/timelog-interview-login/backendCs.Tests/bin/Debug/net8.0/ja/Microsoft.TestPlatform.CoreUtilities.resources.dll
|
||||||
|
/home/arch/projects/unfinished/timelog-interview-login/backendCs.Tests/bin/Debug/net8.0/ja/Microsoft.VisualStudio.TestPlatform.ObjectModel.resources.dll
|
||||||
|
/home/arch/projects/unfinished/timelog-interview-login/backendCs.Tests/bin/Debug/net8.0/ko/Microsoft.TestPlatform.CoreUtilities.resources.dll
|
||||||
|
/home/arch/projects/unfinished/timelog-interview-login/backendCs.Tests/bin/Debug/net8.0/ko/Microsoft.VisualStudio.TestPlatform.ObjectModel.resources.dll
|
||||||
|
/home/arch/projects/unfinished/timelog-interview-login/backendCs.Tests/bin/Debug/net8.0/pl/Microsoft.TestPlatform.CoreUtilities.resources.dll
|
||||||
|
/home/arch/projects/unfinished/timelog-interview-login/backendCs.Tests/bin/Debug/net8.0/pl/Microsoft.VisualStudio.TestPlatform.ObjectModel.resources.dll
|
||||||
|
/home/arch/projects/unfinished/timelog-interview-login/backendCs.Tests/bin/Debug/net8.0/pt-BR/Microsoft.TestPlatform.CoreUtilities.resources.dll
|
||||||
|
/home/arch/projects/unfinished/timelog-interview-login/backendCs.Tests/bin/Debug/net8.0/pt-BR/Microsoft.VisualStudio.TestPlatform.ObjectModel.resources.dll
|
||||||
|
/home/arch/projects/unfinished/timelog-interview-login/backendCs.Tests/bin/Debug/net8.0/ru/Microsoft.TestPlatform.CoreUtilities.resources.dll
|
||||||
|
/home/arch/projects/unfinished/timelog-interview-login/backendCs.Tests/bin/Debug/net8.0/ru/Microsoft.VisualStudio.TestPlatform.ObjectModel.resources.dll
|
||||||
|
/home/arch/projects/unfinished/timelog-interview-login/backendCs.Tests/bin/Debug/net8.0/tr/Microsoft.TestPlatform.CoreUtilities.resources.dll
|
||||||
|
/home/arch/projects/unfinished/timelog-interview-login/backendCs.Tests/bin/Debug/net8.0/tr/Microsoft.VisualStudio.TestPlatform.ObjectModel.resources.dll
|
||||||
|
/home/arch/projects/unfinished/timelog-interview-login/backendCs.Tests/bin/Debug/net8.0/zh-Hans/Microsoft.TestPlatform.CoreUtilities.resources.dll
|
||||||
|
/home/arch/projects/unfinished/timelog-interview-login/backendCs.Tests/bin/Debug/net8.0/zh-Hans/Microsoft.VisualStudio.TestPlatform.ObjectModel.resources.dll
|
||||||
|
/home/arch/projects/unfinished/timelog-interview-login/backendCs.Tests/bin/Debug/net8.0/zh-Hant/Microsoft.TestPlatform.CoreUtilities.resources.dll
|
||||||
|
/home/arch/projects/unfinished/timelog-interview-login/backendCs.Tests/bin/Debug/net8.0/zh-Hant/Microsoft.VisualStudio.TestPlatform.ObjectModel.resources.dll
|
||||||
|
/home/arch/projects/unfinished/timelog-interview-login/backendCs.Tests/bin/Debug/net8.0/cs/Microsoft.TestPlatform.CommunicationUtilities.resources.dll
|
||||||
|
/home/arch/projects/unfinished/timelog-interview-login/backendCs.Tests/bin/Debug/net8.0/cs/Microsoft.TestPlatform.CrossPlatEngine.resources.dll
|
||||||
|
/home/arch/projects/unfinished/timelog-interview-login/backendCs.Tests/bin/Debug/net8.0/cs/Microsoft.VisualStudio.TestPlatform.Common.resources.dll
|
||||||
|
/home/arch/projects/unfinished/timelog-interview-login/backendCs.Tests/bin/Debug/net8.0/de/Microsoft.TestPlatform.CommunicationUtilities.resources.dll
|
||||||
|
/home/arch/projects/unfinished/timelog-interview-login/backendCs.Tests/bin/Debug/net8.0/de/Microsoft.TestPlatform.CrossPlatEngine.resources.dll
|
||||||
|
/home/arch/projects/unfinished/timelog-interview-login/backendCs.Tests/bin/Debug/net8.0/de/Microsoft.VisualStudio.TestPlatform.Common.resources.dll
|
||||||
|
/home/arch/projects/unfinished/timelog-interview-login/backendCs.Tests/bin/Debug/net8.0/es/Microsoft.TestPlatform.CommunicationUtilities.resources.dll
|
||||||
|
/home/arch/projects/unfinished/timelog-interview-login/backendCs.Tests/bin/Debug/net8.0/es/Microsoft.TestPlatform.CrossPlatEngine.resources.dll
|
||||||
|
/home/arch/projects/unfinished/timelog-interview-login/backendCs.Tests/bin/Debug/net8.0/es/Microsoft.VisualStudio.TestPlatform.Common.resources.dll
|
||||||
|
/home/arch/projects/unfinished/timelog-interview-login/backendCs.Tests/bin/Debug/net8.0/fr/Microsoft.TestPlatform.CommunicationUtilities.resources.dll
|
||||||
|
/home/arch/projects/unfinished/timelog-interview-login/backendCs.Tests/bin/Debug/net8.0/fr/Microsoft.TestPlatform.CrossPlatEngine.resources.dll
|
||||||
|
/home/arch/projects/unfinished/timelog-interview-login/backendCs.Tests/bin/Debug/net8.0/fr/Microsoft.VisualStudio.TestPlatform.Common.resources.dll
|
||||||
|
/home/arch/projects/unfinished/timelog-interview-login/backendCs.Tests/bin/Debug/net8.0/it/Microsoft.TestPlatform.CommunicationUtilities.resources.dll
|
||||||
|
/home/arch/projects/unfinished/timelog-interview-login/backendCs.Tests/bin/Debug/net8.0/it/Microsoft.TestPlatform.CrossPlatEngine.resources.dll
|
||||||
|
/home/arch/projects/unfinished/timelog-interview-login/backendCs.Tests/bin/Debug/net8.0/it/Microsoft.VisualStudio.TestPlatform.Common.resources.dll
|
||||||
|
/home/arch/projects/unfinished/timelog-interview-login/backendCs.Tests/bin/Debug/net8.0/ja/Microsoft.TestPlatform.CommunicationUtilities.resources.dll
|
||||||
|
/home/arch/projects/unfinished/timelog-interview-login/backendCs.Tests/bin/Debug/net8.0/ja/Microsoft.TestPlatform.CrossPlatEngine.resources.dll
|
||||||
|
/home/arch/projects/unfinished/timelog-interview-login/backendCs.Tests/bin/Debug/net8.0/ja/Microsoft.VisualStudio.TestPlatform.Common.resources.dll
|
||||||
|
/home/arch/projects/unfinished/timelog-interview-login/backendCs.Tests/bin/Debug/net8.0/ko/Microsoft.TestPlatform.CommunicationUtilities.resources.dll
|
||||||
|
/home/arch/projects/unfinished/timelog-interview-login/backendCs.Tests/bin/Debug/net8.0/ko/Microsoft.TestPlatform.CrossPlatEngine.resources.dll
|
||||||
|
/home/arch/projects/unfinished/timelog-interview-login/backendCs.Tests/bin/Debug/net8.0/ko/Microsoft.VisualStudio.TestPlatform.Common.resources.dll
|
||||||
|
/home/arch/projects/unfinished/timelog-interview-login/backendCs.Tests/bin/Debug/net8.0/pl/Microsoft.TestPlatform.CommunicationUtilities.resources.dll
|
||||||
|
/home/arch/projects/unfinished/timelog-interview-login/backendCs.Tests/bin/Debug/net8.0/pl/Microsoft.TestPlatform.CrossPlatEngine.resources.dll
|
||||||
|
/home/arch/projects/unfinished/timelog-interview-login/backendCs.Tests/bin/Debug/net8.0/pl/Microsoft.VisualStudio.TestPlatform.Common.resources.dll
|
||||||
|
/home/arch/projects/unfinished/timelog-interview-login/backendCs.Tests/bin/Debug/net8.0/pt-BR/Microsoft.TestPlatform.CommunicationUtilities.resources.dll
|
||||||
|
/home/arch/projects/unfinished/timelog-interview-login/backendCs.Tests/bin/Debug/net8.0/pt-BR/Microsoft.TestPlatform.CrossPlatEngine.resources.dll
|
||||||
|
/home/arch/projects/unfinished/timelog-interview-login/backendCs.Tests/bin/Debug/net8.0/pt-BR/Microsoft.VisualStudio.TestPlatform.Common.resources.dll
|
||||||
|
/home/arch/projects/unfinished/timelog-interview-login/backendCs.Tests/bin/Debug/net8.0/ru/Microsoft.TestPlatform.CommunicationUtilities.resources.dll
|
||||||
|
/home/arch/projects/unfinished/timelog-interview-login/backendCs.Tests/bin/Debug/net8.0/ru/Microsoft.TestPlatform.CrossPlatEngine.resources.dll
|
||||||
|
/home/arch/projects/unfinished/timelog-interview-login/backendCs.Tests/bin/Debug/net8.0/ru/Microsoft.VisualStudio.TestPlatform.Common.resources.dll
|
||||||
|
/home/arch/projects/unfinished/timelog-interview-login/backendCs.Tests/bin/Debug/net8.0/tr/Microsoft.TestPlatform.CommunicationUtilities.resources.dll
|
||||||
|
/home/arch/projects/unfinished/timelog-interview-login/backendCs.Tests/bin/Debug/net8.0/tr/Microsoft.TestPlatform.CrossPlatEngine.resources.dll
|
||||||
|
/home/arch/projects/unfinished/timelog-interview-login/backendCs.Tests/bin/Debug/net8.0/tr/Microsoft.VisualStudio.TestPlatform.Common.resources.dll
|
||||||
|
/home/arch/projects/unfinished/timelog-interview-login/backendCs.Tests/bin/Debug/net8.0/zh-Hans/Microsoft.TestPlatform.CommunicationUtilities.resources.dll
|
||||||
|
/home/arch/projects/unfinished/timelog-interview-login/backendCs.Tests/bin/Debug/net8.0/zh-Hans/Microsoft.TestPlatform.CrossPlatEngine.resources.dll
|
||||||
|
/home/arch/projects/unfinished/timelog-interview-login/backendCs.Tests/bin/Debug/net8.0/zh-Hans/Microsoft.VisualStudio.TestPlatform.Common.resources.dll
|
||||||
|
/home/arch/projects/unfinished/timelog-interview-login/backendCs.Tests/bin/Debug/net8.0/zh-Hant/Microsoft.TestPlatform.CommunicationUtilities.resources.dll
|
||||||
|
/home/arch/projects/unfinished/timelog-interview-login/backendCs.Tests/bin/Debug/net8.0/zh-Hant/Microsoft.TestPlatform.CrossPlatEngine.resources.dll
|
||||||
|
/home/arch/projects/unfinished/timelog-interview-login/backendCs.Tests/bin/Debug/net8.0/zh-Hant/Microsoft.VisualStudio.TestPlatform.Common.resources.dll
|
||||||
|
/home/arch/projects/unfinished/timelog-interview-login/backendCs.Tests/bin/Debug/net8.0/cs/Microsoft.VisualStudio.TestPlatform.TestFramework.resources.dll
|
||||||
|
/home/arch/projects/unfinished/timelog-interview-login/backendCs.Tests/bin/Debug/net8.0/de/Microsoft.VisualStudio.TestPlatform.TestFramework.resources.dll
|
||||||
|
/home/arch/projects/unfinished/timelog-interview-login/backendCs.Tests/bin/Debug/net8.0/es/Microsoft.VisualStudio.TestPlatform.TestFramework.resources.dll
|
||||||
|
/home/arch/projects/unfinished/timelog-interview-login/backendCs.Tests/bin/Debug/net8.0/fr/Microsoft.VisualStudio.TestPlatform.TestFramework.resources.dll
|
||||||
|
/home/arch/projects/unfinished/timelog-interview-login/backendCs.Tests/bin/Debug/net8.0/it/Microsoft.VisualStudio.TestPlatform.TestFramework.resources.dll
|
||||||
|
/home/arch/projects/unfinished/timelog-interview-login/backendCs.Tests/bin/Debug/net8.0/ja/Microsoft.VisualStudio.TestPlatform.TestFramework.resources.dll
|
||||||
|
/home/arch/projects/unfinished/timelog-interview-login/backendCs.Tests/bin/Debug/net8.0/ko/Microsoft.VisualStudio.TestPlatform.TestFramework.resources.dll
|
||||||
|
/home/arch/projects/unfinished/timelog-interview-login/backendCs.Tests/bin/Debug/net8.0/pl/Microsoft.VisualStudio.TestPlatform.TestFramework.resources.dll
|
||||||
|
/home/arch/projects/unfinished/timelog-interview-login/backendCs.Tests/bin/Debug/net8.0/pt-BR/Microsoft.VisualStudio.TestPlatform.TestFramework.resources.dll
|
||||||
|
/home/arch/projects/unfinished/timelog-interview-login/backendCs.Tests/bin/Debug/net8.0/ru/Microsoft.VisualStudio.TestPlatform.TestFramework.resources.dll
|
||||||
|
/home/arch/projects/unfinished/timelog-interview-login/backendCs.Tests/bin/Debug/net8.0/tr/Microsoft.VisualStudio.TestPlatform.TestFramework.resources.dll
|
||||||
|
/home/arch/projects/unfinished/timelog-interview-login/backendCs.Tests/bin/Debug/net8.0/zh-Hans/Microsoft.VisualStudio.TestPlatform.TestFramework.resources.dll
|
||||||
|
/home/arch/projects/unfinished/timelog-interview-login/backendCs.Tests/bin/Debug/net8.0/zh-Hant/Microsoft.VisualStudio.TestPlatform.TestFramework.resources.dll
|
||||||
|
/home/arch/projects/unfinished/timelog-interview-login/backendCs.Tests/bin/Debug/net8.0/Microsoft.VisualStudio.TestPlatform.TestFramework.Extensions.dll
|
||||||
|
/home/arch/projects/unfinished/timelog-interview-login/backendCs.Tests/bin/Debug/net8.0/Microsoft.VisualStudio.TestPlatform.TestFramework.Extensions.xml
|
||||||
|
/home/arch/projects/unfinished/timelog-interview-login/backendCs.Tests/obj/Debug/net8.0/backendCs.Test.csproj.AssemblyReference.cache
|
||||||
|
/home/arch/projects/unfinished/timelog-interview-login/backendCs.Tests/obj/Debug/net8.0/backendCs.Test.GeneratedMSBuildEditorConfig.editorconfig
|
||||||
|
/home/arch/projects/unfinished/timelog-interview-login/backendCs.Tests/obj/Debug/net8.0/backendCs.Test.AssemblyInfoInputs.cache
|
||||||
|
/home/arch/projects/unfinished/timelog-interview-login/backendCs.Tests/obj/Debug/net8.0/backendCs.Test.AssemblyInfo.cs
|
||||||
|
/home/arch/projects/unfinished/timelog-interview-login/backendCs.Tests/obj/Debug/net8.0/backendCs.Test.csproj.CoreCompileInputs.cache
|
||||||
|
/home/arch/projects/unfinished/timelog-interview-login/backendCs.Tests/obj/Debug/net8.0/backendCs.Test.csproj.CopyComplete
|
||||||
|
/home/arch/projects/unfinished/timelog-interview-login/backendCs.Tests/obj/Debug/net8.0/backendCs.Test.dll
|
||||||
|
/home/arch/projects/unfinished/timelog-interview-login/backendCs.Tests/obj/Debug/net8.0/refint/backendCs.Test.dll
|
||||||
|
/home/arch/projects/unfinished/timelog-interview-login/backendCs.Tests/obj/Debug/net8.0/backendCs.Test.pdb
|
||||||
|
/home/arch/projects/unfinished/timelog-interview-login/backendCs.Tests/obj/Debug/net8.0/backendCs.Test.genruntimeconfig.cache
|
||||||
|
/home/arch/projects/unfinished/timelog-interview-login/backendCs.Tests/obj/Debug/net8.0/ref/backendCs.Test.dll
|
||||||
|
|||||||
Binary file not shown.
@@ -1 +1 @@
|
|||||||
d00baeaa72366c300b98f70a63e07318bcfbf2aac3aa8140adbf3514d041b139
|
44ffb3de93f5803a95865b1f18602ffa1a9e69b6b29642e60dde4719a8b98d5a
|
||||||
|
|||||||
Binary file not shown.
Binary file not shown.
Binary file not shown.
@@ -1,17 +1,17 @@
|
|||||||
{
|
{
|
||||||
"format": 1,
|
"format": 1,
|
||||||
"restore": {
|
"restore": {
|
||||||
"/home/arch/projects/wip/timelog-interview-login/backendCs.Tests/backendCs.Test.csproj": {}
|
"/home/arch/projects/unfinished/timelog-interview-login/backendCs.Tests/backendCs.Test.csproj": {}
|
||||||
},
|
},
|
||||||
"projects": {
|
"projects": {
|
||||||
"/home/arch/projects/wip/timelog-interview-login/backendCs.Tests/backendCs.Test.csproj": {
|
"/home/arch/projects/unfinished/timelog-interview-login/backendCs.Tests/backendCs.Test.csproj": {
|
||||||
"version": "1.0.0",
|
"version": "1.0.0",
|
||||||
"restore": {
|
"restore": {
|
||||||
"projectUniqueName": "/home/arch/projects/wip/timelog-interview-login/backendCs.Tests/backendCs.Test.csproj",
|
"projectUniqueName": "/home/arch/projects/unfinished/timelog-interview-login/backendCs.Tests/backendCs.Test.csproj",
|
||||||
"projectName": "backendCs.Test",
|
"projectName": "backendCs.Test",
|
||||||
"projectPath": "/home/arch/projects/wip/timelog-interview-login/backendCs.Tests/backendCs.Test.csproj",
|
"projectPath": "/home/arch/projects/unfinished/timelog-interview-login/backendCs.Tests/backendCs.Test.csproj",
|
||||||
"packagesPath": "/home/arch/.nuget/packages/",
|
"packagesPath": "/home/arch/.nuget/packages/",
|
||||||
"outputPath": "/home/arch/projects/wip/timelog-interview-login/backendCs.Tests/obj/",
|
"outputPath": "/home/arch/projects/unfinished/timelog-interview-login/backendCs.Tests/obj/",
|
||||||
"projectStyle": "PackageReference",
|
"projectStyle": "PackageReference",
|
||||||
"configFilePaths": [
|
"configFilePaths": [
|
||||||
"/home/arch/.nuget/NuGet/NuGet.Config"
|
"/home/arch/.nuget/NuGet/NuGet.Config"
|
||||||
|
|||||||
@@ -1074,11 +1074,11 @@
|
|||||||
"project": {
|
"project": {
|
||||||
"version": "1.0.0",
|
"version": "1.0.0",
|
||||||
"restore": {
|
"restore": {
|
||||||
"projectUniqueName": "/home/arch/projects/wip/timelog-interview-login/backendCs.Tests/backendCs.Test.csproj",
|
"projectUniqueName": "/home/arch/projects/unfinished/timelog-interview-login/backendCs.Tests/backendCs.Test.csproj",
|
||||||
"projectName": "backendCs.Test",
|
"projectName": "backendCs.Test",
|
||||||
"projectPath": "/home/arch/projects/wip/timelog-interview-login/backendCs.Tests/backendCs.Test.csproj",
|
"projectPath": "/home/arch/projects/unfinished/timelog-interview-login/backendCs.Tests/backendCs.Test.csproj",
|
||||||
"packagesPath": "/home/arch/.nuget/packages/",
|
"packagesPath": "/home/arch/.nuget/packages/",
|
||||||
"outputPath": "/home/arch/projects/wip/timelog-interview-login/backendCs.Tests/obj/",
|
"outputPath": "/home/arch/projects/unfinished/timelog-interview-login/backendCs.Tests/obj/",
|
||||||
"projectStyle": "PackageReference",
|
"projectStyle": "PackageReference",
|
||||||
"configFilePaths": [
|
"configFilePaths": [
|
||||||
"/home/arch/.nuget/NuGet/NuGet.Config"
|
"/home/arch/.nuget/NuGet/NuGet.Config"
|
||||||
|
|||||||
@@ -1,8 +1,8 @@
|
|||||||
{
|
{
|
||||||
"version": 2,
|
"version": 2,
|
||||||
"dgSpecHash": "MZ1XesT3wmy51PIeGVUHDrPKvcZQbJPK8azHwfm2TlnGmdOSh+BLO5idLCALy5ldv/F004Vk+wySJwTZrnTuCw==",
|
"dgSpecHash": "Vow09WffKk6/6DguUqZNKmUYQdDCPGVBuip3M7OhLkceXUGI4wJgx+a7soIu/yv29h91cY3hReluc8rAg5j2ug==",
|
||||||
"success": true,
|
"success": true,
|
||||||
"projectFilePath": "/home/arch/projects/wip/timelog-interview-login/backendCs.Tests/backendCs.Test.csproj",
|
"projectFilePath": "/home/arch/projects/unfinished/timelog-interview-login/backendCs.Tests/backendCs.Test.csproj",
|
||||||
"expectedPackageFiles": [
|
"expectedPackageFiles": [
|
||||||
"/home/arch/.nuget/packages/coverlet.collector/6.0.0/coverlet.collector.6.0.0.nupkg.sha512",
|
"/home/arch/.nuget/packages/coverlet.collector/6.0.0/coverlet.collector.6.0.0.nupkg.sha512",
|
||||||
"/home/arch/.nuget/packages/microsoft.codecoverage/17.6.0/microsoft.codecoverage.17.6.0.nupkg.sha512",
|
"/home/arch/.nuget/packages/microsoft.codecoverage/17.6.0/microsoft.codecoverage.17.6.0.nupkg.sha512",
|
||||||
|
|||||||
+80
-81
@@ -1,102 +1,101 @@
|
|||||||
using System.Net;
|
using System.Net;
|
||||||
using System.Text;
|
using System.Text;
|
||||||
|
|
||||||
namespace Server
|
namespace Server;
|
||||||
|
|
||||||
|
class Program
|
||||||
{
|
{
|
||||||
class Program
|
static void HandleMissingPath(HttpListenerResponse response)
|
||||||
{
|
{
|
||||||
static void HandleMissingPath(HttpListenerResponse response)
|
response.StatusCode = 404;
|
||||||
{
|
string errorMessage = "Not Found";
|
||||||
response.StatusCode = 404;
|
byte[] buffer = Encoding.UTF8.GetBytes(errorMessage);
|
||||||
string errorMessage = "Not Found";
|
response.ContentType = "text/plain";
|
||||||
byte[] buffer = Encoding.UTF8.GetBytes(errorMessage);
|
response.ContentLength64 = buffer.Length;
|
||||||
response.ContentType = "text/plain";
|
response.OutputStream.Write(buffer, 0, buffer.Length);
|
||||||
response.ContentLength64 = buffer.Length;
|
response.OutputStream.Write(buffer, 0, buffer.Length);
|
||||||
response.OutputStream.Write(buffer, 0, buffer.Length);
|
}
|
||||||
response.OutputStream.Write(buffer, 0, buffer.Length);
|
|
||||||
}
|
|
||||||
|
|
||||||
static void Main()
|
static void Main()
|
||||||
{
|
{
|
||||||
// create server
|
// create server
|
||||||
HttpListener listener = new HttpListener();
|
HttpListener listener = new();
|
||||||
// routes need to be added first
|
// routes need to be added first
|
||||||
listener.Prefixes.Add("http://localhost:5000/api/getall/");
|
listener.Prefixes.Add("http://localhost:5000/api/getall/");
|
||||||
listener.Prefixes.Add("http://localhost:5000/api/gettopten/");
|
listener.Prefixes.Add("http://localhost:5000/api/gettopten/");
|
||||||
listener.Prefixes.Add("http://localhost:5000/api/getuser/");
|
listener.Prefixes.Add("http://localhost:5000/api/getuser/");
|
||||||
listener.Prefixes.Add("http://localhost:5000/api/reset/");
|
listener.Prefixes.Add("http://localhost:5000/api/reset/");
|
||||||
listener.Prefixes.Add("http://localhost:5000/api/createp/");
|
listener.Prefixes.Add("http://localhost:5000/api/createp/");
|
||||||
listener.Prefixes.Add("http://localhost:5000/api/register/");
|
listener.Prefixes.Add("http://localhost:5000/api/register/");
|
||||||
listener.Prefixes.Add("http://localhost:5000/api/login/");
|
listener.Prefixes.Add("http://localhost:5000/api/login/");
|
||||||
listener.Prefixes.Add("http://localhost:5000/api/createlog/");
|
listener.Prefixes.Add("http://localhost:5000/api/createlog/");
|
||||||
|
|
||||||
// listen
|
// listen
|
||||||
listener.Start();
|
listener.Start();
|
||||||
Console.WriteLine("Server is listening on http://localhost:5000/");
|
Console.WriteLine("Server is listening on http://localhost:5000/");
|
||||||
while (true)
|
while (true)
|
||||||
|
{
|
||||||
|
HttpListenerContext context = listener.GetContext();
|
||||||
|
HttpListenerRequest request = context.Request;
|
||||||
|
HttpListenerResponse response = context.Response;
|
||||||
|
// url after localhost:5000/
|
||||||
|
string uri;
|
||||||
|
if (request != null && request.Url != null)
|
||||||
|
uri = request.Url.AbsolutePath;
|
||||||
|
else
|
||||||
|
return;
|
||||||
|
switch (request.HttpMethod)
|
||||||
{
|
{
|
||||||
HttpListenerContext context = listener.GetContext();
|
case "GET":
|
||||||
HttpListenerRequest request = context.Request;
|
switch (uri)
|
||||||
HttpListenerResponse response = context.Response;
|
{
|
||||||
// url after localhost:5000/
|
case "/api/reset":
|
||||||
string uri;
|
Reset.HandleRequest(response);
|
||||||
if (request != null && request.Url != null)
|
break;
|
||||||
uri = request.Url.AbsolutePath;
|
case "/api/getall":
|
||||||
else
|
/* Thread clientThread = new Thread(() => Getall.HandleRequest(request, response)); */
|
||||||
return;
|
/* clientThread.Start(); */
|
||||||
switch (request.HttpMethod)
|
Getall.HandleRequest(request, response);
|
||||||
{
|
break;
|
||||||
case "GET":
|
case "/api/gettopten":
|
||||||
|
Gettopten.HandleRequest(request, response);
|
||||||
|
break;
|
||||||
|
case "/api/getuser":
|
||||||
|
Getuser.HandleRequest(request, response);
|
||||||
|
break;
|
||||||
|
case "/api/createp":
|
||||||
|
CreateProcedure.HandleRequest(response);
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
HandleMissingPath(response);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
case "POST":
|
||||||
|
if (request.HasEntityBody)
|
||||||
switch (uri)
|
switch (uri)
|
||||||
{
|
{
|
||||||
case "/api/reset":
|
case "/api/register":
|
||||||
Reset.HandleRequest(request, response);
|
Register.HandleRequest(request, response);
|
||||||
break;
|
break;
|
||||||
case "/api/getall":
|
case "/api/login":
|
||||||
/* Thread clientThread = new Thread(() => Getall.HandleRequest(request, response)); */
|
Login.HandleRequest(request, response);
|
||||||
/* clientThread.Start(); */
|
|
||||||
Getall.HandleRequest(request, response);
|
|
||||||
break;
|
break;
|
||||||
case "/api/gettopten":
|
case "/api/createlog":
|
||||||
Gettopten.HandleRequest(request, response);
|
CreateLog.HandleRequest(request, response, context);
|
||||||
break;
|
|
||||||
case "/api/getuser":
|
|
||||||
Getuser.HandleRequest(request, response);
|
|
||||||
break;
|
|
||||||
case "/api/createp":
|
|
||||||
CreateProcedure.HandleRequest(request, response);
|
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
HandleMissingPath(response);
|
HandleMissingPath(response);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
break;
|
else
|
||||||
case "POST":
|
{
|
||||||
if (request.HasEntityBody)
|
|
||||||
switch (uri)
|
|
||||||
{
|
|
||||||
case "/api/register":
|
|
||||||
Register.HandleRequest(request, response);
|
|
||||||
break;
|
|
||||||
case "/api/login":
|
|
||||||
Login.HandleRequest(request, response);
|
|
||||||
break;
|
|
||||||
case "/api/createlog":
|
|
||||||
CreateLog.HandleRequest(request, response, context);
|
|
||||||
break;
|
|
||||||
default:
|
|
||||||
HandleMissingPath(response);
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
HandleMissingPath(response);
|
|
||||||
}
|
|
||||||
break;
|
|
||||||
default:
|
|
||||||
HandleMissingPath(response);
|
HandleMissingPath(response);
|
||||||
break;
|
}
|
||||||
}
|
break;
|
||||||
|
default:
|
||||||
|
HandleMissingPath(response);
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Binary file not shown.
Binary file not shown.
@@ -13,7 +13,7 @@ using System.Reflection;
|
|||||||
[assembly: System.Reflection.AssemblyCompanyAttribute("TimelogBackend")]
|
[assembly: System.Reflection.AssemblyCompanyAttribute("TimelogBackend")]
|
||||||
[assembly: System.Reflection.AssemblyConfigurationAttribute("Debug")]
|
[assembly: System.Reflection.AssemblyConfigurationAttribute("Debug")]
|
||||||
[assembly: System.Reflection.AssemblyFileVersionAttribute("1.0.0.0")]
|
[assembly: System.Reflection.AssemblyFileVersionAttribute("1.0.0.0")]
|
||||||
[assembly: System.Reflection.AssemblyInformationalVersionAttribute("1.0.0+cb7b3ad94c91aad561fa90871a3e078e741f566c")]
|
[assembly: System.Reflection.AssemblyInformationalVersionAttribute("1.0.0+926436860cd34dec9ccf3feac66e4c63bae7ba8f")]
|
||||||
[assembly: System.Reflection.AssemblyProductAttribute("TimelogBackend")]
|
[assembly: System.Reflection.AssemblyProductAttribute("TimelogBackend")]
|
||||||
[assembly: System.Reflection.AssemblyTitleAttribute("TimelogBackend")]
|
[assembly: System.Reflection.AssemblyTitleAttribute("TimelogBackend")]
|
||||||
[assembly: System.Reflection.AssemblyVersionAttribute("1.0.0.0")]
|
[assembly: System.Reflection.AssemblyVersionAttribute("1.0.0.0")]
|
||||||
|
|||||||
@@ -1 +1 @@
|
|||||||
21ebdfea2f4ecbc0e48a6b53f27fa496a20e08b7ed0ace43e5500d5093c8a245
|
4d078ebec60178a78b052888e79c6e658ccc73953d1f8ba236008a06ecc632b9
|
||||||
|
|||||||
@@ -117,3 +117,46 @@
|
|||||||
/home/arch/projects/wip/timelog-interview-login/backendCs/bin/Debug/net8.0/Microsoft.IdentityModel.Logging.dll
|
/home/arch/projects/wip/timelog-interview-login/backendCs/bin/Debug/net8.0/Microsoft.IdentityModel.Logging.dll
|
||||||
/home/arch/projects/wip/timelog-interview-login/backendCs/bin/Debug/net8.0/Microsoft.IdentityModel.Tokens.dll
|
/home/arch/projects/wip/timelog-interview-login/backendCs/bin/Debug/net8.0/Microsoft.IdentityModel.Tokens.dll
|
||||||
/home/arch/projects/wip/timelog-interview-login/backendCs/bin/Debug/net8.0/System.IdentityModel.Tokens.Jwt.dll
|
/home/arch/projects/wip/timelog-interview-login/backendCs/bin/Debug/net8.0/System.IdentityModel.Tokens.Jwt.dll
|
||||||
|
/home/arch/projects/unfinished/timelog-interview-login/backendCs/obj/Debug/net8.0/TimelogBackend.csproj.AssemblyReference.cache
|
||||||
|
/home/arch/projects/unfinished/timelog-interview-login/backendCs/obj/Debug/net8.0/TimelogBackend.GeneratedMSBuildEditorConfig.editorconfig
|
||||||
|
/home/arch/projects/unfinished/timelog-interview-login/backendCs/obj/Debug/net8.0/TimelogBackend.AssemblyInfoInputs.cache
|
||||||
|
/home/arch/projects/unfinished/timelog-interview-login/backendCs/obj/Debug/net8.0/TimelogBackend.AssemblyInfo.cs
|
||||||
|
/home/arch/projects/unfinished/timelog-interview-login/backendCs/obj/Debug/net8.0/TimelogBackend.csproj.CoreCompileInputs.cache
|
||||||
|
/home/arch/projects/unfinished/timelog-interview-login/backendCs/obj/Debug/net8.0/TimelogBackend.dll
|
||||||
|
/home/arch/projects/unfinished/timelog-interview-login/backendCs/obj/Debug/net8.0/refint/TimelogBackend.dll
|
||||||
|
/home/arch/projects/unfinished/timelog-interview-login/backendCs/obj/Debug/net8.0/TimelogBackend.pdb
|
||||||
|
/home/arch/projects/unfinished/timelog-interview-login/backendCs/bin/Debug/net8.0/TimelogBackend
|
||||||
|
/home/arch/projects/unfinished/timelog-interview-login/backendCs/bin/Debug/net8.0/TimelogBackend.deps.json
|
||||||
|
/home/arch/projects/unfinished/timelog-interview-login/backendCs/bin/Debug/net8.0/TimelogBackend.runtimeconfig.json
|
||||||
|
/home/arch/projects/unfinished/timelog-interview-login/backendCs/bin/Debug/net8.0/TimelogBackend.dll
|
||||||
|
/home/arch/projects/unfinished/timelog-interview-login/backendCs/bin/Debug/net8.0/TimelogBackend.pdb
|
||||||
|
/home/arch/projects/unfinished/timelog-interview-login/backendCs/bin/Debug/net8.0/BouncyCastle.Cryptography.dll
|
||||||
|
/home/arch/projects/unfinished/timelog-interview-login/backendCs/bin/Debug/net8.0/Google.Protobuf.dll
|
||||||
|
/home/arch/projects/unfinished/timelog-interview-login/backendCs/bin/Debug/net8.0/K4os.Compression.LZ4.dll
|
||||||
|
/home/arch/projects/unfinished/timelog-interview-login/backendCs/bin/Debug/net8.0/K4os.Compression.LZ4.Streams.dll
|
||||||
|
/home/arch/projects/unfinished/timelog-interview-login/backendCs/bin/Debug/net8.0/K4os.Hash.xxHash.dll
|
||||||
|
/home/arch/projects/unfinished/timelog-interview-login/backendCs/bin/Debug/net8.0/Microsoft.IdentityModel.Abstractions.dll
|
||||||
|
/home/arch/projects/unfinished/timelog-interview-login/backendCs/bin/Debug/net8.0/Microsoft.IdentityModel.JsonWebTokens.dll
|
||||||
|
/home/arch/projects/unfinished/timelog-interview-login/backendCs/bin/Debug/net8.0/Microsoft.IdentityModel.Logging.dll
|
||||||
|
/home/arch/projects/unfinished/timelog-interview-login/backendCs/bin/Debug/net8.0/Microsoft.IdentityModel.Tokens.dll
|
||||||
|
/home/arch/projects/unfinished/timelog-interview-login/backendCs/bin/Debug/net8.0/MySql.Data.dll
|
||||||
|
/home/arch/projects/unfinished/timelog-interview-login/backendCs/bin/Debug/net8.0/Newtonsoft.Json.dll
|
||||||
|
/home/arch/projects/unfinished/timelog-interview-login/backendCs/bin/Debug/net8.0/System.Configuration.ConfigurationManager.dll
|
||||||
|
/home/arch/projects/unfinished/timelog-interview-login/backendCs/bin/Debug/net8.0/System.Diagnostics.EventLog.dll
|
||||||
|
/home/arch/projects/unfinished/timelog-interview-login/backendCs/bin/Debug/net8.0/System.IdentityModel.Tokens.Jwt.dll
|
||||||
|
/home/arch/projects/unfinished/timelog-interview-login/backendCs/bin/Debug/net8.0/System.IO.Pipelines.dll
|
||||||
|
/home/arch/projects/unfinished/timelog-interview-login/backendCs/bin/Debug/net8.0/System.Security.Cryptography.ProtectedData.dll
|
||||||
|
/home/arch/projects/unfinished/timelog-interview-login/backendCs/bin/Debug/net8.0/System.Security.Permissions.dll
|
||||||
|
/home/arch/projects/unfinished/timelog-interview-login/backendCs/bin/Debug/net8.0/System.Windows.Extensions.dll
|
||||||
|
/home/arch/projects/unfinished/timelog-interview-login/backendCs/bin/Debug/net8.0/ZstdSharp.dll
|
||||||
|
/home/arch/projects/unfinished/timelog-interview-login/backendCs/bin/Debug/net8.0/runtimes/win-x64/native/comerr64.dll
|
||||||
|
/home/arch/projects/unfinished/timelog-interview-login/backendCs/bin/Debug/net8.0/runtimes/win-x64/native/gssapi64.dll
|
||||||
|
/home/arch/projects/unfinished/timelog-interview-login/backendCs/bin/Debug/net8.0/runtimes/win-x64/native/k5sprt64.dll
|
||||||
|
/home/arch/projects/unfinished/timelog-interview-login/backendCs/bin/Debug/net8.0/runtimes/win-x64/native/krb5_64.dll
|
||||||
|
/home/arch/projects/unfinished/timelog-interview-login/backendCs/bin/Debug/net8.0/runtimes/win-x64/native/krbcc64.dll
|
||||||
|
/home/arch/projects/unfinished/timelog-interview-login/backendCs/bin/Debug/net8.0/runtimes/win/lib/net8.0/System.Diagnostics.EventLog.Messages.dll
|
||||||
|
/home/arch/projects/unfinished/timelog-interview-login/backendCs/bin/Debug/net8.0/runtimes/win/lib/net8.0/System.Diagnostics.EventLog.dll
|
||||||
|
/home/arch/projects/unfinished/timelog-interview-login/backendCs/bin/Debug/net8.0/runtimes/win/lib/net8.0/System.Windows.Extensions.dll
|
||||||
|
/home/arch/projects/unfinished/timelog-interview-login/backendCs/obj/Debug/net8.0/TimelogBackend.csproj.CopyComplete
|
||||||
|
/home/arch/projects/unfinished/timelog-interview-login/backendCs/obj/Debug/net8.0/TimelogBackend.genruntimeconfig.cache
|
||||||
|
/home/arch/projects/unfinished/timelog-interview-login/backendCs/obj/Debug/net8.0/ref/TimelogBackend.dll
|
||||||
|
|||||||
Binary file not shown.
@@ -1 +1 @@
|
|||||||
cabec8eef32bfb7a5e67f2b4ed57839edd7c13e8479c77f87a2d35ec66b02abb
|
6ce12d87876379d820297a17b33b1f57ff3987d74bed581fb7ebcc8c73660966
|
||||||
|
|||||||
Binary file not shown.
Binary file not shown.
Binary file not shown.
@@ -1,17 +1,17 @@
|
|||||||
{
|
{
|
||||||
"format": 1,
|
"format": 1,
|
||||||
"restore": {
|
"restore": {
|
||||||
"/home/arch/projects/wip/timelog-interview-login/backendCs/TimelogBackend.csproj": {}
|
"/home/arch/projects/unfinished/timelog-interview-login/backendCs/TimelogBackend.csproj": {}
|
||||||
},
|
},
|
||||||
"projects": {
|
"projects": {
|
||||||
"/home/arch/projects/wip/timelog-interview-login/backendCs/TimelogBackend.csproj": {
|
"/home/arch/projects/unfinished/timelog-interview-login/backendCs/TimelogBackend.csproj": {
|
||||||
"version": "1.0.0",
|
"version": "1.0.0",
|
||||||
"restore": {
|
"restore": {
|
||||||
"projectUniqueName": "/home/arch/projects/wip/timelog-interview-login/backendCs/TimelogBackend.csproj",
|
"projectUniqueName": "/home/arch/projects/unfinished/timelog-interview-login/backendCs/TimelogBackend.csproj",
|
||||||
"projectName": "TimelogBackend",
|
"projectName": "TimelogBackend",
|
||||||
"projectPath": "/home/arch/projects/wip/timelog-interview-login/backendCs/TimelogBackend.csproj",
|
"projectPath": "/home/arch/projects/unfinished/timelog-interview-login/backendCs/TimelogBackend.csproj",
|
||||||
"packagesPath": "/home/arch/.nuget/packages/",
|
"packagesPath": "/home/arch/.nuget/packages/",
|
||||||
"outputPath": "/home/arch/projects/wip/timelog-interview-login/backendCs/obj/",
|
"outputPath": "/home/arch/projects/unfinished/timelog-interview-login/backendCs/obj/",
|
||||||
"projectStyle": "PackageReference",
|
"projectStyle": "PackageReference",
|
||||||
"configFilePaths": [
|
"configFilePaths": [
|
||||||
"/home/arch/.nuget/NuGet/NuGet.Config"
|
"/home/arch/.nuget/NuGet/NuGet.Config"
|
||||||
|
|||||||
@@ -1857,11 +1857,11 @@
|
|||||||
"project": {
|
"project": {
|
||||||
"version": "1.0.0",
|
"version": "1.0.0",
|
||||||
"restore": {
|
"restore": {
|
||||||
"projectUniqueName": "/home/arch/projects/wip/timelog-interview-login/backendCs/TimelogBackend.csproj",
|
"projectUniqueName": "/home/arch/projects/unfinished/timelog-interview-login/backendCs/TimelogBackend.csproj",
|
||||||
"projectName": "TimelogBackend",
|
"projectName": "TimelogBackend",
|
||||||
"projectPath": "/home/arch/projects/wip/timelog-interview-login/backendCs/TimelogBackend.csproj",
|
"projectPath": "/home/arch/projects/unfinished/timelog-interview-login/backendCs/TimelogBackend.csproj",
|
||||||
"packagesPath": "/home/arch/.nuget/packages/",
|
"packagesPath": "/home/arch/.nuget/packages/",
|
||||||
"outputPath": "/home/arch/projects/wip/timelog-interview-login/backendCs/obj/",
|
"outputPath": "/home/arch/projects/unfinished/timelog-interview-login/backendCs/obj/",
|
||||||
"projectStyle": "PackageReference",
|
"projectStyle": "PackageReference",
|
||||||
"configFilePaths": [
|
"configFilePaths": [
|
||||||
"/home/arch/.nuget/NuGet/NuGet.Config"
|
"/home/arch/.nuget/NuGet/NuGet.Config"
|
||||||
|
|||||||
@@ -1,8 +1,8 @@
|
|||||||
{
|
{
|
||||||
"version": 2,
|
"version": 2,
|
||||||
"dgSpecHash": "lhoNhBuhv5pZb43QtTahPtHclYQU5heHEQPyTVS7gTLS0zI+oKRmmyzvVbe56/iHd4Yw20shJvPbIdrCOp+Qug==",
|
"dgSpecHash": "Kw1QiagALZErTv+cX8IjNVaHlG1vVsZ8jbQdO6NwgQJYGShK1fNvP3A258Ci81RECrzVlyi53zgZ5YHVjUaNOw==",
|
||||||
"success": true,
|
"success": true,
|
||||||
"projectFilePath": "/home/arch/projects/wip/timelog-interview-login/backendCs/TimelogBackend.csproj",
|
"projectFilePath": "/home/arch/projects/unfinished/timelog-interview-login/backendCs/TimelogBackend.csproj",
|
||||||
"expectedPackageFiles": [
|
"expectedPackageFiles": [
|
||||||
"/home/arch/.nuget/packages/bouncycastle.cryptography/2.3.1/bouncycastle.cryptography.2.3.1.nupkg.sha512",
|
"/home/arch/.nuget/packages/bouncycastle.cryptography/2.3.1/bouncycastle.cryptography.2.3.1.nupkg.sha512",
|
||||||
"/home/arch/.nuget/packages/google.protobuf/3.26.1/google.protobuf.3.26.1.nupkg.sha512",
|
"/home/arch/.nuget/packages/google.protobuf/3.26.1/google.protobuf.3.26.1.nupkg.sha512",
|
||||||
|
|||||||
+109
-110
@@ -6,125 +6,124 @@ using Microsoft.IdentityModel.Tokens;
|
|||||||
using MySql.Data.MySqlClient;
|
using MySql.Data.MySqlClient;
|
||||||
using Newtonsoft.Json.Linq;
|
using Newtonsoft.Json.Linq;
|
||||||
|
|
||||||
namespace Server
|
namespace Server;
|
||||||
|
|
||||||
|
public class CreateLog : Route
|
||||||
{
|
{
|
||||||
public class CreateLog : Route
|
private static string secretKey =
|
||||||
|
"stronk-key-much-sercret-much-more-stronk-stronk-key-much-sercret-much-more-stronk";
|
||||||
|
|
||||||
|
private static bool ValidateToken(string token)
|
||||||
{
|
{
|
||||||
private static string secretKey =
|
try
|
||||||
"stronk-key-much-sercret-much-more-stronk-stronk-key-much-sercret-much-more-stronk";
|
|
||||||
|
|
||||||
private static bool ValidateToken(string token)
|
|
||||||
{
|
{
|
||||||
try
|
var key = new SymmetricSecurityKey(Encoding.UTF8.GetBytes(secretKey));
|
||||||
|
var tokenHandler = new JwtSecurityTokenHandler();
|
||||||
|
var validationParameters = new TokenValidationParameters
|
||||||
{
|
{
|
||||||
var key = new SymmetricSecurityKey(Encoding.UTF8.GetBytes(secretKey));
|
ValidateIssuer = true,
|
||||||
var tokenHandler = new JwtSecurityTokenHandler();
|
ValidateAudience = true,
|
||||||
var validationParameters = new TokenValidationParameters
|
ValidateLifetime = true,
|
||||||
{
|
ValidIssuer = "TimeLogServer",
|
||||||
ValidateIssuer = true,
|
ValidAudience = "TimeLogWebsite",
|
||||||
ValidateAudience = true,
|
IssuerSigningKey = key,
|
||||||
ValidateLifetime = true,
|
};
|
||||||
ValidIssuer = "TimeLogServer",
|
|
||||||
ValidAudience = "TimeLogWebsite",
|
|
||||||
IssuerSigningKey = key,
|
|
||||||
};
|
|
||||||
|
|
||||||
var principal = tokenHandler.ValidateToken(
|
var principal = tokenHandler.ValidateToken(
|
||||||
token,
|
token,
|
||||||
validationParameters,
|
validationParameters,
|
||||||
out SecurityToken validatedToken
|
out SecurityToken validatedToken
|
||||||
);
|
);
|
||||||
return validatedToken != null;
|
return validatedToken != null;
|
||||||
}
|
}
|
||||||
catch
|
catch
|
||||||
|
{
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public static void HandleRequest(
|
||||||
|
HttpListenerRequest request,
|
||||||
|
HttpListenerResponse response,
|
||||||
|
HttpListenerContext context
|
||||||
|
)
|
||||||
|
{
|
||||||
|
try
|
||||||
|
{
|
||||||
|
// check header
|
||||||
|
var headers = request.Headers;
|
||||||
|
string? token = headers["token"];
|
||||||
|
if (!string.IsNullOrEmpty(token) && !ValidateToken(token))
|
||||||
{
|
{
|
||||||
return false;
|
throw new Exception("Invalid token");
|
||||||
|
}
|
||||||
|
// prepare SQL query
|
||||||
|
MySqlCommand cmd = new MySqlCommand();
|
||||||
|
// extact data from body
|
||||||
|
string body;
|
||||||
|
using (
|
||||||
|
StreamReader bodyReader = new StreamReader(
|
||||||
|
request.InputStream,
|
||||||
|
request.ContentEncoding
|
||||||
|
)
|
||||||
|
)
|
||||||
|
{
|
||||||
|
body = bodyReader.ReadToEnd();
|
||||||
|
}
|
||||||
|
JObject jsonObject = JObject.Parse(body);
|
||||||
|
string project = jsonObject["project"]?.ToString() ?? "";
|
||||||
|
string time = jsonObject["time"]?.ToString() ?? "";
|
||||||
|
string date = jsonObject["date"]?.ToString() ?? "";
|
||||||
|
|
||||||
|
// TODO check if the hours on given date don't combine to more
|
||||||
|
// than 8
|
||||||
|
|
||||||
|
// validate time
|
||||||
|
if (!int.TryParse(time, out int myInt) || myInt < 0 || myInt > 8)
|
||||||
|
throw new Exception("Incorect ammount of hours");
|
||||||
|
// validate date
|
||||||
|
Regex regex = new Regex(@"^\d{4}-\d{2}-\d{2}$");
|
||||||
|
if (string.IsNullOrEmpty(date) || !regex.IsMatch(date))
|
||||||
|
{
|
||||||
|
throw new Exception("Incorrect date format");
|
||||||
|
}
|
||||||
|
// validate user
|
||||||
|
// extract user from jwt
|
||||||
|
var handler = new JwtSecurityTokenHandler();
|
||||||
|
var jwtToken = handler.ReadJwtToken(token);
|
||||||
|
string? usernameClaim =
|
||||||
|
jwtToken.Claims.FirstOrDefault(c => c.Type == "user")?.Value ?? "";
|
||||||
|
if (string.IsNullOrEmpty(usernameClaim))
|
||||||
|
{
|
||||||
|
throw new Exception("wrong user id");
|
||||||
|
}
|
||||||
|
|
||||||
|
// validate project
|
||||||
|
// TODO better project validation
|
||||||
|
if (string.IsNullOrEmpty(project))
|
||||||
|
{
|
||||||
|
throw new Exception("wrong project");
|
||||||
|
}
|
||||||
|
using (MySqlConnection conn = new MySqlConnection(connectionString))
|
||||||
|
{
|
||||||
|
conn.Open();
|
||||||
|
cmd.Connection = conn;
|
||||||
|
cmd.CommandText =
|
||||||
|
@"INSERT INTO Timelog(user,project,date,time)
|
||||||
|
VALUES(@user,@project,@date,@time);";
|
||||||
|
cmd.Parameters.AddWithValue("@user", usernameClaim);
|
||||||
|
cmd.Parameters.AddWithValue("@project", project);
|
||||||
|
cmd.Parameters.AddWithValue("@time", time);
|
||||||
|
cmd.Parameters.AddWithValue("@date", date);
|
||||||
|
// execute query and read results
|
||||||
|
cmd.ExecuteNonQuery();
|
||||||
|
|
||||||
|
SendSuccess(response);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
catch (Exception ex)
|
||||||
public static void HandleRequest(
|
|
||||||
HttpListenerRequest request,
|
|
||||||
HttpListenerResponse response,
|
|
||||||
HttpListenerContext context
|
|
||||||
)
|
|
||||||
{
|
{
|
||||||
try
|
SendError(response, ex);
|
||||||
{
|
|
||||||
// check header
|
|
||||||
var headers = request.Headers;
|
|
||||||
string? token = headers["token"];
|
|
||||||
if (!string.IsNullOrEmpty(token) && !ValidateToken(token))
|
|
||||||
{
|
|
||||||
throw new Exception("Invalid token");
|
|
||||||
}
|
|
||||||
// prepare SQL query
|
|
||||||
MySqlCommand cmd = new MySqlCommand();
|
|
||||||
// extact data from body
|
|
||||||
string body;
|
|
||||||
using (
|
|
||||||
StreamReader bodyReader = new StreamReader(
|
|
||||||
request.InputStream,
|
|
||||||
request.ContentEncoding
|
|
||||||
)
|
|
||||||
)
|
|
||||||
{
|
|
||||||
body = bodyReader.ReadToEnd();
|
|
||||||
}
|
|
||||||
JObject jsonObject = JObject.Parse(body);
|
|
||||||
string project = jsonObject["project"]?.ToString() ?? "";
|
|
||||||
string time = jsonObject["time"]?.ToString() ?? "";
|
|
||||||
string date = jsonObject["date"]?.ToString() ?? "";
|
|
||||||
|
|
||||||
// TODO check if the hours on given date don't combine to more
|
|
||||||
// than 8
|
|
||||||
|
|
||||||
// validate time
|
|
||||||
if (!int.TryParse(time, out int myInt) || myInt < 0 || myInt > 8)
|
|
||||||
throw new Exception("Incorect ammount of hours");
|
|
||||||
// validate date
|
|
||||||
Regex regex = new Regex(@"^\d{4}-\d{2}-\d{2}$");
|
|
||||||
if (string.IsNullOrEmpty(date) || !regex.IsMatch(date))
|
|
||||||
{
|
|
||||||
throw new Exception("Incorrect date format");
|
|
||||||
}
|
|
||||||
// validate user
|
|
||||||
// extract user from jwt
|
|
||||||
var handler = new JwtSecurityTokenHandler();
|
|
||||||
var jwtToken = handler.ReadJwtToken(token);
|
|
||||||
string? usernameClaim =
|
|
||||||
jwtToken.Claims.FirstOrDefault(c => c.Type == "user")?.Value ?? "";
|
|
||||||
if (string.IsNullOrEmpty(usernameClaim))
|
|
||||||
{
|
|
||||||
throw new Exception("wrong user id");
|
|
||||||
}
|
|
||||||
|
|
||||||
// validate project
|
|
||||||
// TODO better project validation
|
|
||||||
if (string.IsNullOrEmpty(project))
|
|
||||||
{
|
|
||||||
throw new Exception("wrong project");
|
|
||||||
}
|
|
||||||
using (MySqlConnection conn = new MySqlConnection(connectionString))
|
|
||||||
{
|
|
||||||
conn.Open();
|
|
||||||
cmd.Connection = conn;
|
|
||||||
cmd.CommandText =
|
|
||||||
@"INSERT INTO Timelog(user,project,date,time)
|
|
||||||
VALUES(@user,@project,@date,@time);";
|
|
||||||
cmd.Parameters.AddWithValue("@user", usernameClaim);
|
|
||||||
cmd.Parameters.AddWithValue("@project", project);
|
|
||||||
cmd.Parameters.AddWithValue("@time", time);
|
|
||||||
cmd.Parameters.AddWithValue("@date", date);
|
|
||||||
// execute query and read results
|
|
||||||
cmd.ExecuteNonQuery();
|
|
||||||
|
|
||||||
SendSuccess(response);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
catch (Exception ex)
|
|
||||||
{
|
|
||||||
SendError(response, ex);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,22 +1,22 @@
|
|||||||
using System.Net;
|
using System.Net;
|
||||||
using MySql.Data.MySqlClient;
|
using MySql.Data.MySqlClient;
|
||||||
|
|
||||||
namespace Server
|
namespace Server;
|
||||||
{
|
|
||||||
public class CreateProcedure : Route
|
|
||||||
{
|
|
||||||
public static void HandleRequest(HttpListenerRequest request, HttpListenerResponse response)
|
|
||||||
{
|
|
||||||
try
|
|
||||||
{
|
|
||||||
MySqlCommand cmd = new MySqlCommand();
|
|
||||||
|
|
||||||
using (MySqlConnection conn = new MySqlConnection(connectionString))
|
public class CreateProcedure : Route
|
||||||
{
|
{
|
||||||
conn.Open();
|
public static void HandleRequest(HttpListenerResponse response)
|
||||||
cmd.Connection = conn;
|
{
|
||||||
cmd.CommandText =
|
try
|
||||||
@"
|
{
|
||||||
|
MySqlCommand cmd = new();
|
||||||
|
|
||||||
|
using (MySqlConnection conn = new(connectionString))
|
||||||
|
{
|
||||||
|
conn.Open();
|
||||||
|
cmd.Connection = conn;
|
||||||
|
cmd.CommandText =
|
||||||
|
@"
|
||||||
CREATE PROCEDURE fill_timelog ()
|
CREATE PROCEDURE fill_timelog ()
|
||||||
BEGIN
|
BEGIN
|
||||||
DECLARE j INT DEFAULT 1;
|
DECLARE j INT DEFAULT 1;
|
||||||
@@ -53,9 +53,9 @@ BEGIN
|
|||||||
SET users = users + 1;
|
SET users = users + 1;
|
||||||
END WHILE;
|
END WHILE;
|
||||||
END;";
|
END;";
|
||||||
cmd.ExecuteNonQuery();
|
cmd.ExecuteNonQuery();
|
||||||
cmd.CommandText =
|
cmd.CommandText =
|
||||||
@"CREATE PROCEDURE InitDB()
|
@"CREATE PROCEDURE InitDB()
|
||||||
BEGIN
|
BEGIN
|
||||||
DECLARE i INT DEFAULT 1;
|
DECLARE i INT DEFAULT 1;
|
||||||
TRUNCATE TABLE Timelog;
|
TRUNCATE TABLE Timelog;
|
||||||
@@ -116,15 +116,14 @@ BEGIN
|
|||||||
DROP TABLE temp_fname;
|
DROP TABLE temp_fname;
|
||||||
DROP TABLE temp_lname;
|
DROP TABLE temp_lname;
|
||||||
END;";
|
END;";
|
||||||
cmd.ExecuteNonQuery();
|
cmd.ExecuteNonQuery();
|
||||||
// prepare response
|
// prepare response
|
||||||
SendSuccess(response);
|
SendSuccess(response);
|
||||||
}
|
|
||||||
}
|
|
||||||
catch (Exception ex)
|
|
||||||
{
|
|
||||||
SendError(response, ex);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
catch (Exception ex)
|
||||||
|
{
|
||||||
|
SendError(response, ex);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
+98
-99
@@ -3,113 +3,112 @@ using System.Text.RegularExpressions;
|
|||||||
using MySql.Data.MySqlClient;
|
using MySql.Data.MySqlClient;
|
||||||
using Newtonsoft.Json;
|
using Newtonsoft.Json;
|
||||||
|
|
||||||
namespace Server
|
namespace Server;
|
||||||
{
|
|
||||||
// there should be a better way to deal with data comming from sql
|
|
||||||
public class Log
|
|
||||||
{
|
|
||||||
public object? f_name { get; set; }
|
|
||||||
public object? l_name { get; set; }
|
|
||||||
public object? mail { get; set; }
|
|
||||||
public object? name { get; set; }
|
|
||||||
public object? time { get; set; }
|
|
||||||
public object? date { get; set; }
|
|
||||||
public object? user { get; set; }
|
|
||||||
}
|
|
||||||
|
|
||||||
public class Getall : Route
|
// there should be a better way to deal with data comming from sql
|
||||||
|
public class Log
|
||||||
|
{
|
||||||
|
public object? f_name { get; set; }
|
||||||
|
public object? l_name { get; set; }
|
||||||
|
public object? mail { get; set; }
|
||||||
|
public object? name { get; set; }
|
||||||
|
public object? time { get; set; }
|
||||||
|
public object? date { get; set; }
|
||||||
|
public object? user { get; set; }
|
||||||
|
}
|
||||||
|
|
||||||
|
public class Getall : Route
|
||||||
|
{
|
||||||
|
public static void HandleRequest(HttpListenerRequest request, HttpListenerResponse response)
|
||||||
{
|
{
|
||||||
public static void HandleRequest(HttpListenerRequest request, HttpListenerResponse response)
|
try
|
||||||
{
|
{
|
||||||
try
|
// prepare SQL query
|
||||||
{
|
MySqlCommand cmd = new();
|
||||||
// prepare SQL query
|
// get url params
|
||||||
MySqlCommand cmd = new MySqlCommand();
|
var queryString = request.QueryString;
|
||||||
// get url params
|
string? from = queryString["from"];
|
||||||
var queryString = request.QueryString;
|
string? to = queryString["to"];
|
||||||
string? from = queryString["from"];
|
string? sortby = queryString["sortby"];
|
||||||
string? to = queryString["to"];
|
string? offset = queryString["offset"];
|
||||||
string? sortby = queryString["sortby"];
|
string? order = queryString["order"];
|
||||||
string? offset = queryString["offset"];
|
order = order == "true" ? "ASC" : "DESC";
|
||||||
string? order = queryString["order"];
|
string mainQuery =
|
||||||
order = order == "true" ? "ASC" : "DESC";
|
@"SELECT u.f_name,u.l_name,u.mail,p.name,t.time,t.date,t.user
|
||||||
string mainQuery =
|
|
||||||
@"SELECT u.f_name,u.l_name,u.mail,p.name,t.time,t.date,t.user
|
|
||||||
FROM Timelog t
|
FROM Timelog t
|
||||||
INNER JOIN Project p ON p.id=t.project
|
INNER JOIN Project p ON p.id=t.project
|
||||||
INNER JOIN User u ON u.id=t.user ";
|
INNER JOIN User u ON u.id=t.user ";
|
||||||
// this shenanigan is needed to remove the "" around group by
|
// this shenanigan is needed to remove the "" around group by
|
||||||
string offsetQuery = " LIMIT 10 OFFSET " + offset + ";";
|
string offsetQuery = " LIMIT 10 OFFSET " + offset + ";";
|
||||||
// depending on the incoming parameters construct a Query
|
// depending on the incoming parameters construct a Query
|
||||||
if (!string.IsNullOrEmpty(to) && !string.IsNullOrEmpty(from))
|
if (!string.IsNullOrEmpty(to) && !string.IsNullOrEmpty(from))
|
||||||
{
|
|
||||||
Regex regex = new Regex(@"^\d{4}-\d{2}-\d{2}$");
|
|
||||||
if (!regex.IsMatch(to) || !regex.IsMatch(from))
|
|
||||||
{
|
|
||||||
throw new Exception("Incorrect date format");
|
|
||||||
}
|
|
||||||
string whereQuery = " WHERE t.date BETWEEN @from AND @to ";
|
|
||||||
mainQuery = mainQuery + whereQuery;
|
|
||||||
}
|
|
||||||
if (!string.IsNullOrEmpty(sortby))
|
|
||||||
{
|
|
||||||
List<string> validSorting = new List<string>
|
|
||||||
{
|
|
||||||
"f_name",
|
|
||||||
"l_name",
|
|
||||||
"mail",
|
|
||||||
"time",
|
|
||||||
"date",
|
|
||||||
"user",
|
|
||||||
"project",
|
|
||||||
};
|
|
||||||
if (!validSorting.Contains(sortby))
|
|
||||||
{
|
|
||||||
throw new Exception("Incorrect sorting value");
|
|
||||||
}
|
|
||||||
string orderQuery = " ORDER BY " + sortby + " " + order;
|
|
||||||
mainQuery = mainQuery + orderQuery;
|
|
||||||
}
|
|
||||||
if (!int.TryParse(offset, out int myInt) || myInt < 0)
|
|
||||||
throw new Exception("Incorect offset");
|
|
||||||
// add the final line to the query
|
|
||||||
cmd.CommandText = mainQuery + offsetQuery;
|
|
||||||
// those don't produce error if they don't find their variables
|
|
||||||
cmd.Parameters.AddWithValue("@from", from);
|
|
||||||
cmd.Parameters.AddWithValue("@to", to);
|
|
||||||
|
|
||||||
using (MySqlConnection conn = new MySqlConnection(connectionString))
|
|
||||||
{
|
|
||||||
conn.Open();
|
|
||||||
cmd.Connection = conn;
|
|
||||||
// execute query and read results
|
|
||||||
MySqlDataReader reader = cmd.ExecuteReader();
|
|
||||||
|
|
||||||
List<Log> entries = new List<Log>();
|
|
||||||
while (reader.Read())
|
|
||||||
{
|
|
||||||
entries.Add(
|
|
||||||
new Log
|
|
||||||
{
|
|
||||||
f_name = reader["f_name"],
|
|
||||||
l_name = reader["l_name"],
|
|
||||||
user = reader["user"],
|
|
||||||
date = reader["date"],
|
|
||||||
name = reader["name"],
|
|
||||||
time = reader["time"],
|
|
||||||
mail = reader["mail"],
|
|
||||||
}
|
|
||||||
);
|
|
||||||
}
|
|
||||||
// serialize JSON
|
|
||||||
string jsonResponse = JsonConvert.SerializeObject(entries);
|
|
||||||
SendSuccess(response, jsonResponse);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
catch (Exception ex)
|
|
||||||
{
|
{
|
||||||
SendError(response, ex);
|
Regex regex = new Regex(@"^\d{4}-\d{2}-\d{2}$");
|
||||||
|
if (!regex.IsMatch(to) || !regex.IsMatch(from))
|
||||||
|
{
|
||||||
|
throw new Exception("Incorrect date format");
|
||||||
|
}
|
||||||
|
string whereQuery = " WHERE t.date BETWEEN @from AND @to ";
|
||||||
|
mainQuery = mainQuery + whereQuery;
|
||||||
}
|
}
|
||||||
|
if (!string.IsNullOrEmpty(sortby))
|
||||||
|
{
|
||||||
|
List<string> validSorting =
|
||||||
|
[
|
||||||
|
"f_name",
|
||||||
|
"l_name",
|
||||||
|
"mail",
|
||||||
|
"time",
|
||||||
|
"date",
|
||||||
|
"user",
|
||||||
|
"project",
|
||||||
|
];
|
||||||
|
if (!validSorting.Contains(sortby))
|
||||||
|
{
|
||||||
|
throw new Exception("Incorrect sorting value");
|
||||||
|
}
|
||||||
|
string orderQuery = " ORDER BY " + sortby + " " + order;
|
||||||
|
mainQuery = mainQuery + orderQuery;
|
||||||
|
}
|
||||||
|
if (!int.TryParse(offset, out int myInt) || myInt < 0)
|
||||||
|
throw new Exception("Incorect offset");
|
||||||
|
// add the final line to the query
|
||||||
|
cmd.CommandText = mainQuery + offsetQuery;
|
||||||
|
// those don't produce error if they don't find their variables
|
||||||
|
cmd.Parameters.AddWithValue("@from", from);
|
||||||
|
cmd.Parameters.AddWithValue("@to", to);
|
||||||
|
|
||||||
|
using (MySqlConnection conn = new(connectionString))
|
||||||
|
{
|
||||||
|
conn.Open();
|
||||||
|
cmd.Connection = conn;
|
||||||
|
// execute query and read results
|
||||||
|
MySqlDataReader reader = cmd.ExecuteReader();
|
||||||
|
|
||||||
|
List<Log> entries = [];
|
||||||
|
while (reader.Read())
|
||||||
|
{
|
||||||
|
entries.Add(
|
||||||
|
new Log
|
||||||
|
{
|
||||||
|
f_name = reader["f_name"],
|
||||||
|
l_name = reader["l_name"],
|
||||||
|
user = reader["user"],
|
||||||
|
date = reader["date"],
|
||||||
|
name = reader["name"],
|
||||||
|
time = reader["time"],
|
||||||
|
mail = reader["mail"],
|
||||||
|
}
|
||||||
|
);
|
||||||
|
}
|
||||||
|
// serialize JSON
|
||||||
|
string jsonResponse = JsonConvert.SerializeObject(entries);
|
||||||
|
SendSuccess(response, jsonResponse);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
catch (Exception ex)
|
||||||
|
{
|
||||||
|
SendError(response, ex);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -3,101 +3,100 @@ using System.Text.RegularExpressions;
|
|||||||
using MySql.Data.MySqlClient;
|
using MySql.Data.MySqlClient;
|
||||||
using Newtonsoft.Json;
|
using Newtonsoft.Json;
|
||||||
|
|
||||||
namespace Server
|
namespace Server;
|
||||||
|
|
||||||
|
public class TopTen
|
||||||
{
|
{
|
||||||
public class TopTen
|
public object? user { get; set; }
|
||||||
{
|
public object? date { get; set; }
|
||||||
public object? user { get; set; }
|
public object? project { get; set; }
|
||||||
public object? date { get; set; }
|
public object? f_name { get; set; }
|
||||||
public object? project { get; set; }
|
public object? l_name { get; set; }
|
||||||
public object? f_name { get; set; }
|
public object? name { get; set; }
|
||||||
public object? l_name { get; set; }
|
public object? total_time { get; set; }
|
||||||
public object? name { get; set; }
|
}
|
||||||
public object? total_time { get; set; }
|
|
||||||
}
|
|
||||||
|
|
||||||
public class Gettopten : Route
|
public class Gettopten : Route
|
||||||
|
{
|
||||||
|
public static void HandleRequest(HttpListenerRequest request, HttpListenerResponse response)
|
||||||
{
|
{
|
||||||
public static void HandleRequest(HttpListenerRequest request, HttpListenerResponse response)
|
try
|
||||||
{
|
{
|
||||||
try
|
// prepare SQL query
|
||||||
|
MySqlCommand cmd = new();
|
||||||
|
var queryString = request.QueryString;
|
||||||
|
string? from = queryString["from"];
|
||||||
|
string? to = queryString["to"];
|
||||||
|
string? filterBy = queryString["filterBy"];
|
||||||
|
|
||||||
|
if (!string.IsNullOrEmpty(to) && !string.IsNullOrEmpty(from))
|
||||||
{
|
{
|
||||||
// prepare SQL query
|
Regex regex = new Regex(@"^\d{4}-\d{2}-\d{2}$");
|
||||||
MySqlCommand cmd = new MySqlCommand();
|
if (!regex.IsMatch(to) || !regex.IsMatch(from))
|
||||||
var queryString = request.QueryString;
|
{
|
||||||
string? from = queryString["from"];
|
throw new Exception("Incorrect date format");
|
||||||
string? to = queryString["to"];
|
}
|
||||||
string? filterBy = queryString["filterBy"];
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
throw new Exception("Empty date format");
|
||||||
|
}
|
||||||
|
if (string.IsNullOrEmpty(filterBy))
|
||||||
|
{
|
||||||
|
throw new Exception("Empty filterby");
|
||||||
|
}
|
||||||
|
if (filterBy != "user" && filterBy != "project")
|
||||||
|
{
|
||||||
|
throw new Exception("Incorrect filterby");
|
||||||
|
}
|
||||||
|
|
||||||
if (!string.IsNullOrEmpty(to) && !string.IsNullOrEmpty(from))
|
// this shenanigan is needed to remove the "" around
|
||||||
{
|
// group by
|
||||||
Regex regex = new Regex(@"^\d{4}-\d{2}-\d{2}$");
|
string req =
|
||||||
if (!regex.IsMatch(to) || !regex.IsMatch(from))
|
@"SELECT t.user,t.date,t.project,u.f_name,u.l_name,p.name,SUM(t.time) as total_time
|
||||||
{
|
|
||||||
throw new Exception("Incorrect date format");
|
|
||||||
}
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
throw new Exception("Empty date format");
|
|
||||||
}
|
|
||||||
if (string.IsNullOrEmpty(filterBy))
|
|
||||||
{
|
|
||||||
throw new Exception("Empty filterby");
|
|
||||||
}
|
|
||||||
if (filterBy != "user" && filterBy != "project")
|
|
||||||
{
|
|
||||||
throw new Exception("Incorrect filterby");
|
|
||||||
}
|
|
||||||
|
|
||||||
// this shenanigan is needed to remove the "" around
|
|
||||||
// group by
|
|
||||||
string req =
|
|
||||||
@"SELECT t.user,t.date,t.project,u.f_name,u.l_name,p.name,SUM(t.time) as total_time
|
|
||||||
FROM Timelog t
|
FROM Timelog t
|
||||||
INNER JOIN Project p ON p.id=t.project
|
INNER JOIN Project p ON p.id=t.project
|
||||||
INNER JOIN User u ON u.id=t.user
|
INNER JOIN User u ON u.id=t.user
|
||||||
WHERE t.date BETWEEN @from AND @to
|
WHERE t.date BETWEEN @from AND @to
|
||||||
GROUP BY "
|
GROUP BY "
|
||||||
+ filterBy
|
+ filterBy
|
||||||
+ @" ORDER BY total_time DESC
|
+ @" ORDER BY total_time DESC
|
||||||
LIMIT 10;";
|
LIMIT 10;";
|
||||||
cmd.CommandText = req;
|
cmd.CommandText = req;
|
||||||
cmd.Parameters.AddWithValue("@from", from);
|
cmd.Parameters.AddWithValue("@from", from);
|
||||||
cmd.Parameters.AddWithValue("@to", to);
|
cmd.Parameters.AddWithValue("@to", to);
|
||||||
|
|
||||||
using (MySqlConnection conn = new MySqlConnection(connectionString))
|
using (MySqlConnection conn = new(connectionString))
|
||||||
{
|
|
||||||
cmd.Connection = conn;
|
|
||||||
conn.Open();
|
|
||||||
// Execute the query and read the results
|
|
||||||
MySqlDataReader reader = cmd.ExecuteReader();
|
|
||||||
List<TopTen> entries = new List<TopTen>();
|
|
||||||
while (reader.Read())
|
|
||||||
{
|
|
||||||
entries.Add(
|
|
||||||
new TopTen
|
|
||||||
{
|
|
||||||
user = reader["user"],
|
|
||||||
date = reader["date"],
|
|
||||||
project = reader["project"],
|
|
||||||
f_name = reader["f_name"],
|
|
||||||
l_name = reader["l_name"],
|
|
||||||
name = reader["name"],
|
|
||||||
total_time = reader["total_time"],
|
|
||||||
}
|
|
||||||
);
|
|
||||||
}
|
|
||||||
// Serialize the data to JSON
|
|
||||||
string jsonResponse = JsonConvert.SerializeObject(entries);
|
|
||||||
// prepare response
|
|
||||||
SendSuccess(response, jsonResponse);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
catch (Exception ex)
|
|
||||||
{
|
{
|
||||||
SendError(response, ex);
|
cmd.Connection = conn;
|
||||||
|
conn.Open();
|
||||||
|
// Execute the query and read the results
|
||||||
|
MySqlDataReader reader = cmd.ExecuteReader();
|
||||||
|
List<TopTen> entries = [];
|
||||||
|
while (reader.Read())
|
||||||
|
{
|
||||||
|
entries.Add(
|
||||||
|
new TopTen
|
||||||
|
{
|
||||||
|
user = reader["user"],
|
||||||
|
date = reader["date"],
|
||||||
|
project = reader["project"],
|
||||||
|
f_name = reader["f_name"],
|
||||||
|
l_name = reader["l_name"],
|
||||||
|
name = reader["name"],
|
||||||
|
total_time = reader["total_time"],
|
||||||
|
}
|
||||||
|
);
|
||||||
|
}
|
||||||
|
// Serialize the data to JSON
|
||||||
|
string jsonResponse = JsonConvert.SerializeObject(entries);
|
||||||
|
// prepare response
|
||||||
|
SendSuccess(response, jsonResponse);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
catch (Exception ex)
|
||||||
|
{
|
||||||
|
SendError(response, ex);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
+37
-36
@@ -3,54 +3,55 @@ using System.Net;
|
|||||||
using MySql.Data.MySqlClient;
|
using MySql.Data.MySqlClient;
|
||||||
using Newtonsoft.Json;
|
using Newtonsoft.Json;
|
||||||
|
|
||||||
namespace Server
|
namespace Server;
|
||||||
|
|
||||||
|
public class Getuser : Route
|
||||||
{
|
{
|
||||||
public class Getuser : Route
|
public static void HandleRequest(HttpListenerRequest request, HttpListenerResponse response)
|
||||||
{
|
{
|
||||||
public static void HandleRequest(HttpListenerRequest request, HttpListenerResponse response)
|
try
|
||||||
{
|
{
|
||||||
try
|
var queryString = request.QueryString;
|
||||||
|
string? userid = queryString["userid"];
|
||||||
|
if (string.IsNullOrEmpty(userid))
|
||||||
{
|
{
|
||||||
var queryString = request.QueryString;
|
throw new Exception("Missing userid");
|
||||||
string? userid = queryString["userid"];
|
}
|
||||||
if (string.IsNullOrEmpty(userid))
|
// prepare SQL query
|
||||||
{
|
MySqlCommand cmd = new()
|
||||||
throw new Exception("Missing userid");
|
{
|
||||||
}
|
CommandText =
|
||||||
// prepare SQL query
|
|
||||||
MySqlCommand cmd = new MySqlCommand();
|
|
||||||
cmd.CommandText =
|
|
||||||
@"SELECT p.name, SUM(t.time)
|
@"SELECT p.name, SUM(t.time)
|
||||||
FROM Timelog t
|
FROM Timelog t
|
||||||
INNER JOIN Project p ON p.id=t.project
|
INNER JOIN Project p ON p.id=t.project
|
||||||
INNER JOIN User u ON u.id=t.user
|
INNER JOIN User u ON u.id=t.user
|
||||||
WHERE User = @userid
|
WHERE User = @userid
|
||||||
GROUP BY name;";
|
GROUP BY name;",
|
||||||
cmd.Parameters.AddWithValue("@userid", userid);
|
};
|
||||||
|
cmd.Parameters.AddWithValue("@userid", userid);
|
||||||
|
|
||||||
using (MySqlConnection conn = new MySqlConnection(connectionString))
|
using (MySqlConnection conn = new(connectionString))
|
||||||
{
|
|
||||||
conn.Open();
|
|
||||||
cmd.Connection = conn;
|
|
||||||
// execute query and read results
|
|
||||||
MySqlDataReader reader = cmd.ExecuteReader();
|
|
||||||
dynamic expando = new ExpandoObject();
|
|
||||||
while (reader.Read())
|
|
||||||
{
|
|
||||||
((IDictionary<string?, object>)expando)[reader["name"].ToString()] = reader[
|
|
||||||
"SUM(t.time)"
|
|
||||||
];
|
|
||||||
}
|
|
||||||
// serialize JSON
|
|
||||||
string jsonResponse = JsonConvert.SerializeObject(expando);
|
|
||||||
// prepare response
|
|
||||||
SendSuccess(response, jsonResponse);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
catch (Exception ex)
|
|
||||||
{
|
{
|
||||||
SendError(response, ex);
|
conn.Open();
|
||||||
|
cmd.Connection = conn;
|
||||||
|
// execute query and read results
|
||||||
|
MySqlDataReader reader = cmd.ExecuteReader();
|
||||||
|
dynamic expando = new ExpandoObject();
|
||||||
|
while (reader.Read())
|
||||||
|
{
|
||||||
|
((IDictionary<string?, object>)expando)[reader["name"].ToString()] = reader[
|
||||||
|
"SUM(t.time)"
|
||||||
|
];
|
||||||
|
}
|
||||||
|
// serialize JSON
|
||||||
|
string jsonResponse = JsonConvert.SerializeObject(expando);
|
||||||
|
// prepare response
|
||||||
|
SendSuccess(response, jsonResponse);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
catch (Exception ex)
|
||||||
|
{
|
||||||
|
SendError(response, ex);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
+101
-105
@@ -8,126 +8,122 @@ using MySql.Data.MySqlClient;
|
|||||||
using Newtonsoft.Json;
|
using Newtonsoft.Json;
|
||||||
using Newtonsoft.Json.Linq;
|
using Newtonsoft.Json.Linq;
|
||||||
|
|
||||||
namespace Server
|
namespace Server;
|
||||||
|
|
||||||
|
public class Login : Route
|
||||||
{
|
{
|
||||||
public class Login : Route
|
private static string secretKey =
|
||||||
|
"stronk-key-much-sercret-much-more-stronk-stronk-key-much-sercret-much-more-stronk";
|
||||||
|
|
||||||
|
public static string GenerateToken(string user)
|
||||||
{
|
{
|
||||||
private static string secretKey =
|
var key = new SymmetricSecurityKey(Encoding.UTF8.GetBytes(secretKey));
|
||||||
"stronk-key-much-sercret-much-more-stronk-stronk-key-much-sercret-much-more-stronk";
|
var creds = new SigningCredentials(key, SecurityAlgorithms.HmacSha256);
|
||||||
|
|
||||||
public static string GenerateToken(string user)
|
var token = new JwtSecurityToken(
|
||||||
{
|
issuer: "TimeLogServer",
|
||||||
var key = new SymmetricSecurityKey(Encoding.UTF8.GetBytes(secretKey));
|
audience: "TimeLogWebsite",
|
||||||
var creds = new SigningCredentials(key, SecurityAlgorithms.HmacSha256);
|
claims: new[] { new Claim("user", user) },
|
||||||
|
expires: DateTime.Now.AddHours(2),
|
||||||
|
signingCredentials: creds
|
||||||
|
);
|
||||||
|
|
||||||
var token = new JwtSecurityToken(
|
return new JwtSecurityTokenHandler().WriteToken(token);
|
||||||
issuer: "TimeLogServer",
|
}
|
||||||
audience: "TimeLogWebsite",
|
|
||||||
claims: new[] { new Claim("user", user) },
|
|
||||||
expires: DateTime.Now.AddHours(2),
|
|
||||||
signingCredentials: creds
|
|
||||||
);
|
|
||||||
|
|
||||||
return new JwtSecurityTokenHandler().WriteToken(token);
|
public static bool VerifyPassword(string enteredPassword, string storedHash)
|
||||||
}
|
{
|
||||||
|
byte[] hashBytes = Convert.FromBase64String(storedHash);
|
||||||
|
|
||||||
public static bool VerifyPassword(string enteredPassword, string storedHash)
|
// Extract the salt from the stored hash
|
||||||
{
|
byte[] salt = new byte[16];
|
||||||
byte[] hashBytes = Convert.FromBase64String(storedHash);
|
Array.Copy(hashBytes, 0, salt, 0, 16);
|
||||||
|
|
||||||
// Extract the salt from the stored hash
|
// Hash the entered password with the stored salt
|
||||||
byte[] salt = new byte[16];
|
using (
|
||||||
Array.Copy(hashBytes, 0, salt, 0, 16);
|
var pbkdf2 = new Rfc2898DeriveBytes(
|
||||||
|
enteredPassword,
|
||||||
// Hash the entered password with the stored salt
|
salt,
|
||||||
using (
|
10000,
|
||||||
var pbkdf2 = new Rfc2898DeriveBytes(
|
HashAlgorithmName.SHA256
|
||||||
enteredPassword,
|
|
||||||
salt,
|
|
||||||
10000,
|
|
||||||
HashAlgorithmName.SHA256
|
|
||||||
)
|
|
||||||
)
|
)
|
||||||
{
|
)
|
||||||
byte[] newHash = pbkdf2.GetBytes(32);
|
|
||||||
|
|
||||||
// Compare the computed hash with the stored hash
|
|
||||||
for (int i = 0; i < 32; i++)
|
|
||||||
{
|
|
||||||
if (newHash[i] != hashBytes[i + 16])
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public static void HandleRequest(HttpListenerRequest request, HttpListenerResponse response)
|
|
||||||
{
|
{
|
||||||
try
|
byte[] newHash = pbkdf2.GetBytes(32);
|
||||||
{
|
|
||||||
// extract data from body
|
|
||||||
string body;
|
|
||||||
using (
|
|
||||||
StreamReader bodyReader = new StreamReader(
|
|
||||||
request.InputStream,
|
|
||||||
request.ContentEncoding
|
|
||||||
)
|
|
||||||
)
|
|
||||||
{
|
|
||||||
body = bodyReader.ReadToEnd();
|
|
||||||
}
|
|
||||||
JObject jsonObject = JObject.Parse(body);
|
|
||||||
string mail = jsonObject["mail"]?.ToString() ?? "";
|
|
||||||
string password = jsonObject["password"]?.ToString() ?? "";
|
|
||||||
|
|
||||||
// prepare SQL query
|
// Compare the computed hash with the stored hash
|
||||||
MySqlCommand cmd = new MySqlCommand();
|
for (int i = 0; i < 32; i++)
|
||||||
cmd.CommandText =
|
{
|
||||||
|
if (newHash[i] != hashBytes[i + 16])
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public static void HandleRequest(HttpListenerRequest request, HttpListenerResponse response)
|
||||||
|
{
|
||||||
|
try
|
||||||
|
{
|
||||||
|
// extract data from body
|
||||||
|
string body;
|
||||||
|
using (StreamReader bodyReader = new(request.InputStream, request.ContentEncoding))
|
||||||
|
{
|
||||||
|
body = bodyReader.ReadToEnd();
|
||||||
|
}
|
||||||
|
JObject jsonObject = JObject.Parse(body);
|
||||||
|
string mail = jsonObject["mail"]?.ToString() ?? "";
|
||||||
|
string password = jsonObject["password"]?.ToString() ?? "";
|
||||||
|
|
||||||
|
// prepare SQL query
|
||||||
|
MySqlCommand cmd = new()
|
||||||
|
{
|
||||||
|
CommandText =
|
||||||
@"SELECT u.id, password FROM User u
|
@"SELECT u.id, password FROM User u
|
||||||
INNER JOIN Password p ON p.user=u.id
|
INNER JOIN Password p ON p.user=u.id
|
||||||
WHERE mail=@mail;";
|
WHERE mail=@mail;",
|
||||||
cmd.Parameters.AddWithValue("@mail", mail);
|
};
|
||||||
|
cmd.Parameters.AddWithValue("@mail", mail);
|
||||||
|
|
||||||
using (MySqlConnection conn = new MySqlConnection(connectionString))
|
using (MySqlConnection conn = new(connectionString))
|
||||||
{
|
|
||||||
cmd.Connection = conn;
|
|
||||||
conn.Open();
|
|
||||||
// execute query and read results
|
|
||||||
MySqlDataReader reader = cmd.ExecuteReader();
|
|
||||||
string? userId = "";
|
|
||||||
string? hashedPass = "";
|
|
||||||
string? jsonResponse;
|
|
||||||
while (reader.Read())
|
|
||||||
{
|
|
||||||
userId = Convert.ToString(reader["id"]);
|
|
||||||
hashedPass = reader.GetString("password");
|
|
||||||
}
|
|
||||||
|
|
||||||
// check username
|
|
||||||
if (string.IsNullOrEmpty(userId))
|
|
||||||
{
|
|
||||||
throw new Exception("Invalid Username or Password");
|
|
||||||
}
|
|
||||||
//check password
|
|
||||||
if (
|
|
||||||
string.IsNullOrEmpty(password)
|
|
||||||
|| string.IsNullOrEmpty(hashedPass)
|
|
||||||
|| !VerifyPassword(password, hashedPass)
|
|
||||||
)
|
|
||||||
{
|
|
||||||
throw new Exception("Invalid Username or Password");
|
|
||||||
}
|
|
||||||
|
|
||||||
jsonResponse = JsonConvert.SerializeObject(GenerateToken(userId));
|
|
||||||
|
|
||||||
// prepare response
|
|
||||||
SendSuccess(response, jsonResponse);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
catch (Exception ex)
|
|
||||||
{
|
{
|
||||||
SendError(response, ex);
|
cmd.Connection = conn;
|
||||||
|
conn.Open();
|
||||||
|
// execute query and read results
|
||||||
|
MySqlDataReader reader = cmd.ExecuteReader();
|
||||||
|
string? userId = "";
|
||||||
|
string? hashedPass = "";
|
||||||
|
string? jsonResponse;
|
||||||
|
while (reader.Read())
|
||||||
|
{
|
||||||
|
userId = Convert.ToString(reader["id"]);
|
||||||
|
hashedPass = reader.GetString("password");
|
||||||
|
}
|
||||||
|
|
||||||
|
// check username
|
||||||
|
if (string.IsNullOrEmpty(userId))
|
||||||
|
{
|
||||||
|
throw new Exception("Invalid Username or Password");
|
||||||
|
}
|
||||||
|
//check password
|
||||||
|
if (
|
||||||
|
string.IsNullOrEmpty(password)
|
||||||
|
|| string.IsNullOrEmpty(hashedPass)
|
||||||
|
|| !VerifyPassword(password, hashedPass)
|
||||||
|
)
|
||||||
|
{
|
||||||
|
throw new Exception("Invalid Username or Password");
|
||||||
|
}
|
||||||
|
|
||||||
|
jsonResponse = JsonConvert.SerializeObject(GenerateToken(userId));
|
||||||
|
|
||||||
|
// prepare response
|
||||||
|
SendSuccess(response, jsonResponse);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
catch (Exception ex)
|
||||||
|
{
|
||||||
|
SendError(response, ex);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -3,113 +3,102 @@ using System.Security.Cryptography;
|
|||||||
using MySql.Data.MySqlClient;
|
using MySql.Data.MySqlClient;
|
||||||
using Newtonsoft.Json.Linq;
|
using Newtonsoft.Json.Linq;
|
||||||
|
|
||||||
namespace Server
|
namespace Server;
|
||||||
|
|
||||||
|
public class Register : Route
|
||||||
{
|
{
|
||||||
public class Register : Route
|
private static string HashPassword(string password)
|
||||||
{
|
{
|
||||||
private static string HashPassword(string password)
|
// Generate a salt
|
||||||
|
byte[] salt = new byte[16];
|
||||||
|
RandomNumberGenerator.Fill(salt);
|
||||||
|
// Create a PBKDF2 instance to hash the password
|
||||||
|
using var pbkdf2 = new Rfc2898DeriveBytes(password, salt, 10000, HashAlgorithmName.SHA256);
|
||||||
|
byte[] hash = pbkdf2.GetBytes(32);
|
||||||
|
|
||||||
|
// Combine the salt and the hash together
|
||||||
|
byte[] hashBytes = new byte[48]; // 16 (salt) + 32 (hash)
|
||||||
|
Array.Copy(salt, 0, hashBytes, 0, 16);
|
||||||
|
Array.Copy(hash, 0, hashBytes, 16, 32);
|
||||||
|
|
||||||
|
// Return the final hash as a Base64 encoded string
|
||||||
|
return Convert.ToBase64String(hashBytes);
|
||||||
|
}
|
||||||
|
|
||||||
|
public static void HandleRequest(HttpListenerRequest request, HttpListenerResponse response)
|
||||||
|
{
|
||||||
|
MySqlTransaction? transaction = null;
|
||||||
|
try
|
||||||
{
|
{
|
||||||
// Generate a salt
|
// extract parameters from req body
|
||||||
byte[] salt = new byte[16];
|
string body;
|
||||||
RandomNumberGenerator.Fill(salt);
|
using (StreamReader bodyReader = new(request.InputStream, request.ContentEncoding))
|
||||||
// Create a PBKDF2 instance to hash the password
|
{
|
||||||
using (
|
body = bodyReader.ReadToEnd();
|
||||||
var pbkdf2 = new Rfc2898DeriveBytes(password, salt, 10000, HashAlgorithmName.SHA256)
|
}
|
||||||
|
JObject jsonObject = JObject.Parse(body);
|
||||||
|
string f_name = jsonObject["f_name"]?.ToString() ?? "";
|
||||||
|
string l_name = jsonObject["l_name"]?.ToString() ?? "";
|
||||||
|
string password = jsonObject["password"]?.ToString() ?? "";
|
||||||
|
string mail = jsonObject["mail"]?.ToString() ?? "";
|
||||||
|
|
||||||
|
// validate parameters
|
||||||
|
if (
|
||||||
|
string.IsNullOrEmpty(f_name)
|
||||||
|
|| f_name.Length > 30
|
||||||
|
|| f_name.Length < 2
|
||||||
|
|| string.IsNullOrEmpty(l_name)
|
||||||
|
|| l_name.Length > 30
|
||||||
|
|| l_name.Length < 2
|
||||||
|
|| string.IsNullOrEmpty(mail)
|
||||||
|
|| mail.Length > 50
|
||||||
|
|| mail.Length < 6
|
||||||
|
|| string.IsNullOrEmpty(password)
|
||||||
|
|| password.Length > 30
|
||||||
|
|| password.Length < 10
|
||||||
)
|
)
|
||||||
{
|
{
|
||||||
byte[] hash = pbkdf2.GetBytes(32);
|
throw new Exception("Wrong parameters");
|
||||||
|
}
|
||||||
|
// open connection
|
||||||
|
// prepare SQL query
|
||||||
|
MySqlCommand cmd = new()
|
||||||
|
{
|
||||||
|
// Insert into User
|
||||||
|
CommandText = "INSERT INTO User(f_name,l_name,mail) VALUES(@f_name,@l_name,@mail)",
|
||||||
|
};
|
||||||
|
cmd.Parameters.AddWithValue("@f_name", f_name);
|
||||||
|
cmd.Parameters.AddWithValue("@l_name", l_name);
|
||||||
|
cmd.Parameters.AddWithValue("@mail", mail);
|
||||||
|
|
||||||
// Combine the salt and the hash together
|
using (MySqlConnection conn = new(connectionString))
|
||||||
byte[] hashBytes = new byte[48]; // 16 (salt) + 32 (hash)
|
{
|
||||||
Array.Copy(salt, 0, hashBytes, 0, 16);
|
conn.Open();
|
||||||
Array.Copy(hash, 0, hashBytes, 16, 32);
|
transaction = conn.BeginTransaction();
|
||||||
|
cmd.Connection = conn;
|
||||||
|
cmd.ExecuteNonQuery();
|
||||||
|
|
||||||
// Return the final hash as a Base64 encoded string
|
// Get user ID
|
||||||
return Convert.ToBase64String(hashBytes);
|
cmd.CommandText = "SELECT id FROM User WHERE mail=@mail;";
|
||||||
|
MySqlDataReader reader = cmd.ExecuteReader();
|
||||||
|
reader.Read();
|
||||||
|
var id = reader["id"];
|
||||||
|
reader.Close();
|
||||||
|
|
||||||
|
// Insert into password
|
||||||
|
cmd.CommandText = "INSERT INTO Password(user,password) VALUES(@id,@password)";
|
||||||
|
cmd.Parameters.AddWithValue("@password", HashPassword(password));
|
||||||
|
cmd.Parameters.AddWithValue("@id", id);
|
||||||
|
cmd.ExecuteNonQuery();
|
||||||
|
transaction.Commit();
|
||||||
|
|
||||||
|
SendSuccess(response);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
catch (Exception ex)
|
||||||
public static void HandleRequest(HttpListenerRequest request, HttpListenerResponse response)
|
|
||||||
{
|
{
|
||||||
MySqlTransaction? transaction = null;
|
transaction?.Rollback();
|
||||||
try
|
SendError(response, ex);
|
||||||
{
|
|
||||||
// extract parameters from req body
|
|
||||||
string body;
|
|
||||||
using (
|
|
||||||
StreamReader bodyReader = new StreamReader(
|
|
||||||
request.InputStream,
|
|
||||||
request.ContentEncoding
|
|
||||||
)
|
|
||||||
)
|
|
||||||
{
|
|
||||||
body = bodyReader.ReadToEnd();
|
|
||||||
}
|
|
||||||
JObject jsonObject = JObject.Parse(body);
|
|
||||||
string f_name = jsonObject["f_name"]?.ToString() ?? "";
|
|
||||||
string l_name = jsonObject["l_name"]?.ToString() ?? "";
|
|
||||||
string password = jsonObject["password"]?.ToString() ?? "";
|
|
||||||
string mail = jsonObject["mail"]?.ToString() ?? "";
|
|
||||||
|
|
||||||
// validate parameters
|
|
||||||
if (
|
|
||||||
string.IsNullOrEmpty(f_name)
|
|
||||||
|| f_name.Length > 30
|
|
||||||
|| f_name.Length < 2
|
|
||||||
|| string.IsNullOrEmpty(l_name)
|
|
||||||
|| l_name.Length > 30
|
|
||||||
|| l_name.Length < 2
|
|
||||||
|| string.IsNullOrEmpty(mail)
|
|
||||||
|| mail.Length > 50
|
|
||||||
|| mail.Length < 6
|
|
||||||
|| string.IsNullOrEmpty(password)
|
|
||||||
|| password.Length > 30
|
|
||||||
|| password.Length < 10
|
|
||||||
)
|
|
||||||
{
|
|
||||||
throw new Exception("Wrong parameters");
|
|
||||||
}
|
|
||||||
// open connection
|
|
||||||
// prepare SQL query
|
|
||||||
MySqlCommand cmd = new MySqlCommand();
|
|
||||||
|
|
||||||
// Insert into User
|
|
||||||
cmd.CommandText =
|
|
||||||
"INSERT INTO User(f_name,l_name,mail) VALUES(@f_name,@l_name,@mail)";
|
|
||||||
cmd.Parameters.AddWithValue("@f_name", f_name);
|
|
||||||
cmd.Parameters.AddWithValue("@l_name", l_name);
|
|
||||||
cmd.Parameters.AddWithValue("@mail", mail);
|
|
||||||
|
|
||||||
using (MySqlConnection conn = new MySqlConnection(connectionString))
|
|
||||||
{
|
|
||||||
conn.Open();
|
|
||||||
transaction = conn.BeginTransaction();
|
|
||||||
cmd.Connection = conn;
|
|
||||||
cmd.ExecuteNonQuery();
|
|
||||||
|
|
||||||
// Get user ID
|
|
||||||
cmd.CommandText = "SELECT id FROM User WHERE mail=@mail;";
|
|
||||||
MySqlDataReader reader = cmd.ExecuteReader();
|
|
||||||
reader.Read();
|
|
||||||
var id = reader["id"];
|
|
||||||
reader.Close();
|
|
||||||
|
|
||||||
// Insert into password
|
|
||||||
cmd.CommandText = "INSERT INTO Password(user,password) VALUES(@id,@password)";
|
|
||||||
cmd.Parameters.AddWithValue("@password", HashPassword(password));
|
|
||||||
cmd.Parameters.AddWithValue("@id", id);
|
|
||||||
cmd.ExecuteNonQuery();
|
|
||||||
transaction.Commit();
|
|
||||||
|
|
||||||
SendSuccess(response);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
catch (Exception ex)
|
|
||||||
{
|
|
||||||
if (transaction != null)
|
|
||||||
transaction.Rollback();
|
|
||||||
SendError(response, ex);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
+19
-21
@@ -1,32 +1,30 @@
|
|||||||
using System.Net;
|
using System.Net;
|
||||||
using MySql.Data.MySqlClient;
|
using MySql.Data.MySqlClient;
|
||||||
|
|
||||||
namespace Server
|
namespace Server;
|
||||||
|
|
||||||
|
public class Reset : Route
|
||||||
{
|
{
|
||||||
public class Reset : Route
|
public static void HandleRequest(HttpListenerResponse response)
|
||||||
{
|
{
|
||||||
public static void HandleRequest(HttpListenerRequest request, HttpListenerResponse response)
|
try
|
||||||
{
|
{
|
||||||
try
|
// prepare SQL query
|
||||||
|
MySqlCommand cmd = new() { CommandText = "CALL InitDB" };
|
||||||
|
using (MySqlConnection conn = new MySqlConnection(connectionString))
|
||||||
{
|
{
|
||||||
// prepare SQL query
|
cmd.Connection = conn;
|
||||||
MySqlCommand cmd = new MySqlCommand();
|
// open connection
|
||||||
cmd.CommandText = "CALL InitDB";
|
conn.Open();
|
||||||
using (MySqlConnection conn = new MySqlConnection(connectionString))
|
// execute query
|
||||||
{
|
cmd.ExecuteNonQuery();
|
||||||
cmd.Connection = conn;
|
// set up and send response
|
||||||
// open connection
|
SendSuccess(response);
|
||||||
conn.Open();
|
|
||||||
// execute query
|
|
||||||
cmd.ExecuteNonQuery();
|
|
||||||
// set up and send response
|
|
||||||
SendSuccess(response);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
catch (Exception ex)
|
|
||||||
{
|
|
||||||
SendError(response, ex);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
catch (Exception ex)
|
||||||
|
{
|
||||||
|
SendError(response, ex);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user