diff --git a/AuthenticationMicroservice/AuthenticationMicroservice/Models/DTOs/UserDTO.cs b/AuthenticationMicroservice/AuthenticationMicroservice/Models/DTOs/UserDTO.cs index a119119429c670378f6eabb8540c342938136a29..0e3d51b289aafd3383108de132414deb9922a35d 100644 --- a/AuthenticationMicroservice/AuthenticationMicroservice/Models/DTOs/UserDTO.cs +++ b/AuthenticationMicroservice/AuthenticationMicroservice/Models/DTOs/UserDTO.cs @@ -34,27 +34,21 @@ public class UserRegisterRequestDTO : UserDTO [Required] [StringLength(100, MinimumLength = 8)] public string? ConfirmPassword { get; set; } - - public string? CallbackUrl { get; set; } } -public abstract class ChangeEmailRequestDTO +public class ChangeEmailRequestDTO { [Required] public string? NewEmail { get; set; } [Required] public string? ConfirmEmail { get; set; } - - [Required] public string? CallbackUrl { get; set; } } -public abstract class ForgotPasswordRequestDTO +public class ForgotPasswordRequestDTO { [Required] public string? EmailAddress { get; set; } - - [Required] public string? CallbackUrl { get; set; } } -public abstract class SetPasswordRequestDTO +public class SetPasswordRequestDTO { [Required] public string? Token { get; set; } @@ -67,7 +61,7 @@ public abstract class SetPasswordRequestDTO public string? ConfirmPassword { get; set; } } -public abstract class ChangePasswordRequestDTO +public class ChangePasswordRequestDTO { [Required] public string? OldPassword { get; set; } @@ -96,8 +90,4 @@ public class AuthenticatedUserDTO public string? RefreshToken { get; set; } public long RefreshTokenExpires { get; set; } - - public string? ProfilePictureUrl { get; set; } - - public string? ProfilePictureSas { get; set; } } \ No newline at end of file diff --git a/AuthenticationMicroservice/AuthenticationMicroservice/Program.cs b/AuthenticationMicroservice/AuthenticationMicroservice/Program.cs index c6ad4e2755c4e3ec21ca05dd18fae43b2948731f..1cfba1267de6a822811524c2733b90d71f60fba4 100644 --- a/AuthenticationMicroservice/AuthenticationMicroservice/Program.cs +++ b/AuthenticationMicroservice/AuthenticationMicroservice/Program.cs @@ -98,7 +98,7 @@ builder.Services.AddCors(options => options.AddDefaultPolicy( corsPolicyBuilder => { - corsPolicyBuilder.WithOrigins(builder.Configuration.GetSection("Group17Website")["BaseUrl"] ?? string.Empty) + corsPolicyBuilder.WithOrigins(builder.Configuration.GetSection("FrontendStrings")["BaseUrl"] ?? string.Empty) .AllowAnyHeader() .AllowAnyMethod() .AllowCredentials(); diff --git a/AuthenticationMicroservice/AuthenticationMicroservice/Services/AuthService.cs b/AuthenticationMicroservice/AuthenticationMicroservice/Services/AuthService.cs index f7669749b66afc8f186eede910419a37bd4b9b2f..2c2dce2b47f74d39998e008b23206e5840abb35b 100644 --- a/AuthenticationMicroservice/AuthenticationMicroservice/Services/AuthService.cs +++ b/AuthenticationMicroservice/AuthenticationMicroservice/Services/AuthService.cs @@ -127,7 +127,7 @@ public class AuthService : IAuthService throw new AuthenticationException("User not found.", HttpStatusCode.Unauthorized); if (string.IsNullOrWhiteSpace(user.UnconfirmedEmail)) throw new AuthenticationException("Email already confirmed.", HttpStatusCode.BadRequest); - var tryParse = TryParse(token, out var parsedToken); + var tryParse = TryParse(token[1..], out var parsedToken); if (!tryParse) throw new AuthenticationException("Token in request is not valid."); if (user.EmailConfirmationToken != parsedToken) @@ -155,8 +155,7 @@ public class AuthService : IAuthService public async Task ForgotPassword(ForgotPasswordRequestDTO request) { - var user = await _context.User.FirstOrDefaultAsync(u => - string.Equals(u.EmailAddress, request.EmailAddress, StringComparison.CurrentCultureIgnoreCase)); + var user = await _context.User.FirstOrDefaultAsync(u => u.EmailAddress == request.EmailAddress); if (user == null) throw new AuthenticationException($"User with email: {request.EmailAddress} does not exist.", HttpStatusCode.Unauthorized); @@ -175,7 +174,7 @@ public class AuthService : IAuthService { if (string.IsNullOrWhiteSpace(request.Password)) throw new SecurityHelper.InvalidPasswordException("Please enter a password."); - var tryParse = TryParse(request.Token, out var token); + var tryParse = TryParse(request.Token?[1..], out var token); if (!tryParse) throw new AuthenticationException("Token in request is not valid."); var user = _context.User.FirstOrDefault(u => u.PasswordResetToken == token); diff --git a/Frontend/API/Group17AuthApi.cs b/Frontend/API/Group17AuthApi.cs index 8012efb4c192354a6c7a903ad59a2f77038a31f1..2cea8ed8272788697de85ff0f591696ff9695314 100644 --- a/Frontend/API/Group17AuthApi.cs +++ b/Frontend/API/Group17AuthApi.cs @@ -1525,12 +1525,6 @@ namespace Group17.Auth [Newtonsoft.Json.JsonProperty("refreshTokenExpires", Required = Newtonsoft.Json.Required.DisallowNull, NullValueHandling = Newtonsoft.Json.NullValueHandling.Ignore)] public long RefreshTokenExpires { get; set; } - [Newtonsoft.Json.JsonProperty("profilePictureUrl", Required = Newtonsoft.Json.Required.Default, NullValueHandling = Newtonsoft.Json.NullValueHandling.Ignore)] - public string ProfilePictureUrl { get; set; } - - [Newtonsoft.Json.JsonProperty("profilePictureSas", Required = Newtonsoft.Json.Required.Default, NullValueHandling = Newtonsoft.Json.NullValueHandling.Ignore)] - public string ProfilePictureSas { get; set; } - } [System.CodeDom.Compiler.GeneratedCode("NJsonSchema", "13.18.2.0 (NJsonSchema v10.8.0.0 (Newtonsoft.Json v13.0.0.0))")] @@ -1598,10 +1592,6 @@ namespace Group17.Auth [System.ComponentModel.DataAnnotations.Required] public string ConfirmEmail { get; set; } - [Newtonsoft.Json.JsonProperty("callbackUrl", Required = Newtonsoft.Json.Required.Always)] - [System.ComponentModel.DataAnnotations.Required] - public string CallbackUrl { get; set; } - } [System.CodeDom.Compiler.GeneratedCode("NJsonSchema", "13.18.2.0 (NJsonSchema v10.8.0.0 (Newtonsoft.Json v13.0.0.0))")] @@ -1739,10 +1729,6 @@ namespace Group17.Auth [System.ComponentModel.DataAnnotations.Required] public string EmailAddress { get; set; } - [Newtonsoft.Json.JsonProperty("callbackUrl", Required = Newtonsoft.Json.Required.Always)] - [System.ComponentModel.DataAnnotations.Required] - public string CallbackUrl { get; set; } - } [System.CodeDom.Compiler.GeneratedCode("NJsonSchema", "13.18.2.0 (NJsonSchema v10.8.0.0 (Newtonsoft.Json v13.0.0.0))")] @@ -1868,9 +1854,6 @@ namespace Group17.Auth [System.ComponentModel.DataAnnotations.StringLength(100, MinimumLength = 8)] public string ConfirmPassword { get; set; } - [Newtonsoft.Json.JsonProperty("callbackUrl", Required = Newtonsoft.Json.Required.Default, NullValueHandling = Newtonsoft.Json.NullValueHandling.Ignore)] - public string CallbackUrl { get; set; } - [Newtonsoft.Json.JsonProperty("firstName", Required = Newtonsoft.Json.Required.Always)] [System.ComponentModel.DataAnnotations.Required] public string FirstName { get; set; }