diff --git a/backend/app/api/v1/auth.go b/backend/app/api/v1/auth.go index cf532bd3a..e7bd86e02 100644 --- a/backend/app/api/v1/auth.go +++ b/backend/app/api/v1/auth.go @@ -106,40 +106,6 @@ func (b *BaseApi) CheckIsSafety(c *gin.Context) { helper.SuccessWithData(c, authService.CheckIsSafety(code)) } -// @Tags Auth -// @Summary Check is First login -// @Description 判断是否为首次登录 -// @Success 200 -// @Router /auth/isfirst [get] -func (b *BaseApi) CheckIsFirstLogin(c *gin.Context) { - helper.SuccessWithData(c, authService.CheckIsFirst()) -} - -// @Tags Auth -// @Summary Init user -// @Description 初始化用户 -// @Accept json -// @Param request body dto.InitUser true "request" -// @Success 200 -// @Router /auth/init [post] -func (b *BaseApi) InitUserInfo(c *gin.Context) { - var req dto.InitUser - if err := c.ShouldBindJSON(&req); err != nil { - helper.ErrorWithDetail(c, constant.CodeErrBadRequest, constant.ErrTypeInvalidParams, err) - return - } - if err := global.VALID.Struct(req); err != nil { - helper.ErrorWithDetail(c, constant.CodeErrBadRequest, constant.ErrTypeInvalidParams, err) - return - } - - if err := authService.InitUser(c, req); err != nil { - helper.ErrorWithDetail(c, constant.CodeErrInternalServer, constant.ErrTypeInternalServer, err) - return - } - helper.SuccessWithData(c, nil) -} - // @Tags Auth // @Summary Check System isDemo // @Description 判断是否为demo环境 diff --git a/backend/app/dto/auth.go b/backend/app/dto/auth.go index 50e06a4d9..1e831c63f 100644 --- a/backend/app/dto/auth.go +++ b/backend/app/dto/auth.go @@ -31,8 +31,3 @@ type MFALogin struct { Code string `json:"code"` AuthMethod string `json:"authMethod"` } - -type InitUser struct { - Name string `json:"name" validate:"required"` - Password string `json:"password" validate:"required"` -} diff --git a/backend/app/service/auth.go b/backend/app/service/auth.go index 6c1512938..cd7e13555 100644 --- a/backend/app/service/auth.go +++ b/backend/app/service/auth.go @@ -2,10 +2,8 @@ package service import ( "strconv" - "time" "github.com/1Panel-dev/1Panel/backend/app/dto" - "github.com/1Panel-dev/1Panel/backend/buserr" "github.com/1Panel-dev/1Panel/backend/constant" "github.com/1Panel-dev/1Panel/backend/global" "github.com/1Panel-dev/1Panel/backend/utils/encrypt" @@ -20,8 +18,6 @@ type AuthService struct{} type IAuthService interface { CheckIsSafety(code string) bool - CheckIsFirst() bool - InitUser(c *gin.Context, req dto.InitUser) error VerifyCode(code string) (bool, error) Login(c *gin.Context, info dto.Login) (*dto.UserLoginInfo, error) LogOut(c *gin.Context) error @@ -157,39 +153,3 @@ func (u *AuthService) CheckIsSafety(code string) bool { } return status.Value == code } - -func (u *AuthService) CheckIsFirst() bool { - user, _ := settingRepo.Get(settingRepo.WithByKey("UserName")) - pass, _ := settingRepo.Get(settingRepo.WithByKey("Password")) - return len(user.Value) == 0 || len(pass.Value) == 0 -} - -func (u *AuthService) InitUser(c *gin.Context, req dto.InitUser) error { - user, _ := settingRepo.Get(settingRepo.WithByKey("UserName")) - pass, _ := settingRepo.Get(settingRepo.WithByKey("Password")) - if len(user.Value) == 0 || len(pass.Value) == 0 { - newPass, err := encrypt.StringEncrypt(req.Password) - if err != nil { - return err - } - if err := settingRepo.Update("UserName", req.Name); err != nil { - return err - } - if err := settingRepo.Update("Password", newPass); err != nil { - return err - } - expiredSetting, err := settingRepo.Get(settingRepo.WithByKey("ExpirationDays")) - if err != nil { - return err - } - timeout, _ := strconv.Atoi(expiredSetting.Value) - if timeout != 0 { - if err := settingRepo.Update("ExpirationTime", time.Now().AddDate(0, 0, timeout).Format("2006-01-02 15:04:05")); err != nil { - return err - } - } - return nil - } - - return buserr.New(constant.ErrInitUser) -} diff --git a/backend/router/ro_base.go b/backend/router/ro_base.go index d854f0fde..4ccb6aeb4 100644 --- a/backend/router/ro_base.go +++ b/backend/router/ro_base.go @@ -14,9 +14,7 @@ func (s *BaseRouter) InitBaseRouter(Router *gin.RouterGroup) { baseRouter.GET("/captcha", baseApi.Captcha) baseRouter.POST("/mfalogin", baseApi.MFALogin) baseRouter.POST("/login", baseApi.Login) - baseRouter.GET("/isfirst", baseApi.CheckIsFirstLogin) baseRouter.GET("/issafety", baseApi.CheckIsSafety) - baseRouter.POST("/init", baseApi.InitUserInfo) baseRouter.POST("/logout", baseApi.LogOut) baseRouter.GET("/demo", baseApi.CheckIsDemo) } diff --git a/cmd/server/docs/docs.go b/cmd/server/docs/docs.go index 6ddb6664e..72a997a2a 100644 --- a/cmd/server/docs/docs.go +++ b/cmd/server/docs/docs.go @@ -799,48 +799,6 @@ var doc = `{ } } }, - "/auth/init": { - "post": { - "description": "初始化用户", - "consumes": [ - "application/json" - ], - "tags": [ - "Auth" - ], - "summary": "Init user", - "parameters": [ - { - "description": "request", - "name": "request", - "in": "body", - "required": true, - "schema": { - "$ref": "#/definitions/dto.InitUser" - } - } - ], - "responses": { - "200": { - "description": "" - } - } - } - }, - "/auth/isfirst": { - "get": { - "description": "判断是否为首次登录", - "tags": [ - "Auth" - ], - "summary": "Check is First login", - "responses": { - "200": { - "description": "" - } - } - } - }, "/auth/issafety": { "get": { "description": "获取系统安全登录状态", @@ -11073,21 +11031,6 @@ var doc = `{ } } }, - "dto.InitUser": { - "type": "object", - "required": [ - "name", - "password" - ], - "properties": { - "name": { - "type": "string" - }, - "password": { - "type": "string" - } - } - }, "dto.InspectReq": { "type": "object", "properties": { @@ -11987,7 +11930,8 @@ var doc = `{ ], "properties": { "description": { - "type": "string" + "type": "string", + "maxLength": 256 }, "from": { "type": "string", @@ -12006,7 +11950,8 @@ var doc = `{ "type": "object", "properties": { "description": { - "type": "string" + "type": "string", + "maxLength": 256 }, "from": { "type": "string" @@ -12043,7 +11988,8 @@ var doc = `{ ], "properties": { "description": { - "type": "string" + "type": "string", + "maxLength": 256 }, "id": { "type": "integer" diff --git a/cmd/server/docs/swagger.json b/cmd/server/docs/swagger.json index eba0b8eb9..38b662678 100644 --- a/cmd/server/docs/swagger.json +++ b/cmd/server/docs/swagger.json @@ -785,48 +785,6 @@ } } }, - "/auth/init": { - "post": { - "description": "初始化用户", - "consumes": [ - "application/json" - ], - "tags": [ - "Auth" - ], - "summary": "Init user", - "parameters": [ - { - "description": "request", - "name": "request", - "in": "body", - "required": true, - "schema": { - "$ref": "#/definitions/dto.InitUser" - } - } - ], - "responses": { - "200": { - "description": "" - } - } - } - }, - "/auth/isfirst": { - "get": { - "description": "判断是否为首次登录", - "tags": [ - "Auth" - ], - "summary": "Check is First login", - "responses": { - "200": { - "description": "" - } - } - } - }, "/auth/issafety": { "get": { "description": "获取系统安全登录状态", @@ -11059,21 +11017,6 @@ } } }, - "dto.InitUser": { - "type": "object", - "required": [ - "name", - "password" - ], - "properties": { - "name": { - "type": "string" - }, - "password": { - "type": "string" - } - } - }, "dto.InspectReq": { "type": "object", "properties": { @@ -11973,7 +11916,8 @@ ], "properties": { "description": { - "type": "string" + "type": "string", + "maxLength": 256 }, "from": { "type": "string", @@ -11992,7 +11936,8 @@ "type": "object", "properties": { "description": { - "type": "string" + "type": "string", + "maxLength": 256 }, "from": { "type": "string" @@ -12029,7 +11974,8 @@ ], "properties": { "description": { - "type": "string" + "type": "string", + "maxLength": 256 }, "id": { "type": "integer" diff --git a/cmd/server/docs/swagger.yaml b/cmd/server/docs/swagger.yaml index 125995550..1d14e2a27 100644 --- a/cmd/server/docs/swagger.yaml +++ b/cmd/server/docs/swagger.yaml @@ -904,16 +904,6 @@ definitions: - sourceID - targetName type: object - dto.InitUser: - properties: - name: - type: string - password: - type: string - required: - - name - - password - type: object dto.InspectReq: properties: id: @@ -1510,6 +1500,7 @@ definitions: dto.SnapshotCreate: properties: description: + maxLength: 256 type: string from: enum: @@ -1526,6 +1517,7 @@ definitions: dto.SnapshotImport: properties: description: + maxLength: 256 type: string from: type: string @@ -1548,6 +1540,7 @@ definitions: dto.UpdateDescription: properties: description: + maxLength: 256 type: string id: type: integer @@ -3553,33 +3546,6 @@ paths: summary: Check System isDemo tags: - Auth - /auth/init: - post: - consumes: - - application/json - description: 初始化用户 - parameters: - - description: request - in: body - name: request - required: true - schema: - $ref: '#/definitions/dto.InitUser' - responses: - "200": - description: "" - summary: Init user - tags: - - Auth - /auth/isfirst: - get: - description: 判断是否为首次登录 - responses: - "200": - description: "" - summary: Check is First login - tags: - - Auth /auth/issafety: get: description: 获取系统安全登录状态 diff --git a/frontend/src/api/interface/auth.ts b/frontend/src/api/interface/auth.ts index a8391fcbc..ec1a7f777 100644 --- a/frontend/src/api/interface/auth.ts +++ b/frontend/src/api/interface/auth.ts @@ -18,10 +18,6 @@ export namespace Login { token: string; mfaStatus: string; } - export interface InitUser { - name: string; - password: string; - } export interface ResCaptcha { imagePath: string; captchaID: string; diff --git a/frontend/src/api/modules/auth.ts b/frontend/src/api/modules/auth.ts index 72196fe5c..d670b6ef0 100644 --- a/frontend/src/api/modules/auth.ts +++ b/frontend/src/api/modules/auth.ts @@ -25,18 +25,10 @@ export const loginStatus = () => { return http.get('/info'); }; -export const checkIsFirst = () => { - return http.get('/auth/isfirst'); -}; - export const checkIsSafety = (code: string) => { return http.get(`/auth/issafety?code=${code}`); }; -export const initUser = (params: Login.InitUser) => { - return http.post(`/auth/init`, params); -}; - export const checkIsDemo = () => { return http.get('/auth/demo'); }; diff --git a/frontend/src/lang/modules/en.ts b/frontend/src/lang/modules/en.ts index 08dad95d9..8bff74690 100644 --- a/frontend/src/lang/modules/en.ts +++ b/frontend/src/lang/modules/en.ts @@ -105,10 +105,8 @@ const message = { comfimNoNull: 'Make sure the value {0} is not empty', }, login: { - firstLogin: 'First login, please create an initial administrator user!', username: 'UserName', password: 'Password', - rePassword: 'Confirm Password', welcome: 'Welcome back, please enter your username and password to log in!', errorAuthInfo: 'The user name or password you entered is incorrect, please re-enter!', errorMfaInfo: 'Incorrect authentication information, please try again!', diff --git a/frontend/src/lang/modules/zh.ts b/frontend/src/lang/modules/zh.ts index 8977d984a..b14274c9b 100644 --- a/frontend/src/lang/modules/zh.ts +++ b/frontend/src/lang/modules/zh.ts @@ -109,10 +109,8 @@ const message = { comfimNoNull: '请确认 {0} 值不为空', }, login: { - firstLogin: '首次登录,请创建初始管理员用户!', username: '用户名', password: '密码', - rePassword: '确认密码', welcome: '欢迎回来,请输入用户名和密码登录!', errorAuthInfo: '您输入的用户名或密码不正确,请重新输入!', errorMfaInfo: '错误的验证信息,请重试!', diff --git a/frontend/src/views/login/components/login-form.vue b/frontend/src/views/login/components/login-form.vue index fed68c51d..0a621a958 100644 --- a/frontend/src/views/login/components/login-form.vue +++ b/frontend/src/views/login/components/login-form.vue @@ -1,74 +1,6 @@