diff options
| author | Roy Ben Shabat <Roy.mail.net@gmail.com> | 2021-08-13 18:03:16 +0300 |
|---|---|---|
| committer | Roy Ben Shabat <Roy.mail.net@gmail.com> | 2021-08-13 18:03:16 +0300 |
| commit | e7819d9ffabb1efc272e61b4ef93a67d33dca57a (patch) | |
| tree | 8a5e4250f5ccf11f395855130c3b9bc534fe3506 /Software | |
| parent | d687f750aee6db3819893f5ac7dab144774aecdd (diff) | |
| download | Tango-e7819d9ffabb1efc272e61b4ef93a67d33dca57a.tar.gz Tango-e7819d9ffabb1efc272e61b4ef93a67d33dca57a.zip | |
Implemented password changed util.
Diffstat (limited to 'Software')
5 files changed, 246 insertions, 6 deletions
diff --git a/Software/Visual_Studio/Tango.sln b/Software/Visual_Studio/Tango.sln index 60979261e..b22d855d5 100644 --- a/Software/Visual_Studio/Tango.sln +++ b/Software/Visual_Studio/Tango.sln @@ -471,6 +471,8 @@ Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Tango.MachineStudio.Machine EndProject Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Tango.Colorful", "SideChains\Tango.Colorful\Tango.Colorful.csproj", "{C89C1866-C76B-401F-A232-40FC58065CBF}" EndProject +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Tango.PasswordChanger.CLI", "Utilities\Tango.PasswordChanger.CLI\Tango.PasswordChanger.CLI.csproj", "{564C1037-47B0-4D28-BC00-E978C9BE11FD}" +EndProject Global GlobalSection(SolutionConfigurationPlatforms) = preSolution Debug|Any CPU = Debug|Any CPU @@ -4486,6 +4488,26 @@ Global {C89C1866-C76B-401F-A232-40FC58065CBF}.Release|x64.Build.0 = Release|Any CPU {C89C1866-C76B-401F-A232-40FC58065CBF}.Release|x86.ActiveCfg = Release|Any CPU {C89C1866-C76B-401F-A232-40FC58065CBF}.Release|x86.Build.0 = Release|Any CPU + {564C1037-47B0-4D28-BC00-E978C9BE11FD}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {564C1037-47B0-4D28-BC00-E978C9BE11FD}.Debug|Any CPU.Build.0 = Debug|Any CPU + {564C1037-47B0-4D28-BC00-E978C9BE11FD}.Debug|ARM.ActiveCfg = Debug|Any CPU + {564C1037-47B0-4D28-BC00-E978C9BE11FD}.Debug|ARM.Build.0 = Debug|Any CPU + {564C1037-47B0-4D28-BC00-E978C9BE11FD}.Debug|ARM64.ActiveCfg = Debug|Any CPU + {564C1037-47B0-4D28-BC00-E978C9BE11FD}.Debug|ARM64.Build.0 = Debug|Any CPU + {564C1037-47B0-4D28-BC00-E978C9BE11FD}.Debug|x64.ActiveCfg = Debug|Any CPU + {564C1037-47B0-4D28-BC00-E978C9BE11FD}.Debug|x64.Build.0 = Debug|Any CPU + {564C1037-47B0-4D28-BC00-E978C9BE11FD}.Debug|x86.ActiveCfg = Debug|Any CPU + {564C1037-47B0-4D28-BC00-E978C9BE11FD}.Debug|x86.Build.0 = Debug|Any CPU + {564C1037-47B0-4D28-BC00-E978C9BE11FD}.Release|Any CPU.ActiveCfg = Release|Any CPU + {564C1037-47B0-4D28-BC00-E978C9BE11FD}.Release|Any CPU.Build.0 = Release|Any CPU + {564C1037-47B0-4D28-BC00-E978C9BE11FD}.Release|ARM.ActiveCfg = Release|Any CPU + {564C1037-47B0-4D28-BC00-E978C9BE11FD}.Release|ARM.Build.0 = Release|Any CPU + {564C1037-47B0-4D28-BC00-E978C9BE11FD}.Release|ARM64.ActiveCfg = Release|Any CPU + {564C1037-47B0-4D28-BC00-E978C9BE11FD}.Release|ARM64.Build.0 = Release|Any CPU + {564C1037-47B0-4D28-BC00-E978C9BE11FD}.Release|x64.ActiveCfg = Release|Any CPU + {564C1037-47B0-4D28-BC00-E978C9BE11FD}.Release|x64.Build.0 = Release|Any CPU + {564C1037-47B0-4D28-BC00-E978C9BE11FD}.Release|x86.ActiveCfg = Release|Any CPU + {564C1037-47B0-4D28-BC00-E978C9BE11FD}.Release|x86.Build.0 = Release|Any CPU EndGlobalSection GlobalSection(SolutionProperties) = preSolution HideSolutionNode = FALSE @@ -4653,14 +4675,15 @@ Global {B356201F-F958-4AC9-BBEB-E4EAE9DA9EC6} = {5F6BBAA8-EAD0-4B18-97E5-55B4F56DD760} {6C784296-CCF9-469C-A7C1-4C13305E1203} = {B2AF4F3F-2828-47C3-8F3E-A0EA0BD66FF8} {C89C1866-C76B-401F-A232-40FC58065CBF} = {EC62BC9C-F2FE-4333-B7E4-110E38D43958} + {564C1037-47B0-4D28-BC00-E978C9BE11FD} = {5F6BBAA8-EAD0-4B18-97E5-55B4F56DD760} EndGlobalSection GlobalSection(ExtensibilityGlobals) = postSolution - BuildVersion_UseGlobalSettings = False - BuildVersion_AssemblyInfoFilename = Properties\AssemblyInfo.cs - BuildVersion_StartDate = 2000/1/1 - BuildVersion_UpdateFileVersion = False - BuildVersion_UpdateAssemblyVersion = True - BuildVersion_BuildVersioningStyle = None.None.Increment.DeltaBaseYearDayOfYear SolutionGuid = {7986F7F4-A86A-4994-B1B6-0988D7F057B6} + BuildVersion_BuildVersioningStyle = None.None.Increment.DeltaBaseYearDayOfYear + BuildVersion_UpdateAssemblyVersion = True + BuildVersion_UpdateFileVersion = False + BuildVersion_StartDate = 2000/1/1 + BuildVersion_AssemblyInfoFilename = Properties\AssemblyInfo.cs + BuildVersion_UseGlobalSettings = False EndGlobalSection EndGlobal diff --git a/Software/Visual_Studio/Utilities/Tango.PasswordChanger.CLI/App.config b/Software/Visual_Studio/Utilities/Tango.PasswordChanger.CLI/App.config new file mode 100644 index 000000000..731f6de6c --- /dev/null +++ b/Software/Visual_Studio/Utilities/Tango.PasswordChanger.CLI/App.config @@ -0,0 +1,6 @@ +<?xml version="1.0" encoding="utf-8" ?> +<configuration> + <startup> + <supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.6.1" /> + </startup> +</configuration>
\ No newline at end of file diff --git a/Software/Visual_Studio/Utilities/Tango.PasswordChanger.CLI/Program.cs b/Software/Visual_Studio/Utilities/Tango.PasswordChanger.CLI/Program.cs new file mode 100644 index 000000000..c7ded88a7 --- /dev/null +++ b/Software/Visual_Studio/Utilities/Tango.PasswordChanger.CLI/Program.cs @@ -0,0 +1,103 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; +using Tango.BL; +using Tango.Core; +using Tango.Web; + +namespace Tango.PasswordChanger.CLI +{ + class Program + { + private static DataSource dataSource = new DataSource(); + + static void Main(string[] args) + { + dataSource.Address = "twine.database.windows.net"; + dataSource.IntegratedSecurity = false; + dataSource.UserName = "Roy"; + dataSource.Password = "Aa123456"; + + Console.ForegroundColor = ConsoleColor.Yellow; + Console.WriteLine("Welcome to password changed!"); + Console.ForegroundColor = ConsoleColor.Gray; + Console.WriteLine(); + Console.Write("Select Environments (eg DEV,TEST): "); + String envString = Console.ReadLine(); + + Console.Write("Email: "); + String email = Console.ReadLine(); + Console.Write("Password: "); + String password = Console.ReadLine(); + + try + { + if (envString.IsNotNullOrEmpty()) + { + String[] envs = envString.Split(',').Select(x => x.Trim()).ToArray(); + + foreach (var env in envs) + { + ChangePassword($"Tango_{env.ToUpper()}", email, password); + } + } + else + { + foreach (var env in Enum.GetValues(typeof(DeploymentSlot)).Cast<DeploymentSlot>()) + { + ChangePassword($"Tango_{env.ToString()}", email, password); + } + } + + Console.WriteLine(); + Console.ForegroundColor = ConsoleColor.Green; + Console.WriteLine("Done!"); + } + catch (Exception ex) + { + Console.ForegroundColor = ConsoleColor.Red; + Console.WriteLine(); + Console.WriteLine(ex.ToString()); + } + + Console.ForegroundColor = ConsoleColor.Yellow; + Console.Write("Continue? :"); + var key = Console.ReadKey(); + + if (key.Key == ConsoleKey.Y) + { + Console.WriteLine(); + Main(null); + } + } + + private static void ChangePassword(String catalog, String email, String password) + { + if (catalog == "Tango_PROD") + { + catalog = "Tango"; + } + + Console.WriteLine($"Changing password on '{catalog}' for '{email}' to '{password}'..."); + + dataSource.Catalog = catalog; + + using (ObservablesContext db = ObservablesContext.CreateDefault(dataSource)) + { + var user = db.Users.SingleOrDefault(x => x.Email.ToLower() == email.ToLower()); + + if (user == null) + { + throw new KeyNotFoundException($"User {email} not found."); + } + + Core.Cryptography.IHashGenerator gen = new Core.Cryptography.BasicHashGenerator(); + user.Password = gen.Encrypt(password); + + db.SaveChanges(); + } + } + } +} diff --git a/Software/Visual_Studio/Utilities/Tango.PasswordChanger.CLI/Properties/AssemblyInfo.cs b/Software/Visual_Studio/Utilities/Tango.PasswordChanger.CLI/Properties/AssemblyInfo.cs new file mode 100644 index 000000000..7123a00ed --- /dev/null +++ b/Software/Visual_Studio/Utilities/Tango.PasswordChanger.CLI/Properties/AssemblyInfo.cs @@ -0,0 +1,36 @@ +using System.Reflection; +using System.Runtime.CompilerServices; +using System.Runtime.InteropServices; + +// General Information about an assembly is controlled through the following +// set of attributes. Change these attribute values to modify the information +// associated with an assembly. +[assembly: AssemblyTitle("Tango.PasswordChanger.CLI")] +[assembly: AssemblyDescription("")] +[assembly: AssemblyConfiguration("")] +[assembly: AssemblyCompany("")] +[assembly: AssemblyProduct("Tango.PasswordChanger.CLI")] +[assembly: AssemblyCopyright("Copyright © 2021")] +[assembly: AssemblyTrademark("")] +[assembly: AssemblyCulture("")] + +// Setting ComVisible to false makes the types in this assembly not visible +// to COM components. If you need to access a type in this assembly from +// COM, set the ComVisible attribute to true on that type. +[assembly: ComVisible(false)] + +// The following GUID is for the ID of the typelib if this project is exposed to COM +[assembly: Guid("564c1037-47b0-4d28-bc00-e978c9be11fd")] + +// Version information for an assembly consists of the following four values: +// +// Major Version +// Minor Version +// Build Number +// Revision +// +// You can specify all the values or you can default the Build and Revision Numbers +// by using the '*' as shown below: +// [assembly: AssemblyVersion("1.0.*")] +[assembly: AssemblyVersion("1.0.0.0")] +[assembly: AssemblyFileVersion("1.0.0.0")] diff --git a/Software/Visual_Studio/Utilities/Tango.PasswordChanger.CLI/Tango.PasswordChanger.CLI.csproj b/Software/Visual_Studio/Utilities/Tango.PasswordChanger.CLI/Tango.PasswordChanger.CLI.csproj new file mode 100644 index 000000000..3f834580f --- /dev/null +++ b/Software/Visual_Studio/Utilities/Tango.PasswordChanger.CLI/Tango.PasswordChanger.CLI.csproj @@ -0,0 +1,72 @@ +<?xml version="1.0" encoding="utf-8"?> +<Project ToolsVersion="15.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003"> + <Import Project="$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props" Condition="Exists('$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props')" /> + <PropertyGroup> + <Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration> + <Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform> + <ProjectGuid>{564C1037-47B0-4D28-BC00-E978C9BE11FD}</ProjectGuid> + <OutputType>Exe</OutputType> + <RootNamespace>Tango.PasswordChanger.CLI</RootNamespace> + <AssemblyName>Tango.PasswordChanger.CLI</AssemblyName> + <TargetFrameworkVersion>v4.6.1</TargetFrameworkVersion> + <FileAlignment>512</FileAlignment> + <AutoGenerateBindingRedirects>true</AutoGenerateBindingRedirects> + <Deterministic>true</Deterministic> + </PropertyGroup> + <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' "> + <PlatformTarget>AnyCPU</PlatformTarget> + <DebugSymbols>true</DebugSymbols> + <DebugType>full</DebugType> + <Optimize>false</Optimize> + <OutputPath>bin\Debug\</OutputPath> + <DefineConstants>DEBUG;TRACE</DefineConstants> + <ErrorReport>prompt</ErrorReport> + <WarningLevel>4</WarningLevel> + </PropertyGroup> + <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' "> + <PlatformTarget>AnyCPU</PlatformTarget> + <DebugType>pdbonly</DebugType> + <Optimize>true</Optimize> + <OutputPath>bin\Release\</OutputPath> + <DefineConstants>TRACE</DefineConstants> + <ErrorReport>prompt</ErrorReport> + <WarningLevel>4</WarningLevel> + </PropertyGroup> + <ItemGroup> + <Reference Include="System" /> + <Reference Include="System.Core" /> + <Reference Include="System.Xml.Linq" /> + <Reference Include="System.Data.DataSetExtensions" /> + <Reference Include="Microsoft.CSharp" /> + <Reference Include="System.Data" /> + <Reference Include="System.Net.Http" /> + <Reference Include="System.Xml" /> + </ItemGroup> + <ItemGroup> + <Compile Include="Program.cs" /> + <Compile Include="Properties\AssemblyInfo.cs" /> + </ItemGroup> + <ItemGroup> + <None Include="App.config" /> + </ItemGroup> + <ItemGroup> + <ProjectReference Include="..\..\Tango.BL\Tango.BL.csproj"> + <Project>{f441feee-322a-4943-b566-110e12fd3b72}</Project> + <Name>Tango.BL</Name> + </ProjectReference> + <ProjectReference Include="..\..\Tango.Core\Tango.Core.csproj"> + <Project>{a34ee0f0-649d-41c8-8489-b6f1cc6924ee}</Project> + <Name>Tango.Core</Name> + </ProjectReference> + <ProjectReference Include="..\..\Tango.Web\Tango.Web.csproj"> + <Project>{5001990f-977b-48ff-b217-0236a5022ad8}</Project> + <Name>Tango.Web</Name> + </ProjectReference> + </ItemGroup> + <ItemGroup> + <PackageReference Include="EntityFramework"> + <Version>6.2.0</Version> + </PackageReference> + </ItemGroup> + <Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" /> +</Project>
\ No newline at end of file |
