add automatic database migrations with goose
This commit is contained in:
		@@ -3,16 +3,11 @@ package api
 | 
			
		||||
import (
 | 
			
		||||
	"fmt"
 | 
			
		||||
	"github.com/dgrijalva/jwt-go"
 | 
			
		||||
	"gopkg.in/oauth2.v3"
 | 
			
		||||
	"gopkg.in/oauth2.v3/server"
 | 
			
		||||
	"net/http"
 | 
			
		||||
	"openmediacenter/apiGo/database"
 | 
			
		||||
	"strconv"
 | 
			
		||||
	"time"
 | 
			
		||||
)
 | 
			
		||||
 | 
			
		||||
var srv *server.Server
 | 
			
		||||
 | 
			
		||||
type Perm uint8
 | 
			
		||||
 | 
			
		||||
const (
 | 
			
		||||
@@ -103,15 +98,3 @@ func InitOAuth() {
 | 
			
		||||
		})
 | 
			
		||||
	})
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
func ValidateToken(f func(rw http.ResponseWriter, req *http.Request, node int, tokenInfo *oauth2.TokenInfo), node int) http.HandlerFunc {
 | 
			
		||||
	return func(w http.ResponseWriter, r *http.Request) {
 | 
			
		||||
		tokeninfo, err := srv.ValidationBearerToken(r)
 | 
			
		||||
		if err != nil {
 | 
			
		||||
			http.Error(w, err.Error(), http.StatusBadRequest)
 | 
			
		||||
			return
 | 
			
		||||
		}
 | 
			
		||||
 | 
			
		||||
		f(w, r, node, &tokeninfo)
 | 
			
		||||
	}
 | 
			
		||||
}
 | 
			
		||||
 
 | 
			
		||||
		Reference in New Issue
	
	Block a user