sum7/warehost
sum7
/
warehost
Archived
1
0
Fork 0

fix system lib

This commit is contained in:
Martin Geno 2016-10-12 08:14:06 +02:00
parent 8bb5500a39
commit 6ee9ed8aa5
2 changed files with 4 additions and 3 deletions

View File

@ -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")

View File

@ -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")