online state
This commit is contained in:
@@ -771,7 +771,7 @@ func PostNeServiceAction(w http.ResponseWriter, r *http.Request) {
|
||||
// neInfo := new(dborm.NeInfo)
|
||||
neInfo, err := dborm.XormGetNeInfo(neType, neId)
|
||||
if err != nil {
|
||||
log.Errorf("Failed to get ne_info:", err)
|
||||
log.Error("Failed to get ne_info:", err)
|
||||
services.ResponseInternalServerError500DatabaseOperationFailed(w)
|
||||
return
|
||||
}
|
||||
@@ -785,7 +785,7 @@ func PostNeServiceAction(w http.ResponseWriter, r *http.Request) {
|
||||
out, err := cmd.CombinedOutput()
|
||||
log.Debugf("Exec output: %v", string(out))
|
||||
if err != nil {
|
||||
log.Error("Faile to execute ssh %s omc:", action, err)
|
||||
log.Errorf("Faile to execute ssh %s omc:%v", action, err)
|
||||
services.ResponseInternalServerError500ProcessError(w, err)
|
||||
return
|
||||
}
|
||||
@@ -797,7 +797,7 @@ func PostNeServiceAction(w http.ResponseWriter, r *http.Request) {
|
||||
out, err := cmd.CombinedOutput()
|
||||
log.Debugf("Exec output: %v", string(out))
|
||||
if err != nil {
|
||||
log.Error("Faile to execute ssh sudo ims-%s command:", action, err)
|
||||
log.Errorf("Faile to execute %s command:%v", actionCmd, err)
|
||||
services.ResponseInternalServerError500ProcessError(w, err)
|
||||
return
|
||||
}
|
||||
@@ -807,13 +807,13 @@ func PostNeServiceAction(w http.ResponseWriter, r *http.Request) {
|
||||
out, err := cmd.CombinedOutput()
|
||||
log.Debugf("Exec output: %v", string(out))
|
||||
if err != nil {
|
||||
log.Error("Faile to execute ssh sudo ims-%s command:", action, err)
|
||||
log.Errorf("Faile to execute %s command:%v", actionCmd, err)
|
||||
services.ResponseInternalServerError500ProcessError(w, err)
|
||||
return
|
||||
}
|
||||
default:
|
||||
err = global.ErrCMUnknownServiceAction
|
||||
log.Error("%v, action:%s", err, action)
|
||||
log.Errorf("%v, action:%s", err, action)
|
||||
services.ResponseInternalServerError500ProcessError(w, err)
|
||||
return
|
||||
}
|
||||
@@ -823,11 +823,10 @@ func PostNeServiceAction(w http.ResponseWriter, r *http.Request) {
|
||||
out, err := cmd.CombinedOutput()
|
||||
log.Debugf("Exec output: %v", string(out))
|
||||
if err != nil {
|
||||
log.Error("Faile to execute ssh sudo systemctl command:", err)
|
||||
log.Error("Faile to execute command:", err)
|
||||
services.ResponseInternalServerError500ProcessError(w, err)
|
||||
return
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
services.ResponseStatusOK204NoContent(w)
|
||||
@@ -898,7 +897,7 @@ func PostNeInstanceAction(w http.ResponseWriter, r *http.Request) {
|
||||
}
|
||||
default:
|
||||
err = global.ErrCMUnknownInstanceAction
|
||||
log.Error("%v, action:%s", err, action)
|
||||
log.Errorf("%v, action:%s", err, action)
|
||||
services.ResponseInternalServerError500ProcessError(w, err)
|
||||
return
|
||||
}
|
||||
|
||||
@@ -7,6 +7,7 @@ import (
|
||||
"io"
|
||||
"net/http"
|
||||
"strconv"
|
||||
"strings"
|
||||
"time"
|
||||
|
||||
"ems.agt/features/security/service"
|
||||
@@ -118,7 +119,7 @@ func LoginFromOMC(w http.ResponseWriter, r *http.Request) {
|
||||
}
|
||||
|
||||
token := oauth.GenRandToken("omc") // Generate new token to session ID
|
||||
sourceAddr := r.RemoteAddr
|
||||
sourceAddr := r.RemoteAddr[:strings.Index(r.RemoteAddr, ":")]
|
||||
affected, err := dborm.XormInsertSession(oAuthBody.UserName, sourceAddr, token,
|
||||
config.GetExpiresFromConfig(), config.GetYamlConfig().Auth.Session)
|
||||
if err != nil {
|
||||
@@ -185,7 +186,6 @@ func LogoutFromOMC(w http.ResponseWriter, r *http.Request) {
|
||||
// 清除缓存用户信息
|
||||
account.ClearLoginUser(se.AccountId)
|
||||
services.ResponseStatusOK200Null(w)
|
||||
return
|
||||
}
|
||||
|
||||
func HandshakeFromOMC(w http.ResponseWriter, r *http.Request) {
|
||||
@@ -208,7 +208,7 @@ func HandshakeFromOMC(w http.ResponseWriter, r *http.Request) {
|
||||
// error processing ...
|
||||
// 401-1 response
|
||||
token, ret := oauth.IsCarriedToken(r)
|
||||
if ret == false {
|
||||
if !ret {
|
||||
log.Error("AccessToken is not carried")
|
||||
services.ResponseUnauthorized401AccessTokenNotCarried(w)
|
||||
return
|
||||
@@ -221,14 +221,13 @@ func HandshakeFromOMC(w http.ResponseWriter, r *http.Request) {
|
||||
return
|
||||
}
|
||||
services.ResponseStatusOK200Null(w)
|
||||
return
|
||||
}
|
||||
|
||||
// 系统登录
|
||||
//
|
||||
// POST /login
|
||||
func LoginOMC(w http.ResponseWriter, r *http.Request) {
|
||||
log.Info("LoginFromOMC processing... ")
|
||||
log.Info("LoginOMC processing... ")
|
||||
var body struct {
|
||||
Username string `json:"username" binding:"required"` // Username 用户名
|
||||
Password string `json:"password" binding:"required"` // Password 用户密码
|
||||
@@ -285,7 +284,7 @@ func LoginOMC(w http.ResponseWriter, r *http.Request) {
|
||||
}
|
||||
|
||||
token := oauth.GenRandToken("omc") // Generate new token to session ID
|
||||
sourceAddr := r.RemoteAddr
|
||||
sourceAddr := r.RemoteAddr[:strings.Index(r.RemoteAddr, ":")]
|
||||
affected, err := dborm.XormInsertSession(body.Username, sourceAddr, token,
|
||||
config.GetExpiresFromConfig(), config.GetYamlConfig().Auth.Session)
|
||||
if err != nil {
|
||||
|
||||
Reference in New Issue
Block a user