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