✨ Suspended account
This commit is contained in:
parent
e5bdb23c09
commit
681eb3cf7f
@ -18,6 +18,7 @@ type Account struct {
|
|||||||
Avatar *uint `json:"avatar"`
|
Avatar *uint `json:"avatar"`
|
||||||
Banner *uint `json:"banner"`
|
Banner *uint `json:"banner"`
|
||||||
ConfirmedAt *time.Time `json:"confirmed_at"`
|
ConfirmedAt *time.Time `json:"confirmed_at"`
|
||||||
|
SuspendedAt *time.Time `json:"suspended_at"`
|
||||||
PermNodes datatypes.JSONMap `json:"perm_nodes"`
|
PermNodes datatypes.JSONMap `json:"perm_nodes"`
|
||||||
|
|
||||||
Profile AccountProfile `json:"profile"`
|
Profile AccountProfile `json:"profile"`
|
||||||
|
@ -2,6 +2,7 @@ package admin
|
|||||||
|
|
||||||
import (
|
import (
|
||||||
"fmt"
|
"fmt"
|
||||||
|
|
||||||
"git.solsynth.dev/hydrogen/passport/pkg/internal/database"
|
"git.solsynth.dev/hydrogen/passport/pkg/internal/database"
|
||||||
"git.solsynth.dev/hydrogen/passport/pkg/internal/models"
|
"git.solsynth.dev/hydrogen/passport/pkg/internal/models"
|
||||||
"git.solsynth.dev/hydrogen/passport/pkg/internal/server/exts"
|
"git.solsynth.dev/hydrogen/passport/pkg/internal/server/exts"
|
||||||
@ -33,6 +34,8 @@ func editUserPermission(c *fiber.Ctx) error {
|
|||||||
prev := user.PermNodes
|
prev := user.PermNodes
|
||||||
user.PermNodes = data.PermNodes
|
user.PermNodes = data.PermNodes
|
||||||
|
|
||||||
|
services.InvalidAuthCacheWithUser(user.ID)
|
||||||
|
|
||||||
if err := database.C.Save(&user).Error; err != nil {
|
if err := database.C.Save(&user).Error; err != nil {
|
||||||
return fiber.NewError(fiber.StatusInternalServerError, err.Error())
|
return fiber.NewError(fiber.StatusInternalServerError, err.Error())
|
||||||
} else {
|
} else {
|
||||||
|
@ -2,9 +2,10 @@ package api
|
|||||||
|
|
||||||
import (
|
import (
|
||||||
"fmt"
|
"fmt"
|
||||||
"git.solsynth.dev/hydrogen/passport/pkg/internal/server/exts"
|
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
|
"git.solsynth.dev/hydrogen/passport/pkg/internal/server/exts"
|
||||||
|
|
||||||
"github.com/gofiber/fiber/v2"
|
"github.com/gofiber/fiber/v2"
|
||||||
|
|
||||||
"git.solsynth.dev/hydrogen/passport/pkg/internal/services"
|
"git.solsynth.dev/hydrogen/passport/pkg/internal/services"
|
||||||
@ -39,6 +40,8 @@ func doAuthenticate(c *fiber.Ctx) error {
|
|||||||
return fiber.NewError(fiber.StatusBadRequest, fmt.Sprintf("account was not found: %v", err.Error()))
|
return fiber.NewError(fiber.StatusBadRequest, fmt.Sprintf("account was not found: %v", err.Error()))
|
||||||
} else if user.ConfirmedAt == nil {
|
} else if user.ConfirmedAt == nil {
|
||||||
return fiber.NewError(fiber.StatusForbidden, "account was not confirmed")
|
return fiber.NewError(fiber.StatusForbidden, "account was not confirmed")
|
||||||
|
} else if user.SuspendedAt == nil {
|
||||||
|
return fiber.NewError(fiber.StatusForbidden, "account was suspended")
|
||||||
}
|
}
|
||||||
|
|
||||||
ticket, err := services.NewTicket(user, c.IP(), c.Get(fiber.HeaderUserAgent))
|
ticket, err := services.NewTicket(user, c.IP(), c.Get(fiber.HeaderUserAgent))
|
||||||
|
Loading…
Reference in New Issue
Block a user