mirror of
https://github.com/ehang-io/nps.git
synced 2025-09-02 11:56:53 +00:00
redo web UI |web close| client log |system info |p2p |max、ump optimization
This commit is contained in:
32
web/controllers/auth.go
Normal file
32
web/controllers/auth.go
Normal file
@@ -0,0 +1,32 @@
|
||||
package controllers
|
||||
|
||||
import (
|
||||
"github.com/cnlh/nps/lib/crypt"
|
||||
"github.com/cnlh/nps/vender/github.com/astaxie/beego"
|
||||
)
|
||||
|
||||
type AuthController struct {
|
||||
beego.Controller
|
||||
}
|
||||
|
||||
func (s *AuthController) GetAuthKey() {
|
||||
m := make(map[string]interface{})
|
||||
defer func() {
|
||||
s.Data["json"] = m
|
||||
s.ServeJSON()
|
||||
}()
|
||||
if cryptKey := beego.AppConfig.String("cryptKey"); len(cryptKey) != 16 {
|
||||
m["status"] = 0
|
||||
return
|
||||
} else {
|
||||
b, err := crypt.AesEncrypt([]byte(beego.AppConfig.String("authKey")), []byte(cryptKey))
|
||||
if err != nil {
|
||||
m["status"] = 0
|
||||
return
|
||||
}
|
||||
m["status"] = 1
|
||||
m["crypt_auth_key"] = string(b)
|
||||
m["crypt_type"] = "aes cbc"
|
||||
return
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user