mirror of https://github.com/Xhofe/alist
feat(register-and-statistics): add user registration endpoint (#register-and-statistics)
- Added `POST /auth/register` endpoint to support user registration. - Implemented registration logic in `auth.go` with dynamic role assignment. - Integrated `AllowRegister` and `DefaultRole` settings for registration flow. - Updated imports to include new modules: `conf`, `setting`. - Adjusted user creation logic to use `DefaultRole` dynamically.pull/9277/head
parent
a2aaa32c34
commit
17b287972f
|
@ -4,8 +4,10 @@ import (
|
||||||
"github.com/alist-org/alist/v3/pkg/utils"
|
"github.com/alist-org/alist/v3/pkg/utils"
|
||||||
"strconv"
|
"strconv"
|
||||||
|
|
||||||
|
"github.com/alist-org/alist/v3/internal/conf"
|
||||||
"github.com/alist-org/alist/v3/internal/model"
|
"github.com/alist-org/alist/v3/internal/model"
|
||||||
"github.com/alist-org/alist/v3/internal/op"
|
"github.com/alist-org/alist/v3/internal/op"
|
||||||
|
"github.com/alist-org/alist/v3/internal/setting"
|
||||||
"github.com/alist-org/alist/v3/server/common"
|
"github.com/alist-org/alist/v3/server/common"
|
||||||
"github.com/gin-gonic/gin"
|
"github.com/gin-gonic/gin"
|
||||||
log "github.com/sirupsen/logrus"
|
log "github.com/sirupsen/logrus"
|
||||||
|
@ -36,6 +38,9 @@ func CreateUser(c *gin.Context) {
|
||||||
common.ErrorResp(c, err, 400)
|
common.ErrorResp(c, err, 400)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
if len(req.Role) == 0 {
|
||||||
|
req.Role = model.Roles{setting.GetInt(conf.DefaultRole, int(model.GUEST))}
|
||||||
|
}
|
||||||
if req.IsAdmin() || req.IsGuest() {
|
if req.IsAdmin() || req.IsGuest() {
|
||||||
common.ErrorStrResp(c, "admin or guest user can not be created", 400, true)
|
common.ErrorStrResp(c, "admin or guest user can not be created", 400, true)
|
||||||
return
|
return
|
||||||
|
|
Loading…
Reference in New Issue