-
Notifications
You must be signed in to change notification settings - Fork 16
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
#54 refactor better exceptions handling and cleaner code in sigin end…
…point
- Loading branch information
Showing
4 changed files
with
72 additions
and
49 deletions.
There are no files selected for viewing
8 changes: 0 additions & 8 deletions
8
src/main/kotlin/dniel/forwardauth/domain/AuthorizationException.kt
This file was deleted.
Oops, something went wrong.
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 |
---|---|---|
@@ -1,8 +1,13 @@ | ||
package dniel.forwardauth.domain | ||
|
||
import javax.ws.rs.WebApplicationException | ||
import javax.ws.rs.core.MediaType | ||
import javax.ws.rs.core.Response | ||
|
||
class SigninException : WebApplicationException { | ||
constructor(error: String, description: String) : super("${error}: ${description}", Response.Status.BAD_REQUEST) | ||
constructor(error: String, description: String? = "no message") : super( | ||
Response.status(Response.Status.BAD_REQUEST) | ||
.entity("${error}: ${description}") | ||
.type(MediaType.APPLICATION_JSON) | ||
.build()) | ||
} |
13 changes: 13 additions & 0 deletions
13
src/main/kotlin/dniel/forwardauth/domain/UnauthorizedException.kt
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,13 @@ | ||
package dniel.forwardauth.domain | ||
|
||
import javax.ws.rs.WebApplicationException | ||
import javax.ws.rs.core.MediaType | ||
import javax.ws.rs.core.Response | ||
|
||
class UnauthorizedException : WebApplicationException { | ||
constructor(error: String, description: String? = "unknown") : super( | ||
Response.status(Response.Status.FORBIDDEN) | ||
.entity("${error}: ${description}") | ||
.type(MediaType.APPLICATION_JSON) | ||
.build()) | ||
} |
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