First merge from develop to main (WIP) #7
@@ -1,5 +1,6 @@
|
||||
middleware:
|
||||
gin_logger: "901"
|
||||
jwt: "902"
|
||||
permission: "903"
|
||||
api_version: "904"
|
||||
service:
|
||||
gin_logger: "901"
|
||||
jwt: "902"
|
||||
permission: "903"
|
||||
api_version: "904"
|
||||
|
||||
@@ -12,10 +12,10 @@ func ApiVersionCheck() gin.HandlerFunc {
|
||||
apiVersion := c.GetHeader("X-Api-Version")
|
||||
if apiVersion == "" {
|
||||
errorCode := new(exception.Builder).
|
||||
SetStatus(exception.ErrorStatusServer).
|
||||
SetService(exception.MiddlewareApiVersionService).
|
||||
SetEndpoint(exception.MiddlewareEndpoint).
|
||||
SetType(exception.ErrorTypeSpecific).
|
||||
SetStatus(exception.StatusServer).
|
||||
SetService(exception.MiddlewareServiceApiVersion).
|
||||
SetEndpoint(exception.EndpointMiddlewareService).
|
||||
SetType(exception.TypeSpecific).
|
||||
SetOriginal(exception.ApiVersionNotFound).
|
||||
Build()
|
||||
utils.HttpAbort(c, 400, errorCode)
|
||||
|
||||
@@ -17,10 +17,10 @@ func JWTAuth() gin.HandlerFunc {
|
||||
uid, err := authtoken.HeaderVerify(auth)
|
||||
if err != nil {
|
||||
errorCode := new(exception.Builder).
|
||||
SetStatus(exception.ErrorStatusServer).
|
||||
SetService(exception.MiddlewareJwtService).
|
||||
SetEndpoint(exception.MiddlewareEndpoint).
|
||||
SetType(exception.ErrorTypeSpecific).
|
||||
SetStatus(exception.StatusServer).
|
||||
SetService(exception.MiddlewareServiceJwt).
|
||||
SetEndpoint(exception.EndpointMiddlewareService).
|
||||
SetType(exception.TypeSpecific).
|
||||
SetOriginal(exception.CommonErrorUnauthorized).
|
||||
Build()
|
||||
|
||||
|
||||
@@ -17,10 +17,10 @@ func Permission(requiredLevel uint) gin.HandlerFunc {
|
||||
userIdOrig, ok := c.Get("user_id")
|
||||
if !ok || userIdOrig.(string) == "" {
|
||||
errorCode := new(exception.Builder).
|
||||
SetStatus(exception.ErrorStatusUser).
|
||||
SetService(exception.MiddlewarePermissionService).
|
||||
SetEndpoint(exception.MiddlewareEndpoint).
|
||||
SetType(exception.ErrorTypeCommon).
|
||||
SetStatus(exception.StatusUser).
|
||||
SetService(exception.MiddlewareServicePermission).
|
||||
SetEndpoint(exception.EndpointMiddlewareService).
|
||||
SetType(exception.TypeCommon).
|
||||
SetOriginal(exception.CommonErrorMissingUserId).
|
||||
Build()
|
||||
utils.HttpAbort(c, 401, errorCode)
|
||||
@@ -30,10 +30,10 @@ func Permission(requiredLevel uint) gin.HandlerFunc {
|
||||
userId, err := uuid.Parse(userIdOrig.(string))
|
||||
if err != nil {
|
||||
errorCode := new(exception.Builder).
|
||||
SetStatus(exception.ErrorStatusServer).
|
||||
SetService(exception.MiddlewarePermissionService).
|
||||
SetEndpoint(exception.MiddlewareEndpoint).
|
||||
SetType(exception.ErrorTypeCommon).
|
||||
SetStatus(exception.StatusServer).
|
||||
SetService(exception.MiddlewareServicePermission).
|
||||
SetEndpoint(exception.EndpointMiddlewareService).
|
||||
SetType(exception.TypeCommon).
|
||||
SetOriginal(exception.CommonErrorUuidParseFailed).
|
||||
Build()
|
||||
utils.HttpAbort(c, 500, errorCode)
|
||||
@@ -43,10 +43,10 @@ func Permission(requiredLevel uint) gin.HandlerFunc {
|
||||
userData, err := new(data.User).GetByUserId(userId)
|
||||
if err != nil {
|
||||
errorCode := new(exception.Builder).
|
||||
SetStatus(exception.ErrorStatusUser).
|
||||
SetService(exception.MiddlewarePermissionService).
|
||||
SetEndpoint(exception.MiddlewareEndpoint).
|
||||
SetType(exception.ErrorTypeCommon).
|
||||
SetStatus(exception.StatusUser).
|
||||
SetService(exception.MiddlewareServicePermission).
|
||||
SetEndpoint(exception.EndpointMiddlewareService).
|
||||
SetType(exception.TypeCommon).
|
||||
SetOriginal(exception.CommonErrorUserNotFound).
|
||||
Build()
|
||||
utils.HttpAbort(c, 404, errorCode)
|
||||
@@ -61,10 +61,10 @@ func Permission(requiredLevel uint) gin.HandlerFunc {
|
||||
|
||||
if permissionLevel < requiredLevel {
|
||||
errorCode := new(exception.Builder).
|
||||
SetStatus(exception.ErrorStatusUser).
|
||||
SetService(exception.MiddlewarePermissionService).
|
||||
SetEndpoint(exception.MiddlewareEndpoint).
|
||||
SetType(exception.ErrorTypeCommon).
|
||||
SetStatus(exception.StatusUser).
|
||||
SetService(exception.MiddlewareServicePermission).
|
||||
SetEndpoint(exception.EndpointMiddlewareService).
|
||||
SetType(exception.TypeCommon).
|
||||
SetOriginal(exception.CommonErrorPermissionDenied).
|
||||
Build()
|
||||
utils.HttpAbort(c, 403, errorCode)
|
||||
|
||||
@@ -25,10 +25,10 @@ func Exchange(c *gin.Context) {
|
||||
if err != nil {
|
||||
fmt.Println(err)
|
||||
errorCode := new(exception.Builder).
|
||||
SetStatus(exception.ErrorStatusClient).
|
||||
SetService(exception.AuthService).
|
||||
SetEndpoint(exception.AuthExchangeEndpoint).
|
||||
SetType(exception.ErrorTypeCommon).
|
||||
SetStatus(exception.StatusClient).
|
||||
SetService(exception.ServiceAuth).
|
||||
SetEndpoint(exception.EndpointAuthServiceExchange).
|
||||
SetType(exception.TypeCommon).
|
||||
SetOriginal(exception.CommonErrorInvalidInput).
|
||||
Build()
|
||||
utils.HttpResponse(c, 400, errorCode)
|
||||
@@ -38,10 +38,10 @@ func Exchange(c *gin.Context) {
|
||||
userIdOrig, ok := c.Get("user_id")
|
||||
if !ok {
|
||||
errorCode := new(exception.Builder).
|
||||
SetStatus(exception.ErrorStatusClient).
|
||||
SetService(exception.AuthService).
|
||||
SetEndpoint(exception.AuthExchangeEndpoint).
|
||||
SetType(exception.ErrorTypeCommon).
|
||||
SetStatus(exception.StatusClient).
|
||||
SetService(exception.ServiceAuth).
|
||||
SetEndpoint(exception.EndpointAuthServiceExchange).
|
||||
SetType(exception.TypeCommon).
|
||||
SetOriginal(exception.CommonErrorUnauthorized).
|
||||
Build()
|
||||
utils.HttpResponse(c, 401, errorCode)
|
||||
@@ -51,10 +51,10 @@ func Exchange(c *gin.Context) {
|
||||
userId, err := uuid.Parse(userIdOrig.(string))
|
||||
if err != nil {
|
||||
errorCode := new(exception.Builder).
|
||||
SetStatus(exception.ErrorStatusServer).
|
||||
SetService(exception.AuthService).
|
||||
SetEndpoint(exception.AuthExchangeEndpoint).
|
||||
SetType(exception.ErrorTypeCommon).
|
||||
SetStatus(exception.StatusServer).
|
||||
SetService(exception.ServiceAuth).
|
||||
SetEndpoint(exception.EndpointAuthServiceExchange).
|
||||
SetType(exception.TypeCommon).
|
||||
SetOriginal(exception.CommonErrorUuidParseFailed).
|
||||
Build()
|
||||
utils.HttpResponse(c, 500, errorCode)
|
||||
@@ -65,10 +65,10 @@ func Exchange(c *gin.Context) {
|
||||
user, err := userData.GetByUserId(userId)
|
||||
if err != nil {
|
||||
errorCode := new(exception.Builder).
|
||||
SetStatus(exception.ErrorStatusServer).
|
||||
SetService(exception.AuthService).
|
||||
SetEndpoint(exception.AuthExchangeEndpoint).
|
||||
SetType(exception.ErrorTypeSpecific).
|
||||
SetStatus(exception.StatusServer).
|
||||
SetService(exception.ServiceAuth).
|
||||
SetEndpoint(exception.EndpointAuthServiceExchange).
|
||||
SetType(exception.TypeSpecific).
|
||||
SetOriginal(exception.AuthExchangeGetUserIdFailed).
|
||||
Build()
|
||||
utils.HttpResponse(c, 500, errorCode)
|
||||
@@ -78,10 +78,10 @@ func Exchange(c *gin.Context) {
|
||||
code, err := authcode.NewAuthCode(exchangeReq.ClientId, user.Email)
|
||||
if err != nil {
|
||||
errorCode := new(exception.Builder).
|
||||
SetStatus(exception.ErrorStatusServer).
|
||||
SetService(exception.AuthService).
|
||||
SetEndpoint(exception.AuthExchangeEndpoint).
|
||||
SetType(exception.ErrorTypeSpecific).
|
||||
SetStatus(exception.StatusServer).
|
||||
SetService(exception.ServiceAuth).
|
||||
SetEndpoint(exception.EndpointAuthServiceExchange).
|
||||
SetType(exception.TypeSpecific).
|
||||
SetOriginal(exception.AuthExchangeCodeGenFailed).
|
||||
Build()
|
||||
utils.HttpResponse(c, 500, errorCode)
|
||||
@@ -91,10 +91,10 @@ func Exchange(c *gin.Context) {
|
||||
url, err := url.Parse(exchangeReq.RedirectUri)
|
||||
if err != nil {
|
||||
errorCode := new(exception.Builder).
|
||||
SetStatus(exception.ErrorStatusClient).
|
||||
SetService(exception.AuthService).
|
||||
SetEndpoint(exception.AuthExchangeEndpoint).
|
||||
SetType(exception.ErrorTypeSpecific).
|
||||
SetStatus(exception.StatusClient).
|
||||
SetService(exception.ServiceAuth).
|
||||
SetEndpoint(exception.EndpointAuthServiceExchange).
|
||||
SetType(exception.TypeSpecific).
|
||||
SetOriginal(exception.AuthExchangeInvalidRedirectUri).
|
||||
Build()
|
||||
utils.HttpResponse(c, 400, errorCode)
|
||||
|
||||
Reference in New Issue
Block a user