Skip to content

Commit d6db8da

Browse files
committed
fix: update login license redirect
1 parent 13fed02 commit d6db8da

19 files changed

Lines changed: 77 additions & 188 deletions

File tree

core/app/api/v2/auth.go

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -461,6 +461,28 @@ func (b *BaseApi) UpdateCurrentUser(c *gin.Context) {
461461
helper.Success(c)
462462
}
463463

464+
// @Tags Auth
465+
// @Summary Reset system password expired
466+
// @Accept json
467+
// @Param request body dto.PasswordUpdate true "request"
468+
// @Success 200
469+
// @Security ApiKeyAuth
470+
// @Security Timestamp
471+
// @Router /core/auth/expired/reset [post]
472+
// @x-panel-log {"bodyKeys":[],"paramKeys":[],"BeforeFunctions":[],"formatZH":"重置过期密码","formatEN":"reset an expired Password"}
473+
func (b *BaseApi) ResetPassword(c *gin.Context) {
474+
var req dto.PasswordUpdate
475+
if err := helper.CheckBindAndValidate(&req, c); err != nil {
476+
return
477+
}
478+
479+
if err := xpack.AuthProvider.HandlePasswordExpired(c, req.OldPassword, req.NewPassword); err != nil {
480+
helper.InternalServer(c, err)
481+
return
482+
}
483+
helper.Success(c)
484+
}
485+
464486
func saveLoginLogs(c *gin.Context, err error) {
465487
var logs model.LoginLog
466488
if err != nil {

core/app/api/v2/setting.go

Lines changed: 0 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,6 @@ import (
1717
"github.com/1Panel-dev/1Panel/core/constant"
1818
"github.com/1Panel-dev/1Panel/core/global"
1919
"github.com/1Panel-dev/1Panel/core/utils/common"
20-
"github.com/1Panel-dev/1Panel/core/utils/xpack"
2120
"github.com/gin-gonic/gin"
2221
)
2322

@@ -338,28 +337,6 @@ func (b *BaseApi) UpdatePort(c *gin.Context) {
338337
helper.Success(c)
339338
}
340339

341-
// @Tags System Setting
342-
// @Summary Reset system password expired
343-
// @Accept json
344-
// @Param request body dto.PasswordUpdate true "request"
345-
// @Success 200
346-
// @Security ApiKeyAuth
347-
// @Security Timestamp
348-
// @Router /core/settings/expired/handle [post]
349-
// @x-panel-log {"bodyKeys":[],"paramKeys":[],"BeforeFunctions":[],"formatZH":"重置过期密码","formatEN":"reset an expired Password"}
350-
func (b *BaseApi) HandlePasswordExpired(c *gin.Context) {
351-
var req dto.PasswordUpdate
352-
if err := helper.CheckBindAndValidate(&req, c); err != nil {
353-
return
354-
}
355-
356-
if err := xpack.AuthProvider.HandlePasswordExpired(c, req.OldPassword, req.NewPassword); err != nil {
357-
helper.InternalServer(c, err)
358-
return
359-
}
360-
helper.Success(c)
361-
}
362-
363340
func (b *BaseApi) ReloadSSL(c *gin.Context) {
364341
clientIP := c.ClientIP()
365342
if clientIP != "127.0.0.1" {

core/app/service/logs.go

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ import (
44
"bytes"
55
"fmt"
66
"net/http"
7+
"os"
78

89
"github.com/1Panel-dev/1Panel/core/buserr"
910
"github.com/1Panel-dev/1Panel/core/constant"
@@ -126,7 +127,7 @@ func runRemoteShellScript(url string, args ...string) error {
126127
if statusCode < http.StatusOK || statusCode >= http.StatusMultipleChoices {
127128
return fmt.Errorf("download script failed, status code: %d", statusCode)
128129
}
129-
_, err = cmd.NewCommandMgr().RunPipe(cmd.PipeCommand{
130+
_, err = cmd.NewCommandMgr(cmd.WithOutputFile(os.DevNull)).RunPipe(cmd.PipeCommand{
130131
Name: "sh",
131132
Args: append([]string{"-s"}, args...),
132133
Stdin: bytes.NewReader(script),

core/cmd/server/conf/app.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ base:
44
is_demo: false
55
is_offline: false
66
is_fxplay: false
7-
is_xpackee: false
7+
is_xpackee: true
88
port: 9999
99
username: admin
1010
password: admin123

core/middleware/password_expired.go

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,9 +16,11 @@ import (
1616
func PasswordExpired() gin.HandlerFunc {
1717
return func(c *gin.Context) {
1818
if strings.HasPrefix(c.Request.URL.Path, "/api/v2/core/auth") ||
19-
c.Request.URL.Path == "/api/v2/core/settings/expired/handle" ||
2019
c.Request.URL.Path == "/api/v2/core/settings/search" ||
21-
c.Request.URL.Path == "/api/v2/core/settings/search/base" {
20+
c.Request.URL.Path == "/api/v2/core/settings/search/base" ||
21+
c.Request.URL.Path == "/api/v2/core/xpackee/licenses/info" ||
22+
c.Request.URL.Path == "/api/v2/core/xpackee/licenses/status" ||
23+
c.Request.URL.Path == "/api/v2/core/xpackee/licenses/upload" {
2224
c.Next()
2325
return
2426
}

core/router/ro_base.go

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,14 +26,17 @@ func (s *BaseRouter) InitRouter(Router *gin.RouterGroup) {
2626

2727
authRouter.POST("/mfa", baseApi.LoadMFA)
2828
authRouter.POST("/mfa/bind", baseApi.MFABind)
29+
2930
authRouter.POST("/passkey/register/begin", baseApi.PasskeyRegisterBegin)
3031
authRouter.POST("/passkey/register/finish", baseApi.PasskeyRegisterFinish)
3132
authRouter.GET("/passkey/list", baseApi.PasskeyList)
3233
authRouter.POST("/passkey/del", baseApi.PasskeyDelete)
34+
3335
authRouter.POST("/api/generate", baseApi.GenerateApiKey)
3436
authRouter.POST("/api/update", baseApi.UpdateApiConfig)
3537

3638
authRouter.GET("/current", baseApi.GetCurrentUser)
3739
authRouter.POST("/current/update", baseApi.UpdateCurrentUser)
40+
authRouter.POST("/expired/reset", baseApi.ResetPassword)
3841
}
3942
}

core/router/ro_setting.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,10 +18,10 @@ func (s *SettingRouter) InitRouter(Router *gin.RouterGroup) {
1818
noAuthRouter := Router.Group("settings")
1919
baseApi := v2.ApiGroupApp.BaseApi
2020
{
21-
router.POST("/search", baseApi.GetSettingInfo)
2221
router.POST("/search/base", baseApi.GetSettingBaseInfo)
2322

2423
settingRouter.POST("/by", baseApi.GetSettingByKey)
24+
settingRouter.POST("/search", baseApi.GetSettingInfo)
2525
settingRouter.POST("/terminal/search", baseApi.GetTerminalSettingInfo)
2626
settingRouter.GET("/search/available", baseApi.GetSystemAvailable)
2727
settingRouter.POST("/update", baseApi.UpdateSetting)

frontend/src/api/index.ts

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -95,7 +95,12 @@ class RequestHttp {
9595
if (data.code == ResultEnum.ERRXPACKEE) {
9696
globalStore.isXpackEELicensed = false;
9797
const routeName = router.currentRoute.value.name;
98-
if (globalStore.isLogin && routeName !== 'entrance' && routeName !== 'login') {
98+
if (
99+
globalStore.isLogin &&
100+
routeName !== 'entrance' &&
101+
routeName !== 'login' &&
102+
routeName !== 'XpackEELicenseRequired'
103+
) {
99104
router.push({ name: 'XpackEELicenseRequired' });
100105
}
101106
return Promise.reject(data);

frontend/src/api/interface/auth.ts

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -90,4 +90,8 @@ export namespace Login {
9090
ipWhiteList: string;
9191
apiKeyValidityTime: string;
9292
}
93+
export interface PasswordUpdate {
94+
oldPassword: string;
95+
newPassword: string;
96+
}
9397
}

frontend/src/api/interface/setting.ts

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -152,10 +152,6 @@ export namespace Setting {
152152
key: string;
153153
sslID: number;
154154
}
155-
export interface PasswordUpdate {
156-
oldPassword: string;
157-
newPassword: string;
158-
}
159155
export interface PortUpdate {
160156
serverPort: number;
161157
}

0 commit comments

Comments
 (0)