dashboard/utils/sessionutils.go
2020-04-02 20:53:11 +01:00

21 lines
506 B
Go

package utils
import (
"github.com/gin-gonic/contrib/sessions"
"strconv"
)
func IsLoggedIn(store sessions.Session) bool {
return store.Get("access_token") != nil &&
store.Get("expiry") != nil &&
store.Get("refresh_token") != nil &&
store.Get("userid") != nil &&
store.Get("name") != nil &&
store.Get("avatar") != nil &&
store.Get("csrf") != nil
}
func GetUserId(store sessions.Session) (int64, error) {
return strconv.ParseInt(store.Get("userid").(string), 10, 64)
}