Woooo! Login & Gallery Loading Working!

This commit is contained in:
2021-02-21 22:36:25 -05:00
parent 901a69bb91
commit f46db58ed1
12 changed files with 155 additions and 100 deletions

View File

@@ -37,7 +37,6 @@ func (api *API) mediaHandler(w http.ResponseWriter, r *http.Request) {
rawUserID, _ := (*authContext.AccessToken).Get("sub")
userID := rawUserID.(string)
// TODO: Derive Cache & Width Location
// Derive Path
fileName := path.Base(r.URL.Path)
folderPath := path.Join("/" + api.Config.DataPath + "/media/" + userID)

View File

@@ -52,6 +52,20 @@ func (api *API) queryMiddleware(next http.Handler) http.Handler {
**/
func (api *API) authMiddleware(next http.Handler) http.HandlerFunc {
return http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
// TODO: REMOVE (SOME OF) THIS!! Only for developement due to CORS
w.Header().Set("Access-Control-Allow-Credentials", "true")
w.Header().Set("Access-Control-Allow-Origin", "*")
//w.Header().Set("Access-Control-Expose-Headers", "*")
w.Header().Set("Access-Control-Allow-Headers", "x-imagini-accesstoken,x-imagini-refreshtoken")
w.Header().Set("Access-Control-Allow-Methods", "POST, GET, OPTIONS, PUT, DELETE")
// CORS Preflight
if r.Method == http.MethodOptions {
w.WriteHeader(http.StatusOK)
return
}
// Validate Tokens
accessToken, err := api.validateTokens(&w, r)
if err != nil {