diff --git a/Docker/MySQL_Init_Script/1.init.sql b/Docker/MySQL_Init_Script/1.init.sql index 6bf2855..832eecb 100644 --- a/Docker/MySQL_Init_Script/1.init.sql +++ b/Docker/MySQL_Init_Script/1.init.sql @@ -1,45 +1,14 @@ --- phpMyAdmin SQL Dump --- version 5.0.1 --- https://www.phpmyadmin.net/ --- --- Host: db --- Generation Time: Feb 18, 2020 at 02:41 PM --- Server version: 8.0.19 --- PHP Version: 7.4.1 - SET SQL_MODE = "NO_AUTO_VALUE_ON_ZERO"; SET AUTOCOMMIT = 0; START TRANSACTION; SET time_zone = "+00:00"; - -/*!40101 SET @OLD_CHARACTER_SET_CLIENT=@@CHARACTER_SET_CLIENT */; -/*!40101 SET @OLD_CHARACTER_SET_RESULTS=@@CHARACTER_SET_RESULTS */; -/*!40101 SET @OLD_COLLATION_CONNECTION=@@COLLATION_CONNECTION */; -/*!40101 SET NAMES utf8mb4 */; - --- --- Database: `H2020.IPMDecisions.IDP` --- - CREATE DATABASE IF NOT EXISTS `H2020.IPMDecisions.IDP` DEFAULT CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci; USE `H2020.IPMDecisions.IDP`; --- -------------------------------------------------------- - --- --- Database User: `ipm_idp_user` --- - CREATE USER `ipm_idp_user`@`%` IDENTIFIED BY 'user_password'; GRANT USAGE ON *.* TO `ipm_idp_user`@`%`; -GRANT SELECT, INSERT, UPDATE, DELETE ON `H2020.IPMDecisions.IDP`.* TO `ipm_idp_user`@`%`; - --- -------------------------------------------------------- - --- --- Table structure for table `ApplicationClient` --- +GRANT SELECT, INSERT, UPDATE, DELETE, CREATE, REFERENCES ON `H2020.IPMDecisions.IDP`.* TO `ipm_idp_user`@`%`; CREATE TABLE `ApplicationClient` ( `Base64Secret` varchar(80) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NOT NULL, @@ -51,12 +20,6 @@ CREATE TABLE `ApplicationClient` ( `JWTAudienceCategory` longtext CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NOT NULL ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci; --- -------------------------------------------------------- - --- --- Table structure for table `RefreshToken` --- - CREATE TABLE `RefreshToken` ( `Id` char(36) NOT NULL, `ApplicationClientId` char(36) NOT NULL, @@ -65,12 +28,6 @@ CREATE TABLE `RefreshToken` ( `ExpiresUtc` datetime(6) NOT NULL DEFAULT '0001-01-01 00:00:00.000000' ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci; --- -------------------------------------------------------- - --- --- Table structure for table `Role` --- - CREATE TABLE `Role` ( `Id` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NOT NULL, `Name` varchar(256) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci DEFAULT NULL, @@ -78,12 +35,6 @@ CREATE TABLE `Role` ( `ConcurrencyStamp` longtext CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci; --- -------------------------------------------------------- - --- --- Table structure for table `RoleClaim` --- - CREATE TABLE `RoleClaim` ( `Id` int NOT NULL, `RoleId` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NOT NULL, @@ -91,12 +42,6 @@ CREATE TABLE `RoleClaim` ( `ClaimValue` longtext CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci; --- -------------------------------------------------------- - --- --- Table structure for table `User` --- - CREATE TABLE `User` ( `Id` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NOT NULL, `UserName` varchar(256) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci DEFAULT NULL, @@ -118,12 +63,6 @@ CREATE TABLE `User` ( `InactiveEmailsSent` int NOT NULL DEFAULT '0' ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci; --- -------------------------------------------------------- - --- --- Table structure for table `UserClaim` --- - CREATE TABLE `UserClaim` ( `Id` int NOT NULL, `UserId` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NOT NULL, @@ -131,12 +70,6 @@ CREATE TABLE `UserClaim` ( `ClaimValue` longtext CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci; --- -------------------------------------------------------- - --- --- Table structure for table `UserLogin` --- - CREATE TABLE `UserLogin` ( `LoginProvider` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NOT NULL, `ProviderKey` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NOT NULL, @@ -144,23 +77,11 @@ CREATE TABLE `UserLogin` ( `UserId` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NOT NULL ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci; --- -------------------------------------------------------- - --- --- Table structure for table `UserRole` --- - CREATE TABLE `UserRole` ( `UserId` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NOT NULL, `RoleId` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NOT NULL ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci; --- -------------------------------------------------------- - --- --- Table structure for table `UserToken` --- - CREATE TABLE `UserToken` ( `UserId` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NOT NULL, `LoginProvider` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci NOT NULL, @@ -168,148 +89,72 @@ CREATE TABLE `UserToken` ( `Value` longtext CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci; --- -------------------------------------------------------- - --- --- Table structure for table `__EFMigrationsHistory` --- - CREATE TABLE `__EFMigrationsHistory` ( `MigrationId` varchar(95) NOT NULL, `ProductVersion` varchar(32) NOT NULL ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci; --- --- Indexes for dumped tables --- - --- --- Indexes for table `ApplicationClient` --- ALTER TABLE `ApplicationClient` ADD PRIMARY KEY (`Id`); --- --- Indexes for table `RefreshToken` --- ALTER TABLE `RefreshToken` ADD PRIMARY KEY (`Id`), ADD KEY `IX_RefreshToken_ApplicationClientId` (`ApplicationClientId`), ADD KEY `IX_RefreshToken_UserId` (`UserId`); --- --- Indexes for table `Role` --- ALTER TABLE `Role` ADD PRIMARY KEY (`Id`), ADD UNIQUE KEY `RoleNameIndex` (`NormalizedName`); --- --- Indexes for table `RoleClaim` --- ALTER TABLE `RoleClaim` ADD PRIMARY KEY (`Id`), ADD KEY `IX_RoleClaim_RoleId` (`RoleId`); --- --- Indexes for table `User` --- ALTER TABLE `User` ADD PRIMARY KEY (`Id`), ADD UNIQUE KEY `UserNameIndex` (`NormalizedUserName`), ADD KEY `EmailIndex` (`NormalizedEmail`); --- --- Indexes for table `UserClaim` --- ALTER TABLE `UserClaim` ADD PRIMARY KEY (`Id`), ADD KEY `IX_UserClaim_UserId` (`UserId`); --- --- Indexes for table `UserLogin` --- ALTER TABLE `UserLogin` ADD PRIMARY KEY (`LoginProvider`,`ProviderKey`), ADD KEY `IX_UserLogin_UserId` (`UserId`); --- --- Indexes for table `UserRole` --- ALTER TABLE `UserRole` ADD PRIMARY KEY (`UserId`,`RoleId`), ADD KEY `IX_UserRole_RoleId` (`RoleId`); --- --- Indexes for table `UserToken` --- ALTER TABLE `UserToken` ADD PRIMARY KEY (`UserId`,`LoginProvider`,`Name`); --- --- Indexes for table `__EFMigrationsHistory` --- ALTER TABLE `__EFMigrationsHistory` ADD PRIMARY KEY (`MigrationId`); --- --- AUTO_INCREMENT for dumped tables --- - --- --- AUTO_INCREMENT for table `RoleClaim` --- ALTER TABLE `RoleClaim` MODIFY `Id` int NOT NULL AUTO_INCREMENT; --- --- AUTO_INCREMENT for table `UserClaim` --- ALTER TABLE `UserClaim` MODIFY `Id` int NOT NULL AUTO_INCREMENT, AUTO_INCREMENT=26; --- --- Constraints for dumped tables --- - --- --- Constraints for table `RefreshToken` --- ALTER TABLE `RefreshToken` ADD CONSTRAINT `FK_RefreshToken_ApplicationClient_ApplicationClientId` FOREIGN KEY (`ApplicationClientId`) REFERENCES `ApplicationClient` (`Id`) ON DELETE CASCADE; --- --- Constraints for table `RoleClaim` --- ALTER TABLE `RoleClaim` ADD CONSTRAINT `FK_RoleClaim_Role_RoleId` FOREIGN KEY (`RoleId`) REFERENCES `Role` (`Id`) ON DELETE CASCADE; --- --- Constraints for table `UserClaim` --- ALTER TABLE `UserClaim` ADD CONSTRAINT `FK_UserClaim_User_UserId` FOREIGN KEY (`UserId`) REFERENCES `User` (`Id`) ON DELETE CASCADE; --- --- Constraints for table `UserLogin` --- ALTER TABLE `UserLogin` ADD CONSTRAINT `FK_UserLogin_User_UserId` FOREIGN KEY (`UserId`) REFERENCES `User` (`Id`) ON DELETE CASCADE; --- --- Constraints for table `UserRole` --- ALTER TABLE `UserRole` ADD CONSTRAINT `FK_UserRole_Role_RoleId` FOREIGN KEY (`RoleId`) REFERENCES `Role` (`Id`) ON DELETE CASCADE, ADD CONSTRAINT `FK_UserRole_User_UserId` FOREIGN KEY (`UserId`) REFERENCES `User` (`Id`) ON DELETE CASCADE; --- --- Constraints for table `UserToken` --- ALTER TABLE `UserToken` ADD CONSTRAINT `FK_UserToken_User_UserId` FOREIGN KEY (`UserId`) REFERENCES `User` (`Id`) ON DELETE CASCADE; -COMMIT; - -/*!40101 SET CHARACTER_SET_CLIENT=@OLD_CHARACTER_SET_CLIENT */; -/*!40101 SET CHARACTER_SET_RESULTS=@OLD_CHARACTER_SET_RESULTS */; -/*!40101 SET COLLATION_CONNECTION=@OLD_COLLATION_CONNECTION */; +COMMIT; \ No newline at end of file diff --git a/Docker/MySQL_Init_Script/2.defaultData.sql b/Docker/MySQL_Init_Script/2.defaultData.sql index 142ce94..48624c4 100644 --- a/Docker/MySQL_Init_Script/2.defaultData.sql +++ b/Docker/MySQL_Init_Script/2.defaultData.sql @@ -22,4 +22,6 @@ INSERT INTO `__EFMigrationsHistory` (`MigrationId`, `ProductVersion`) VALUES ('20200213102409_fixingMissingColum', '3.1.1'), ('20200213132720_addExpireRefreshToken', '3.1.1'), ('20200604151512_ChangeColumnName', '3.1.1'), -('20200729155000_AddRegistrationDateToUser', '3.1.1'); \ No newline at end of file +('20200729155000_AddRegistrationDateToUser', '3.1.1'), +('20210521101912_AddLastAccessColumn', '3.1.1'), +('20210524140407_InactiveEmailsColumn', '3.1.14'); \ No newline at end of file diff --git a/H2020.IPMDecisions.IDP.API/Controllers/AccountsController.cs b/H2020.IPMDecisions.IDP.API/Controllers/AccountsController.cs index 02e07b3..43603a7 100644 --- a/H2020.IPMDecisions.IDP.API/Controllers/AccountsController.cs +++ b/H2020.IPMDecisions.IDP.API/Controllers/AccountsController.cs @@ -46,6 +46,7 @@ public async Task ForgotPassword( [ProducesResponseType(StatusCodes.Status200OK)] [ProducesResponseType(StatusCodes.Status400BadRequest)] [HttpPost("resetpassword", Name = "ResetPassword")] + // POST: api/Accounts/resetpassword public async Task ResetPassword( [FromBody] ResetPasswordDto resetPasswordDto) { @@ -142,7 +143,7 @@ public async Task ResendConfirmationEmail([FromBody] UserEmailDto if (response.IsSuccessful) return Ok(); - + return BadRequest(new { message = response.ErrorMessage }); } diff --git a/H2020.IPMDecisions.IDP.API/H2020.IPMDecisions.IDP.API.csproj b/H2020.IPMDecisions.IDP.API/H2020.IPMDecisions.IDP.API.csproj index a498fdd..e7543a2 100644 --- a/H2020.IPMDecisions.IDP.API/H2020.IPMDecisions.IDP.API.csproj +++ b/H2020.IPMDecisions.IDP.API/H2020.IPMDecisions.IDP.API.csproj @@ -1,9 +1,9 @@ netcoreapp3.1 - 0.3.1.0 - 0.3.1.0 - 0.3.1.0 + 0.3.2.0 + 0.3.2.0 + 0.3.2.0 ADAS Modelling and Informatics Team RSK ADAS Ltd H2020 IPM Decisions Identity Provider Service diff --git a/H2020.IPMDecisions.IDP.BLL/BusinessLogic.Accounts.cs b/H2020.IPMDecisions.IDP.BLL/BusinessLogic.Accounts.cs index b0542cf..5f37817 100644 --- a/H2020.IPMDecisions.IDP.BLL/BusinessLogic.Accounts.cs +++ b/H2020.IPMDecisions.IDP.BLL/BusinessLogic.Accounts.cs @@ -233,6 +233,7 @@ private async Task CreateRegistrationEmailObject(ApplicationU var configKey = "UIPageAddresses:ConfirmUserFormPageAddress"; var emailObject = GenerateEmailLink(identityUser, configKey, token, "id"); var registrationEmail = this.mapper.Map(emailObject); + registrationEmail.HoursToConfirmEmail = int.Parse(this.configuration["EmailConfirmationAllowanceHours"]); return registrationEmail; } diff --git a/H2020.IPMDecisions.IDP.BLL/H2020.IPMDecisions.IDP.BLL.csproj b/H2020.IPMDecisions.IDP.BLL/H2020.IPMDecisions.IDP.BLL.csproj index 51fbff0..3b5e006 100644 --- a/H2020.IPMDecisions.IDP.BLL/H2020.IPMDecisions.IDP.BLL.csproj +++ b/H2020.IPMDecisions.IDP.BLL/H2020.IPMDecisions.IDP.BLL.csproj @@ -13,9 +13,9 @@ netstandard2.1 - 0.3.1.0 - 0.3.1.0 - 0.3.1.0 + 0.3.2.0 + 0.3.2.0 + 0.3.2.0 ADAS Modelling and Informatics Team RSK ADAS Ltd H2020 IPM Decisions Identity Provider Service diff --git a/H2020.IPMDecisions.IDP.BLL/Providers/MicroservicesInternalCommunicationHttpProvider.cs b/H2020.IPMDecisions.IDP.BLL/Providers/MicroservicesInternalCommunicationHttpProvider.cs index da3c471..a725410 100644 --- a/H2020.IPMDecisions.IDP.BLL/Providers/MicroservicesInternalCommunicationHttpProvider.cs +++ b/H2020.IPMDecisions.IDP.BLL/Providers/MicroservicesInternalCommunicationHttpProvider.cs @@ -145,6 +145,7 @@ private StringContent CreateEmailJsonObject(Email email) var jsonObject = new System.Json.JsonObject(); jsonObject.Add("toAddress", email.ToAddress); jsonObject.Add("callbackUrl", email.CallbackUrl.AbsoluteUri); + jsonObject.Add("hoursToConfirmEmail", email.HoursToConfirmEmail); jsonObject.Add("token", email.Token); var customContentType = config["MicroserviceInternalCommunication:ContentTypeHeader"]; diff --git a/H2020.IPMDecisions.IDP.Core/H2020.IPMDecisions.IDP.Core.csproj b/H2020.IPMDecisions.IDP.Core/H2020.IPMDecisions.IDP.Core.csproj index bf5e96c..6371a5a 100644 --- a/H2020.IPMDecisions.IDP.Core/H2020.IPMDecisions.IDP.Core.csproj +++ b/H2020.IPMDecisions.IDP.Core/H2020.IPMDecisions.IDP.Core.csproj @@ -2,9 +2,9 @@ netstandard2.1 - 0.3.1.0 - 0.3.1.0 - 0.3.1.0 + 0.3.2.0 + 0.3.2.0 + 0.3.2.0 ADAS Modelling and Informatics Team RSK ADAS Ltd H2020 IPM Decisions Identity Provider Service diff --git a/H2020.IPMDecisions.IDP.Core/Models/Email.cs b/H2020.IPMDecisions.IDP.Core/Models/Email.cs index e414984..5585462 100644 --- a/H2020.IPMDecisions.IDP.Core/Models/Email.cs +++ b/H2020.IPMDecisions.IDP.Core/Models/Email.cs @@ -2,10 +2,11 @@ namespace H2020.IPMDecisions.IDP.Core.Models { - public class Email + public class Email { public string ToAddress { get; set; } public Uri CallbackUrl { get; set; } public string Token { get; set; } + public int HoursToConfirmEmail { get; set; } = 24; } } \ No newline at end of file diff --git a/H2020.IPMDecisions.IDP.Data/H2020.IPMDecisions.IDP.Data.csproj b/H2020.IPMDecisions.IDP.Data/H2020.IPMDecisions.IDP.Data.csproj index fd69e8e..9fa16eb 100644 --- a/H2020.IPMDecisions.IDP.Data/H2020.IPMDecisions.IDP.Data.csproj +++ b/H2020.IPMDecisions.IDP.Data/H2020.IPMDecisions.IDP.Data.csproj @@ -2,9 +2,9 @@ netstandard2.1 - 0.3.1.0 - 0.3.1.0 - 0.3.1.0 + 0.3.2.0 + 0.3.2.0 + 0.3.2.0 ADAS Modelling and Informatics Team RSK ADAS Ltd H2020 IPM Decisions Identity Provider Service diff --git a/H2020.IPMDecisions.IDP.Tests/H2020.IPMDecisions.IDP.Tests.csproj b/H2020.IPMDecisions.IDP.Tests/H2020.IPMDecisions.IDP.Tests.csproj index 99c55b2..c98b3a1 100644 --- a/H2020.IPMDecisions.IDP.Tests/H2020.IPMDecisions.IDP.Tests.csproj +++ b/H2020.IPMDecisions.IDP.Tests/H2020.IPMDecisions.IDP.Tests.csproj @@ -1,9 +1,9 @@ netcoreapp3.1 - 0.3.1.0 - 0.3.1.0 - 0.3.1.0 + 0.3.2.0 + 0.3.2.0 + 0.3.2.0 ADAS Modelling and Informatics Team RSK ADAS Ltd false diff --git a/README.md b/README.md index a567021..742ae3c 100644 --- a/README.md +++ b/README.md @@ -54,7 +54,7 @@ dotnet build Run command to start database on Docker: ```console -'docker run -p 3306:3306 --name some-mysql -e MYSQL_ROOT_PASSWORD=my-secret-pw -d mysql:8.0.19' +docker run -p 3306:3306 --name some-mysql -e MYSQL_ROOT_PASSWORD=my-secret-pw -d mysql:8.0.19 ``` Open file `H2020.IPMDecisions.IDP.API\appsettings.json` and change the json object `ConnectionStrings\MySqlDbConnection` with your MySql instance.