Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Create User invalid request has a response which returns 500 #5228 #5229

Merged
Merged
Show file tree
Hide file tree
Changes from 3 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions DNN Platform/Library/DotNetNuke.Library.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -230,6 +230,7 @@
<Compile Include="Entities\Portals\PortalAliasExtensions.cs" />
<Compile Include="Entities\Portals\PortalSettingUpdatedEventArgs.cs" />
<Compile Include="Entities\Portals\PortalTemplateEventArgs.cs" />
<Compile Include="Entities\Users\Exceptions\InvalidPasswordException.cs" />
<Compile Include="Entities\Users\UpdateUserEventArgs.cs" />
<Compile Include="Entities\Content\ContentTypeMemberNameFixer.cs" />
<Compile Include="Collections\EnumerableExtensions.cs" />
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
// Licensed to the .NET Foundation under one or more agreements.
// The .NET Foundation licenses this file to you under the MIT license.
// See the LICENSE file in the project root for more information

namespace DotNetNuke.Entities.Users
{
using System;

[Serializable]
public class InvalidPasswordException : Exception
{
/// <summary>
/// Initializes a new instance of the <see cref="InvalidPasswordException"/> class.
/// </summary>
public InvalidPasswordException()
{
}

/// <summary>
/// Initializes a new instance of the <see cref="InvalidPasswordException"/> class.
/// </summary>
/// <param name="message"></param>
public InvalidPasswordException(string message)
: base(message)
{
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -243,7 +243,7 @@ public UserBasicDto Register(RegisterationDetails registerationDetails)

if (createStatus != UserCreateStatus.Success)
{
throw new Exception(UserController.GetUserCreateStatus(createStatus));
throw new InvalidPasswordException(UserController.GetUserCreateStatus(createStatus));
}

// if (registerationDetails.IgnoreRegistrationMode)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -69,9 +69,16 @@ public HttpResponseMessage CreateUser(CreateUserContract contract)
: null);
}
catch (Exception ex)
{
Logger.Error(ex);
return this.Request.CreateErrorResponse(HttpStatusCode.InternalServerError, ex.Message);
{
if (ex.GetType() == typeof(InvalidPasswordException))
{
return this.Request.CreateErrorResponse(HttpStatusCode.BadRequest, ex.Message);
mitchelsellers marked this conversation as resolved.
Show resolved Hide resolved
}
else
{
Logger.Error(ex);
return this.Request.CreateErrorResponse(HttpStatusCode.InternalServerError, ex.Message);
}
}
}

Expand Down