Add confirm=? quer-param to delete-user route [skip-tests]
This commit is contained in:
parent
9db49a4164
commit
7bbe321d3c
@ -528,6 +528,8 @@ class _AccountRootPageState extends State<AccountRootPage> {
|
|||||||
if (!acc.isAuth()) return;
|
if (!acc.isAuth()) return;
|
||||||
|
|
||||||
try {
|
try {
|
||||||
|
TODO ASK BEFORE DELETING TEH FUCKING USER !!!!!!!
|
||||||
|
|
||||||
await APIClient.deleteUser(acc, acc.userID!);
|
await APIClient.deleteUser(acc, acc.userID!);
|
||||||
|
|
||||||
Toaster.info('Logout', 'Successfully logged out');
|
Toaster.info('Logout', 'Successfully logged out');
|
||||||
|
@ -20,6 +20,7 @@ const (
|
|||||||
BINDFAIL_URI_PARAM APIError = 1153
|
BINDFAIL_URI_PARAM APIError = 1153
|
||||||
BINDFAIL_HEADER_PARAM APIError = 1152
|
BINDFAIL_HEADER_PARAM APIError = 1152
|
||||||
INVALID_BODY_PARAM APIError = 1161
|
INVALID_BODY_PARAM APIError = 1161
|
||||||
|
INVALID_QUERY_PARAM APIError = 1162
|
||||||
INVALID_ENUM_VALUE APIError = 1171
|
INVALID_ENUM_VALUE APIError = 1171
|
||||||
|
|
||||||
NO_TITLE APIError = 1201
|
NO_TITLE APIError = 1201
|
||||||
|
@ -290,14 +290,18 @@ func (h APIHandler) UpdateUser(pctx ginext.PreContext) ginext.HTTPResponse {
|
|||||||
// @Failure 404 {object} ginresp.apiError "user not found"
|
// @Failure 404 {object} ginresp.apiError "user not found"
|
||||||
// @Failure 500 {object} ginresp.apiError "internal server error"
|
// @Failure 500 {object} ginresp.apiError "internal server error"
|
||||||
//
|
//
|
||||||
// @Router /api/v2/users/{uid} [PATCH]
|
// @Router /api/v2/users/{uid} [DELETE]
|
||||||
func (h APIHandler) DeleteUser(pctx ginext.PreContext) ginext.HTTPResponse {
|
func (h APIHandler) DeleteUser(pctx ginext.PreContext) ginext.HTTPResponse {
|
||||||
type uri struct {
|
type uri struct {
|
||||||
UserID models.UserID `uri:"uid" binding:"entityid"`
|
UserID models.UserID `uri:"uid" binding:"entityid"`
|
||||||
}
|
}
|
||||||
|
type query struct {
|
||||||
|
Confirm *bool `json:"confirm" form:"confirm"`
|
||||||
|
}
|
||||||
|
|
||||||
var u uri
|
var u uri
|
||||||
ctx, g, errResp := pctx.URI(&u).Start()
|
var q query
|
||||||
|
ctx, g, errResp := pctx.URI(&u).Query(&q).Start()
|
||||||
if errResp != nil {
|
if errResp != nil {
|
||||||
return *errResp
|
return *errResp
|
||||||
}
|
}
|
||||||
@ -309,6 +313,10 @@ func (h APIHandler) DeleteUser(pctx ginext.PreContext) ginext.HTTPResponse {
|
|||||||
return *permResp
|
return *permResp
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if q.Confirm == nil || !*q.Confirm {
|
||||||
|
return ginresp.APIError(g, 400, apierr.INVALID_QUERY_PARAM, "Must send confirm=true to delete an account", nil)
|
||||||
|
}
|
||||||
|
|
||||||
user, err := h.database.GetUser(ctx, u.UserID)
|
user, err := h.database.GetUser(ctx, u.UserID)
|
||||||
if errors.Is(err, sql.ErrNoRows) {
|
if errors.Is(err, sql.ErrNoRows) {
|
||||||
return ginresp.APIError(g, 404, apierr.USER_NOT_FOUND, "User not found", err)
|
return ginresp.APIError(g, 404, apierr.USER_NOT_FOUND, "User not found", err)
|
||||||
|
Loading…
x
Reference in New Issue
Block a user