fix system lib
This commit is contained in:
parent
8bb5500a39
commit
6ee9ed8aa5
|
@ -221,7 +221,7 @@ func loginList(ctx context.Context, w http.ResponseWriter, r *http.Request) (ret
|
|||
var logins []Login
|
||||
selectfield := "ID, mail"
|
||||
if login.Superadmin {
|
||||
selectfield = "ID, mail, superadmin"
|
||||
selectfield = "ID, mail, superadmin, active"
|
||||
}
|
||||
if err := dbconnection.Select(selectfield).Find(&logins).Error; err != nil {
|
||||
logger.Warn("sql edit login")
|
||||
|
|
|
@ -3,23 +3,24 @@ package system
|
|||
import (
|
||||
"net/http"
|
||||
|
||||
"github.com/astaxie/session"
|
||||
"golang.org/x/net/context"
|
||||
|
||||
libapi "dev.sum7.eu/sum7/warehost/lib/api"
|
||||
liblog "dev.sum7.eu/sum7/warehost/lib/log"
|
||||
libsession "dev.sum7.eu/sum7/warehost/lib/session"
|
||||
)
|
||||
|
||||
//LoginHandler for api function to Verifie User ist loggedin
|
||||
func LoginHandler(h libapi.Handle) libapi.Handle {
|
||||
return func(ctx context.Context, w http.ResponseWriter, r *http.Request) (returndata interface{}, returnerr *libapi.ErrorResult) {
|
||||
sess := ctx.Value("session").(session.Session)
|
||||
sess := ctx.Value("session").(libsession.Session)
|
||||
returndata = false
|
||||
|
||||
if login := sess.Get("login"); login != nil {
|
||||
if loginObj := login.(Login); loginObj.Active {
|
||||
ctx = context.WithValue(ctx, "login", &loginObj)
|
||||
returndata, returnerr = h(ctx, w, r)
|
||||
return
|
||||
}
|
||||
returnerr = &libapi.ErrorResult{Fields: []string{"session"}, Message: "Not active user"}
|
||||
liblog.Log.Warn("user not active")
|
||||
|
|
Reference in New Issue