diff --git a/api/filter/authentication.go b/api/filter/authentication.go index 11c15618f8..0a2bfde1e0 100644 --- a/api/filter/authentication.go +++ b/api/filter/authentication.go @@ -27,7 +27,7 @@ import ( func Authentication() gin.HandlerFunc { return func(c *gin.Context) { - if c.Request.URL.Path != "/user/login" && strings.HasPrefix(c.Request.URL.Path,"/apisix") { + if c.Request.URL.Path != "/apisix/admin/user/login" && strings.HasPrefix(c.Request.URL.Path,"/apisix") { tokenStr := c.GetHeader("Authorization") // verify token diff --git a/api/route/authentication.go b/api/route/authentication.go index c19fa6aa86..98348959e5 100644 --- a/api/route/authentication.go +++ b/api/route/authentication.go @@ -30,7 +30,7 @@ type UserSession struct { } func AppendAuthentication(r *gin.Engine) *gin.Engine { - r.POST("/user/login", userLogin) + r.POST("/apisix/admin/user/login", userLogin) return r } diff --git a/api/route/authentication_test.go b/api/route/authentication_test.go index 0cc0214977..89c1b4b3d4 100644 --- a/api/route/authentication_test.go +++ b/api/route/authentication_test.go @@ -28,7 +28,7 @@ var token string func TestUserLogin(t *testing.T) { // password error handler. - Post("/user/login"). + Post("/apisix/admin/user/login"). Header("Content-Type", "application/x-www-form-urlencoded"). Body("username=admin&password=admin1"). Expect(t). @@ -37,7 +37,7 @@ func TestUserLogin(t *testing.T) { // login success sessionResponse := handler. - Post("/user/login"). + Post("/apisix/admin/user/login"). Header("Content-Type", "application/x-www-form-urlencoded"). Body("username=admin&password=admin"). Expect(t). diff --git a/compose/dashboard_conf/nginx.conf b/compose/dashboard_conf/nginx.conf index 497780d0b9..3735dd8de2 100644 --- a/compose/dashboard_conf/nginx.conf +++ b/compose/dashboard_conf/nginx.conf @@ -15,13 +15,6 @@ server { try_files $uri $uri/ /index.html; } - location /user/login { - if ( $request_method = 'POST' ) { #HERE - proxy_pass http://manager:8080; - } - try_files $uri $uri/ /index.html; - } - location /apisix/admin { proxy_pass http://manager:8080/apisix/admin; } diff --git a/src/pages/User/components/LoginMethodPassword.tsx b/src/pages/User/components/LoginMethodPassword.tsx index da0e384428..504f739806 100644 --- a/src/pages/User/components/LoginMethodPassword.tsx +++ b/src/pages/User/components/LoginMethodPassword.tsx @@ -95,7 +95,7 @@ const LoginMethodPassword: UserModule.LoginMethod = { submit: async (data) => { if (data.username !== '' && data.password !== '') { try { - const result = await request('/user/login', { + const result = await request('/apisix/admin/user/login', { method: 'POST', requestType: 'form', prefix: '', @@ -127,7 +127,6 @@ const LoginMethodPassword: UserModule.LoginMethod = { } }, logout: () => { - console.log('password logout'); localStorage.removeItem('token'); }, };