-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #24 from marcwittke/hotfix/2.1.2
Hotfix/2.1.2
- Loading branch information
Showing
6 changed files
with
120 additions
and
37 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,49 @@ | ||
namespace Backend.Fx.Exceptions | ||
{ | ||
using System; | ||
|
||
public class UnauthorizedException : ClientException | ||
{ | ||
public enum Code | ||
{ | ||
AccessDenied, | ||
NotAuthenticated, | ||
AccountLocked | ||
} | ||
|
||
public UnauthorizedException() | ||
{ } | ||
|
||
public UnauthorizedException(string message) : base(message) | ||
{ } | ||
|
||
public UnauthorizedException(string message, Exception innerException) : base(message, innerException) | ||
{ } | ||
|
||
public static UnauthorizedException AccessDenied() | ||
{ | ||
var exception = new UnauthorizedException(); | ||
exception.Errors.Add(new Error(Code.AccessDenied, "Access to this function or data is denied.")); | ||
return exception; | ||
} | ||
|
||
public static UnauthorizedException AccountLocked() | ||
{ | ||
var exception = new UnauthorizedException(); | ||
exception.Errors.Add(new Error(Code.AccountLocked, "The identity's user account is locked.")); | ||
return exception; | ||
} | ||
|
||
public static UnauthorizedException NotAuthenticated() | ||
{ | ||
var exception = new UnauthorizedException(); | ||
exception.Errors.Add(new Error(Code.NotAuthenticated, "Identity must be authenticated to access this function or data.")); | ||
return exception; | ||
} | ||
|
||
protected override string DefaultMessage | ||
{ | ||
get { return "Unauthorized access."; } | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters