mirror of
https://github.com/0xJacky/nginx-ui.git
synced 2025-05-10 18:05:48 +02:00
bug fix
This commit is contained in:
parent
87c2fa520c
commit
855634cd45
10 changed files with 61 additions and 16 deletions
2
.gitignore
vendored
2
.gitignore
vendored
|
@ -3,3 +3,5 @@
|
|||
database.db
|
||||
tmp
|
||||
node_modules
|
||||
dist
|
||||
app.ini
|
||||
|
|
|
@ -2,3 +2,11 @@
|
|||
Yet another Nginx Web UI
|
||||
|
||||
Version: 0.1
|
||||
|
||||
# 安装
|
||||
1. 克隆项目
|
||||
2. 运行 install.sh
|
||||
3. 添加配置文件到 nginx
|
||||
```
|
||||
|
||||
```
|
||||
|
|
31
install.sh
Executable file
31
install.sh
Executable file
|
@ -0,0 +1,31 @@
|
|||
#!/bin/bash
|
||||
|
||||
echo "=========================="
|
||||
echo
|
||||
echo "Nginx UI Install Shell"
|
||||
echo "Copyright (c) 0xJacky 2021"
|
||||
echo
|
||||
echo "=========================="
|
||||
|
||||
echo "installing yarn..."
|
||||
npm install -g yarn
|
||||
|
||||
echo "Compiling frontend..."
|
||||
cd nginx-ui-frontend || exit 1
|
||||
yarn build
|
||||
|
||||
cd ..
|
||||
|
||||
echo "Compiling api server..."
|
||||
cd server || exit 1
|
||||
go build -o nginx-ui-server main.go
|
||||
|
||||
echo "Installing acme.sh..."
|
||||
go test -v test/acme_test.go
|
||||
|
||||
echo "build completed"
|
||||
cd ..
|
||||
|
||||
echo "==============="
|
||||
echo "frontend dist path: nginx-ui-frontend/dist"
|
||||
echo "start server, run server/nginx-ui-server"
|
|
@ -35,7 +35,9 @@ http.interceptors.response.use(
|
|||
return Promise.resolve(response.data)
|
||||
},
|
||||
async error => {
|
||||
console.log(error)
|
||||
if (error.response.status === 403) {
|
||||
await store.dispatch('logout')
|
||||
}
|
||||
return Promise.reject(error.response.data)
|
||||
}
|
||||
)
|
||||
|
|
|
@ -1 +1 @@
|
|||
{"version":"0.1.0","build_id":18}
|
||||
{"version":"0.1.0","build_id":20}
|
|
@ -51,12 +51,14 @@ func Login(c *gin.Context) {
|
|||
|
||||
func Logout(c *gin.Context) {
|
||||
token := c.GetHeader("Authorization")
|
||||
err := model.DeleteToken(token)
|
||||
if err != nil {
|
||||
c.JSON(http.StatusInternalServerError, gin.H{
|
||||
"message": err.Error(),
|
||||
})
|
||||
return
|
||||
if token != "" {
|
||||
err := model.DeleteToken(token)
|
||||
if err != nil {
|
||||
c.JSON(http.StatusInternalServerError, gin.H{
|
||||
"message": err.Error(),
|
||||
})
|
||||
return
|
||||
}
|
||||
}
|
||||
c.JSON(http.StatusNoContent, gin.H{})
|
||||
}
|
||||
|
|
4
server/app.example.ini
Normal file
4
server/app.example.ini
Normal file
|
@ -0,0 +1,4 @@
|
|||
[server]
|
||||
HttpPort = 9000
|
||||
RunMode = debug
|
||||
JwtSecret =
|
|
@ -1,5 +1,4 @@
|
|||
[server]
|
||||
HttpPort = 9000
|
||||
RunMode = debug
|
||||
WebSocketToken = f094ec2e-8455-48e1-a5c0-edabe1d79867
|
||||
JwtSecret = f094ec2e-8455-48e1-a5c0-edabe1d79867
|
||||
JwtSecret = F7AFBC0E-227E-40AC-918D-60122D725398
|
||||
|
|
|
@ -4,6 +4,7 @@ go 1.15
|
|||
|
||||
require (
|
||||
github.com/appleboy/gin-jwt/v2 v2.6.4
|
||||
github.com/dgrijalva/jwt-go v3.2.0+incompatible
|
||||
github.com/dustin/go-humanize v1.0.0
|
||||
github.com/gin-gonic/gin v1.6.3
|
||||
github.com/gorilla/websocket v1.4.2
|
||||
|
|
|
@ -5,7 +5,6 @@ import (
|
|||
"github.com/0xJacky/Nginx-UI/api"
|
||||
"github.com/0xJacky/Nginx-UI/model"
|
||||
"github.com/gin-gonic/gin"
|
||||
"log"
|
||||
"net/http"
|
||||
)
|
||||
|
||||
|
@ -23,11 +22,9 @@ func authRequired() gin.HandlerFunc {
|
|||
return
|
||||
}
|
||||
}
|
||||
log.Println(c.Query("token"))
|
||||
log.Println(token)
|
||||
|
||||
n := model.CheckToken(token)
|
||||
log.Println(n)
|
||||
|
||||
if n < 1 {
|
||||
c.JSON(http.StatusForbidden, gin.H{
|
||||
"message": "auth fail",
|
||||
|
@ -52,11 +49,10 @@ func InitRouter() *gin.Engine {
|
|||
})
|
||||
|
||||
r.POST("/login", api.Login)
|
||||
r.DELETE("/logout", api.Logout)
|
||||
|
||||
endpoint := r.Group("/", authRequired())
|
||||
{
|
||||
endpoint.DELETE("/logout", api.Logout)
|
||||
|
||||
endpoint.GET("domains", api.GetDomains)
|
||||
endpoint.GET("domain/:name", api.GetDomain)
|
||||
endpoint.POST("domain/:name", api.EditDomain)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue