-
-
Notifications
You must be signed in to change notification settings - Fork 0
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 #106 from isaqueveras/disable-user
adding route to disable user
- Loading branch information
Showing
10 changed files
with
121 additions
and
4 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
// Copyright (c) 2023 Isaque Veras | ||
// Use of this source code is governed by a MIT style | ||
// license that can be found in the LICENSE file. | ||
|
||
package user | ||
|
||
import ( | ||
"context" | ||
|
||
"github.com/google/uuid" | ||
"github.com/isaqueveras/power-sso/internal/infrastructure/auth/user" | ||
"github.com/isaqueveras/power-sso/pkg/database/postgres" | ||
"github.com/isaqueveras/power-sso/pkg/oops" | ||
) | ||
|
||
// Disable is the business logic for disable user | ||
func Disable(ctx context.Context, userUUID *uuid.UUID) (err error) { | ||
var transaction *postgres.DBTransaction | ||
if transaction, err = postgres.NewTransaction(ctx, false); err != nil { | ||
return oops.Err(err) | ||
} | ||
defer transaction.Rollback() | ||
|
||
repository := user.New(transaction) | ||
if err = repository.DisableUser(userUUID); err != nil { | ||
return oops.Err(err) | ||
} | ||
|
||
if err = transaction.Commit(); err != nil { | ||
return oops.Err(err) | ||
} | ||
|
||
return | ||
} |
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
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,39 @@ | ||
// Copyright (c) 2023 Isaque Veras | ||
// Use of this source code is governed by a MIT style | ||
// license that can be found in the LICENSE file. | ||
|
||
package user | ||
|
||
import ( | ||
"net/http" | ||
|
||
"github.com/gin-gonic/gin" | ||
"github.com/google/uuid" | ||
"github.com/isaqueveras/power-sso/internal/application/auth/user" | ||
"github.com/isaqueveras/power-sso/internal/utils" | ||
"github.com/isaqueveras/power-sso/pkg/oops" | ||
) | ||
|
||
// disable godoc | ||
// @Summary Disable user | ||
// @Description Route to disable a user | ||
// @Tags Http/Auth/User | ||
// @Param user_uuid path string true "UUID of the user" | ||
// @Accept json | ||
// @Produce json | ||
// @Success 201 {object} utils.NoContent{} | ||
// @Router /v1/auth/user/{user_uuid}/disable [put] | ||
func disable(ctx *gin.Context) { | ||
userUUID, err := uuid.Parse(ctx.Param("user_uuid")) | ||
if err != nil { | ||
oops.Handling(ctx, err) | ||
return | ||
} | ||
|
||
if err = user.Disable(ctx, &userUUID); err != nil { | ||
oops.Handling(ctx, err) | ||
return | ||
} | ||
|
||
ctx.JSON(http.StatusCreated, utils.NoContent{}) | ||
} |
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,12 @@ | ||
// Copyright (c) 2023 Isaque Veras | ||
// Use of this source code is governed by a MIT style | ||
// license that can be found in the LICENSE file. | ||
|
||
package user | ||
|
||
import "github.com/gin-gonic/gin" | ||
|
||
// RouterWithUUID is the router for the user module. | ||
func RouterWithUUID(r *gin.RouterGroup) { | ||
r.PUT("disable", disable) | ||
} |
File renamed without changes.
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
9fb2af8
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Successfully deployed to the following URLs:
power-sso – ./
power-sso.vercel.app
power-sso-isaqueveras.vercel.app
power-sso-git-main-isaqueveras.vercel.app