Skip to content

Commit

Permalink
add delete user endpoint
Browse files Browse the repository at this point in the history
  • Loading branch information
rawdaGastan committed Jan 6, 2025
1 parent 4a180e7 commit 26ced02
Show file tree
Hide file tree
Showing 27 changed files with 993 additions and 419 deletions.
2 changes: 2 additions & 0 deletions client/src/components/Toast.vue
Original file line number Diff line number Diff line change
Expand Up @@ -8,12 +8,14 @@ import { createToast, clearToasts } from "mosha-vue-toastify";
export default {
setup() {
const toast = (title, color = "#217dbb") => {
if (title.length > 0) {
createToast(title.charAt(0).toUpperCase() + title.slice(1), {
position: "bottom-right",
hideProgressBar: true,
toastBackgroundColor: color,
timeout: 8000,
});
}
};
const clear = () => {
clearToasts();
Expand Down
18 changes: 9 additions & 9 deletions server/app/admin_handler.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,31 +18,31 @@ import (

// AdminAnnouncement struct for data needed when admin sends new announcement
type AdminAnnouncement struct {
Subject string `json:"subject" binding:"required"`
Body string `json:"announcement" binding:"required"`
Subject string `json:"subject" validate:"nonzero" binding:"required"`
Body string `json:"announcement" validate:"nonzero" binding:"required"`
}

// EmailUser struct for data needed when admin sends new email to a user
type EmailUser struct {
Subject string `json:"subject" binding:"required"`
Body string `json:"body" binding:"required"`
Subject string `json:"subject" validate:"nonzero" binding:"required"`
Body string `json:"body" validate:"nonzero" binding:"required"`
Email string `json:"email" binding:"required" validate:"mail"`
}

// UpdateMaintenanceInput struct for data needed when user update maintenance
type UpdateMaintenanceInput struct {
ON bool `json:"on" binding:"required"`
ON bool `json:"on" validate:"nonzero" binding:"required"`
}

// SetAdminInput struct for setting users as admins
type SetAdminInput struct {
Email string `json:"email" binding:"required"`
Admin bool `json:"admin" binding:"required"`
Email string `json:"email" binding:"required" validate:"mail"`
Admin bool `json:"admin" validate:"nonzero" binding:"required"`
}

// UpdateNextLaunchInput struct for data needed when updating next launch state
type UpdateNextLaunchInput struct {
Launched bool `json:"launched" binding:"required"`
Launched bool `json:"launched" validate:"nonzero" binding:"required"`
}

// SetPricesInput struct for setting prices as admins
Expand Down Expand Up @@ -556,7 +556,7 @@ func (a *App) CreateNewAnnouncementHandler(req *http.Request) (interface{}, Resp
// @Failure 401 {object} Response
// @Failure 404 {object} Response
// @Failure 500 {object} Response
// @Router /announcement [post]
// @Router /email [post]
func (a *App) SendEmailHandler(req *http.Request) (interface{}, Response) {
var emailUser EmailUser
err := json.NewDecoder(req.Body).Decode(&emailUser)
Expand Down
4 changes: 3 additions & 1 deletion server/app/app.go
Original file line number Diff line number Diff line change
Expand Up @@ -137,12 +137,14 @@ func (a *App) registerHandlers() {
unAuthUserRouter.HandleFunc("/signup/verify_email", WrapFunc(a.VerifySignUpCodeHandler)).Methods("POST", "OPTIONS")
unAuthUserRouter.HandleFunc("/signin", WrapFunc(a.SignInHandler)).Methods("POST", "OPTIONS")
unAuthUserRouter.HandleFunc("/refresh_token", WrapFunc(a.RefreshJWTHandler)).Methods("POST", "OPTIONS")
// TODO: rename it
unAuthUserRouter.HandleFunc("/forgot_password", WrapFunc(a.ForgotPasswordHandler)).Methods("POST", "OPTIONS")
unAuthUserRouter.HandleFunc("/forget_password/verify_email", WrapFunc(a.VerifyForgetPasswordCodeHandler)).Methods("POST", "OPTIONS")

userRouter.HandleFunc("/change_password", WrapFunc(a.ChangePasswordHandler)).Methods("PUT", "OPTIONS")
userRouter.HandleFunc("", WrapFunc(a.UpdateUserHandler)).Methods("PUT", "OPTIONS")
userRouter.HandleFunc("", WrapFunc(a.GetUserHandler)).Methods("GET", "OPTIONS")
userRouter.HandleFunc("", WrapFunc(a.DeleteUserHandler)).Methods("DELETE", "OPTIONS")
userRouter.HandleFunc("/apply_voucher", WrapFunc(a.ApplyForVoucherHandler)).Methods("POST", "OPTIONS")
userRouter.HandleFunc("/activate_voucher", WrapFunc(a.ActivateVoucherHandler)).Methods("PUT", "OPTIONS")
userRouter.HandleFunc("/charge_balance", WrapFunc(a.ChargeBalance)).Methods("PUT", "OPTIONS")
Expand Down Expand Up @@ -196,7 +198,7 @@ func (a *App) registerHandlers() {
voucherRouter.HandleFunc("", WrapFunc(a.ListVouchersHandler)).Methods("GET", "OPTIONS")
voucherRouter.HandleFunc("/{id}", WrapFunc(a.UpdateVoucherHandler)).Methods("PUT", "OPTIONS")
voucherRouter.HandleFunc("", WrapFunc(a.ApproveAllVouchersHandler)).Methods("PUT", "OPTIONS")
voucherRouter.HandleFunc("/reset", WrapFunc(a.ResetUsersVoucherBalanceHandler)).Methods("PUT", "OPTIONS")
voucherRouter.HandleFunc("/all/reset", WrapFunc(a.ResetUsersVoucherBalanceHandler)).Methods("PUT", "OPTIONS")

// middlewares
r.Use(middlewares.LoggingMW)
Expand Down
Loading

0 comments on commit 26ced02

Please sign in to comment.