Added a bunch of CORS related fixes for new shell dev

This commit is contained in:
Frikky
2022-01-21 19:30:40 +00:00
committed by GitHub
parent d2c9cbec7d
commit 9ce92d6e1f
8 changed files with 87 additions and 54 deletions
+1
View File
@@ -2,6 +2,7 @@
ORG_ID=Shuffle ORG_ID=Shuffle
ENVIRONMENT_NAME=Shuffle ENVIRONMENT_NAME=Shuffle
# Remote github config for first load # Remote github config for first load
SHUFFLE_DOWNLOAD_WORKFLOW_LOCATION= SHUFFLE_DOWNLOAD_WORKFLOW_LOCATION=
SHUFFLE_DOWNLOAD_WORKFLOW_USERNAME= SHUFFLE_DOWNLOAD_WORKFLOW_USERNAME=
+4 -3
View File
@@ -14,6 +14,7 @@ import (
"encoding/json" "encoding/json"
"errors" "errors"
"fmt" "fmt"
//"github.com/docker/docker" //"github.com/docker/docker"
"github.com/docker/docker/api/types" "github.com/docker/docker/api/types"
//"github.com/docker/docker/api/types/container" //"github.com/docker/docker/api/types/container"
@@ -417,7 +418,7 @@ func stopWebhook(image string, identifier string) error {
// Starts a new webhook // Starts a new webhook
func handleStopHookDocker(resp http.ResponseWriter, request *http.Request) { func handleStopHookDocker(resp http.ResponseWriter, request *http.Request) {
cors := handleCors(resp, request) cors := shuffle.HandleCors(resp, request)
if cors { if cors {
return return
} }
@@ -502,7 +503,7 @@ var webhook = `{
// Starts a new webhook // Starts a new webhook
func handleDeleteHookDocker(resp http.ResponseWriter, request *http.Request) { func handleDeleteHookDocker(resp http.ResponseWriter, request *http.Request) {
ctx := context.Background() ctx := context.Background()
cors := handleCors(resp, request) cors := shuffle.HandleCors(resp, request)
if cors { if cors {
return return
} }
@@ -619,7 +620,7 @@ func hookTest() {
//https://stackoverflow.com/questions/23935141/how-to-copy-docker-images-from-one-host-to-another-without-using-a-repository //https://stackoverflow.com/questions/23935141/how-to-copy-docker-images-from-one-host-to-another-without-using-a-repository
func getDockerImage(resp http.ResponseWriter, request *http.Request) { func getDockerImage(resp http.ResponseWriter, request *http.Request) {
cors := handleCors(resp, request) cors := shuffle.HandleCors(resp, request)
if cors { if cors {
return return
} }
+11 -11
View File
@@ -1,34 +1,34 @@
module main module main
go 1.15 go 1.16
replace github.com/shuffle/shuffle-shared => ../../../../git/shuffle-shared replace github.com/shuffle/shuffle-shared => ../../../shuffle-shared
//replace github.com/frikky/kin-openapi => ../../../../git/kin-openapi //replace github.com/frikky/kin-openapi => ../../../../git/kin-openapi
//replace github.com/frikky/go-elasticsearch => ../../../../git/go-elasticsearch //replace github.com/frikky/go-elasticsearch => ../../../../git/go-elasticsearch
require ( require (
cloud.google.com/go/datastore v1.6.0 cloud.google.com/go/datastore v1.6.0
cloud.google.com/go/pubsub v1.17.0 cloud.google.com/go/iam v0.1.1 // indirect
cloud.google.com/go/pubsub v1.17.1
cloud.google.com/go/storage v1.18.2 cloud.google.com/go/storage v1.18.2
github.com/basgys/goxml2json v1.1.0 github.com/basgys/goxml2json v1.1.0
github.com/carlescere/scheduler v0.0.0-20170109141437-ee74d2f83d82 github.com/carlescere/scheduler v0.0.0-20170109141437-ee74d2f83d82
github.com/docker/docker v20.10.9+incompatible github.com/docker/docker v20.10.12+incompatible
github.com/frikky/kin-openapi v0.41.0 github.com/frikky/kin-openapi v0.41.0
github.com/fsouza/go-dockerclient v1.7.4 github.com/fsouza/go-dockerclient v1.7.7
github.com/ghodss/yaml v1.0.0 github.com/ghodss/yaml v1.0.0
github.com/go-git/go-billy/v5 v5.3.1 github.com/go-git/go-billy/v5 v5.3.1
github.com/go-git/go-git/v5 v5.4.2 github.com/go-git/go-git/v5 v5.4.2
github.com/gorilla/mux v1.8.0 github.com/gorilla/mux v1.8.0
github.com/h2non/filetype v1.1.1 github.com/h2non/filetype v1.1.3
github.com/satori/go.uuid v1.2.0 github.com/satori/go.uuid v1.2.0
github.com/shuffle/shuffle-shared v0.1.79 github.com/shuffle/shuffle-shared v0.1.84
github.com/skip2/go-qrcode v0.0.0-20200617195104-da1b6568686e // indirect
go4.org v0.0.0-20201209231011-d4a079459e60 // indirect go4.org v0.0.0-20201209231011-d4a079459e60 // indirect
golang.org/x/crypto v0.0.0-20210921155107-089bfa567519 golang.org/x/crypto v0.0.0-20220112180741-5e0467b6c7ce
google.golang.org/api v0.58.0 google.golang.org/api v0.65.0
google.golang.org/appengine v1.6.7 google.golang.org/appengine v1.6.7
google.golang.org/grpc v1.41.0 google.golang.org/grpc v1.43.0
gopkg.in/src-d/go-git.v4 v4.13.1 gopkg.in/src-d/go-git.v4 v4.13.1
gopkg.in/yaml.v3 v3.0.0-20210107192922-496545a6307b gopkg.in/yaml.v3 v3.0.0-20210107192922-496545a6307b
) )
+37 -20
View File
@@ -1,12 +1,14 @@
package main package main
import ( import (
uuid "github.com/satori/go.uuid"
"github.com/shuffle/shuffle-shared" "github.com/shuffle/shuffle-shared"
"bufio" "bufio"
"bytes" "bytes"
"context" "context"
"crypto/md5" "crypto/md5"
//"crypto/tls" //"crypto/tls"
//"crypto/x509" //"crypto/x509"
"encoding/hex" "encoding/hex"
@@ -21,6 +23,7 @@ import (
"os" "os"
"os/exec" "os/exec"
"path/filepath" "path/filepath"
//"regexp" //"regexp"
"strings" "strings"
"time" "time"
@@ -49,12 +52,12 @@ import (
"github.com/go-git/go-git/v5" "github.com/go-git/go-git/v5"
"github.com/go-git/go-git/v5/plumbing" "github.com/go-git/go-git/v5/plumbing"
"github.com/go-git/go-git/v5/storage/memory" "github.com/go-git/go-git/v5/storage/memory"
//githttp "gopkg.in/src-d/go-git.v4/plumbing/transport/http" //githttp "gopkg.in/src-d/go-git.v4/plumbing/transport/http"
// Random // Random
xj "github.com/basgys/goxml2json" xj "github.com/basgys/goxml2json"
newscheduler "github.com/carlescere/scheduler" newscheduler "github.com/carlescere/scheduler"
"github.com/satori/go.uuid"
"golang.org/x/crypto/bcrypt" "golang.org/x/crypto/bcrypt"
"gopkg.in/yaml.v3" "gopkg.in/yaml.v3"
@@ -706,7 +709,7 @@ func createNewUser(username, password, role, apikey string, org shuffle.OrgMini)
} }
func handleRegister(resp http.ResponseWriter, request *http.Request) { func handleRegister(resp http.ResponseWriter, request *http.Request) {
cors := handleCors(resp, request) cors := shuffle.HandleCors(resp, request)
if cors { if cors {
return return
} }
@@ -835,7 +838,7 @@ func handleCookie(request *http.Request) bool {
} }
func handleInfo(resp http.ResponseWriter, request *http.Request) { func handleInfo(resp http.ResponseWriter, request *http.Request) {
cors := handleCors(resp, request) cors := shuffle.HandleCors(resp, request)
if cors { if cors {
return return
} }
@@ -1118,7 +1121,7 @@ func increaseStatisticsField(ctx context.Context, fieldname, id string, amount i
// FIXME - forward this to emails or whatever CRM system in use // FIXME - forward this to emails or whatever CRM system in use
func handleContact(resp http.ResponseWriter, request *http.Request) { func handleContact(resp http.ResponseWriter, request *http.Request) {
cors := handleCors(resp, request) cors := shuffle.HandleCors(resp, request)
if cors { if cors {
return return
} }
@@ -1164,7 +1167,8 @@ func handleContact(resp http.ResponseWriter, request *http.Request) {
} }
func checkAdminLogin(resp http.ResponseWriter, request *http.Request) { func checkAdminLogin(resp http.ResponseWriter, request *http.Request) {
cors := handleCors(resp, request) log.Printf("In admin login request?")
cors := shuffle.HandleCors(resp, request)
if cors { if cors {
return return
} }
@@ -1193,7 +1197,7 @@ func checkAdminLogin(resp http.ResponseWriter, request *http.Request) {
} }
func handleLogin(resp http.ResponseWriter, request *http.Request) { func handleLogin(resp http.ResponseWriter, request *http.Request) {
cors := handleCors(resp, request) cors := shuffle.HandleCors(resp, request)
if cors { if cors {
return return
} }
@@ -1418,8 +1422,12 @@ func fixUserOrg(ctx context.Context, user *shuffle.User) *shuffle.User {
} }
// Used for testing only. Shouldn't impact production. // Used for testing only. Shouldn't impact production.
func handleCors(resp http.ResponseWriter, request *http.Request) bool { /*
allowedOrigins := "http://localhost:3000" func shuffle.HandleCors(resp http.ResponseWriter, request *http.Request) bool {
// Used for Codespace dev
allowedOrigins := "https://frikky-shuffle-5gvr4xx62w64-3000.githubpreview.dev"
//origin := request.Header["Origin"]
//log.Printf("Origin: %s", origin)
//allowedOrigins := "http://localhost:3002" //allowedOrigins := "http://localhost:3002"
resp.Header().Set("Vary", "Origin") resp.Header().Set("Vary", "Origin")
@@ -1436,6 +1444,7 @@ func handleCors(resp http.ResponseWriter, request *http.Request) bool {
return false return false
} }
*/
func parseWorkflowParameters(resp http.ResponseWriter, request *http.Request) (map[string]interface{}, error) { func parseWorkflowParameters(resp http.ResponseWriter, request *http.Request) (map[string]interface{}, error) {
body, err := ioutil.ReadAll(request.Body) body, err := ioutil.ReadAll(request.Body)
@@ -1580,7 +1589,7 @@ func SearchNested(obj interface{}, key string) (interface{}, bool) {
} }
func handleSetHook(resp http.ResponseWriter, request *http.Request) { func handleSetHook(resp http.ResponseWriter, request *http.Request) {
cors := handleCors(resp, request) cors := shuffle.HandleCors(resp, request)
if cors { if cors {
return return
} }
@@ -1768,7 +1777,7 @@ func verifyHook(hook shuffle.Hook) (bool, string) {
} }
func setSpecificSchedule(resp http.ResponseWriter, request *http.Request) { func setSpecificSchedule(resp http.ResponseWriter, request *http.Request) {
cors := handleCors(resp, request) cors := shuffle.HandleCors(resp, request)
if cors { if cors {
return return
} }
@@ -1828,7 +1837,7 @@ func setSpecificSchedule(resp http.ResponseWriter, request *http.Request) {
} }
func getSpecificWebhook(resp http.ResponseWriter, request *http.Request) { func getSpecificWebhook(resp http.ResponseWriter, request *http.Request) {
cors := handleCors(resp, request) cors := shuffle.HandleCors(resp, request)
if cors { if cors {
return return
} }
@@ -1880,7 +1889,7 @@ func getSpecificWebhook(resp http.ResponseWriter, request *http.Request) {
// Starts a new webhook // Starts a new webhook
func handleDeleteSchedule(resp http.ResponseWriter, request *http.Request) { func handleDeleteSchedule(resp http.ResponseWriter, request *http.Request) {
cors := handleCors(resp, request) cors := shuffle.HandleCors(resp, request)
if cors { if cors {
return return
} }
@@ -1935,7 +1944,7 @@ func handleDeleteSchedule(resp http.ResponseWriter, request *http.Request) {
// Starts a new webhook // Starts a new webhook
func handleNewSchedule(resp http.ResponseWriter, request *http.Request) { func handleNewSchedule(resp http.ResponseWriter, request *http.Request) {
cors := handleCors(resp, request) cors := shuffle.HandleCors(resp, request)
if cors { if cors {
return return
} }
@@ -2229,7 +2238,7 @@ func getSpecificSchedule(resp http.ResponseWriter, request *http.Request) {
return return
} }
cors := handleCors(resp, request) cors := shuffle.HandleCors(resp, request)
if cors { if cors {
return return
} }
@@ -2295,7 +2304,7 @@ func loadYaml(fileLocation string) (ApiYaml, error) {
// This should ALWAYS come from an OUTPUT // This should ALWAYS come from an OUTPUT
func executeSchedule(resp http.ResponseWriter, request *http.Request) { func executeSchedule(resp http.ResponseWriter, request *http.Request) {
cors := handleCors(resp, request) cors := shuffle.HandleCors(resp, request)
if cors { if cors {
return return
} }
@@ -2788,7 +2797,7 @@ type Result struct {
// r.HandleFunc("/api/v1/docs/{key}", getDocs).Methods("GET", "OPTIONS") // r.HandleFunc("/api/v1/docs/{key}", getDocs).Methods("GET", "OPTIONS")
func getOpenapi(resp http.ResponseWriter, request *http.Request) { func getOpenapi(resp http.ResponseWriter, request *http.Request) {
cors := handleCors(resp, request) cors := shuffle.HandleCors(resp, request)
if cors { if cors {
return return
} }
@@ -3254,7 +3263,7 @@ func buildSwaggerApp(resp http.ResponseWriter, body []byte, user shuffle.User) {
// Creates an app from the app builder // Creates an app from the app builder
func verifySwagger(resp http.ResponseWriter, request *http.Request) { func verifySwagger(resp http.ResponseWriter, request *http.Request) {
cors := handleCors(resp, request) cors := shuffle.HandleCors(resp, request)
if cors { if cors {
return return
} }
@@ -4999,7 +5008,7 @@ func handleStopCloudSync(syncUrl string, org shuffle.Org) (*shuffle.Org, error)
This is here to both enable and disable cloud sync features for an organization This is here to both enable and disable cloud sync features for an organization
*/ */
func handleCloudSetup(resp http.ResponseWriter, request *http.Request) { func handleCloudSetup(resp http.ResponseWriter, request *http.Request) {
cors := handleCors(resp, request) cors := shuffle.HandleCors(resp, request)
if cors { if cors {
return return
} }
@@ -5687,10 +5696,15 @@ func initHandlers() {
dbclient, err = datastore.NewClient(ctx, gceProject, option.WithGRPCDialOption(grpc.WithNoProxy())) dbclient, err = datastore.NewClient(ctx, gceProject, option.WithGRPCDialOption(grpc.WithNoProxy()))
if err != nil { if err != nil {
if elasticConfig == "" { if elasticConfig == "" {
log.Fatalf("[ERROR] Database client error during init: %s. Env: SHUFFLE_ELASTIC=false", err) log.Printf("[ERROR] Database client error during init: %s. Env: SHUFFLE_ELASTIC=false", err)
} else { } else {
log.Printf("[DEBUG] Database client error during init: %s. Here for backwards compatibility: not critical.", err) if !strings.Contains(fmt.Sprintf("%s", err), "find default credentials") {
log.Printf("[DEBUG] Database client error info during init: %s. Here for backwards compatibility: not critical.", err)
} }
dbclient = &datastore.Client{}
}
} else {
//log.Printf("Database client initiated: %s", dbclient)
} }
for { for {
@@ -5887,6 +5901,9 @@ func initHandlers() {
r.HandleFunc("/api/v1/notifications/clear", shuffle.HandleClearNotifications).Methods("GET", "OPTIONS") r.HandleFunc("/api/v1/notifications/clear", shuffle.HandleClearNotifications).Methods("GET", "OPTIONS")
r.HandleFunc("/api/v1/notifications/{notificationId}/markasread", shuffle.HandleMarkAsRead).Methods("GET", "OPTIONS") r.HandleFunc("/api/v1/notifications/{notificationId}/markasread", shuffle.HandleMarkAsRead).Methods("GET", "OPTIONS")
//r.HandleFunc("/api/v1/notifications/{notificationId}/markasread", shuffle.HandleMarkAsRead).Methods("GET", "OPTIONS") //r.HandleFunc("/api/v1/notifications/{notificationId}/markasread", shuffle.HandleMarkAsRead).Methods("GET", "OPTIONS")
r.HandleFunc("/api/v1/users/notifications", shuffle.HandleGetNotifications).Methods("GET", "OPTIONS")
r.HandleFunc("/api/v1/users/notifications/clear", shuffle.HandleClearNotifications).Methods("GET", "OPTIONS")
r.HandleFunc("/api/v1/users/notifications/{notificationId}/markasread", shuffle.HandleMarkAsRead).Methods("GET", "OPTIONS")
http.Handle("/", r) http.Handle("/", r)
} }
+17 -15
View File
@@ -21,6 +21,7 @@ import (
"github.com/docker/docker/api/types" "github.com/docker/docker/api/types"
dockerclient "github.com/docker/docker/client" dockerclient "github.com/docker/docker/client"
//gyaml "github.com/ghodss/yaml" //gyaml "github.com/ghodss/yaml"
"github.com/h2non/filetype" "github.com/h2non/filetype"
@@ -34,6 +35,7 @@ import (
"github.com/go-git/go-git/v5/plumbing" "github.com/go-git/go-git/v5/plumbing"
"github.com/go-git/go-git/v5/storage/memory" "github.com/go-git/go-git/v5/storage/memory"
http2 "gopkg.in/src-d/go-git.v4/plumbing/transport/http" http2 "gopkg.in/src-d/go-git.v4/plumbing/transport/http"
//"github.com/gorilla/websocket" //"github.com/gorilla/websocket"
//"google.golang.org/appengine" //"google.golang.org/appengine"
//"google.golang.org/appengine/memcache" //"google.golang.org/appengine/memcache"
@@ -142,7 +144,7 @@ func createSchedule(ctx context.Context, scheduleId, workflowId, name, startNode
} }
func handleGetWorkflowqueueConfirm(resp http.ResponseWriter, request *http.Request) { func handleGetWorkflowqueueConfirm(resp http.ResponseWriter, request *http.Request) {
cors := handleCors(resp, request) cors := shuffle.HandleCors(resp, request)
if cors { if cors {
return return
} }
@@ -243,7 +245,7 @@ func handleGetWorkflowqueueConfirm(resp http.ResponseWriter, request *http.Reque
// FIXME: Authenticate this one? Can org ID be auth enough? // FIXME: Authenticate this one? Can org ID be auth enough?
// (especially since we have a default: shuffle) // (especially since we have a default: shuffle)
func handleGetWorkflowqueue(resp http.ResponseWriter, request *http.Request) { func handleGetWorkflowqueue(resp http.ResponseWriter, request *http.Request) {
cors := handleCors(resp, request) cors := shuffle.HandleCors(resp, request)
if cors { if cors {
return return
} }
@@ -335,7 +337,7 @@ func handleGetWorkflowqueue(resp http.ResponseWriter, request *http.Request) {
} }
func handleGetStreamResults(resp http.ResponseWriter, request *http.Request) { func handleGetStreamResults(resp http.ResponseWriter, request *http.Request) {
cors := handleCors(resp, request) cors := shuffle.HandleCors(resp, request)
if cors { if cors {
return return
} }
@@ -393,7 +395,7 @@ func handleGetStreamResults(resp http.ResponseWriter, request *http.Request) {
} }
func handleWorkflowQueue(resp http.ResponseWriter, request *http.Request) { func handleWorkflowQueue(resp http.ResponseWriter, request *http.Request) {
cors := handleCors(resp, request) cors := shuffle.HandleCors(resp, request)
if cors { if cors {
return return
} }
@@ -666,7 +668,7 @@ func handleExecutionStatistics(execution shuffle.WorkflowExecution) {
} }
func deleteWorkflow(resp http.ResponseWriter, request *http.Request) { func deleteWorkflow(resp http.ResponseWriter, request *http.Request) {
cors := handleCors(resp, request) cors := shuffle.HandleCors(resp, request)
if cors { if cors {
return return
} }
@@ -1034,7 +1036,7 @@ func cloudExecuteAction(execution shuffle.WorkflowExecution) error {
} }
func executeWorkflow(resp http.ResponseWriter, request *http.Request) { func executeWorkflow(resp http.ResponseWriter, request *http.Request) {
cors := handleCors(resp, request) cors := shuffle.HandleCors(resp, request)
if cors { if cors {
return return
} }
@@ -1131,7 +1133,7 @@ func executeWorkflow(resp http.ResponseWriter, request *http.Request) {
} }
func stopSchedule(resp http.ResponseWriter, request *http.Request) { func stopSchedule(resp http.ResponseWriter, request *http.Request) {
cors := handleCors(resp, request) cors := shuffle.HandleCors(resp, request)
if cors { if cors {
return return
} }
@@ -1281,7 +1283,7 @@ func stopSchedule(resp http.ResponseWriter, request *http.Request) {
} }
func stopScheduleGCP(resp http.ResponseWriter, request *http.Request) { func stopScheduleGCP(resp http.ResponseWriter, request *http.Request) {
cors := handleCors(resp, request) cors := shuffle.HandleCors(resp, request)
if cors { if cors {
return return
} }
@@ -1390,7 +1392,7 @@ func deleteSchedule(ctx context.Context, id string) error {
} }
func scheduleWorkflow(resp http.ResponseWriter, request *http.Request) { func scheduleWorkflow(resp http.ResponseWriter, request *http.Request) {
cors := handleCors(resp, request) cors := shuffle.HandleCors(resp, request)
if cors { if cors {
return return
} }
@@ -1641,7 +1643,7 @@ func setExampleresult(ctx context.Context, result shuffle.AppExecutionExample) e
} }
func getWorkflowApps(resp http.ResponseWriter, request *http.Request) { func getWorkflowApps(resp http.ResponseWriter, request *http.Request) {
cors := handleCors(resp, request) cors := shuffle.HandleCors(resp, request)
if cors { if cors {
return return
} }
@@ -1714,7 +1716,7 @@ func handleGetfile(resp http.ResponseWriter, request *http.Request) ([]byte, err
// Basically a search for apps that aren't activated yet // Basically a search for apps that aren't activated yet
func getSpecificApps(resp http.ResponseWriter, request *http.Request) { func getSpecificApps(resp http.ResponseWriter, request *http.Request) {
cors := handleCors(resp, request) cors := shuffle.HandleCors(resp, request)
if cors { if cors {
return return
} }
@@ -1789,7 +1791,7 @@ func getSpecificApps(resp http.ResponseWriter, request *http.Request) {
} }
func validateAppInput(resp http.ResponseWriter, request *http.Request) { func validateAppInput(resp http.ResponseWriter, request *http.Request) {
cors := handleCors(resp, request) cors := shuffle.HandleCors(resp, request)
if cors { if cors {
return return
} }
@@ -1910,7 +1912,7 @@ func loadGithubWorkflows(url, username, password, userId, branch, orgId string)
} }
func loadSpecificWorkflows(resp http.ResponseWriter, request *http.Request) { func loadSpecificWorkflows(resp http.ResponseWriter, request *http.Request) {
cors := handleCors(resp, request) cors := shuffle.HandleCors(resp, request)
if cors { if cors {
return return
} }
@@ -1972,7 +1974,7 @@ func loadSpecificWorkflows(resp http.ResponseWriter, request *http.Request) {
} }
func handleAppHotloadRequest(resp http.ResponseWriter, request *http.Request) { func handleAppHotloadRequest(resp http.ResponseWriter, request *http.Request) {
cors := handleCors(resp, request) cors := shuffle.HandleCors(resp, request)
if cors { if cors {
return return
} }
@@ -2290,7 +2292,7 @@ func iterateWorkflowGithubFolders(fs billy.Filesystem, dir []os.FileInfo, extra
} }
func setNewWorkflowApp(resp http.ResponseWriter, request *http.Request) { func setNewWorkflowApp(resp http.ResponseWriter, request *http.Request) {
cors := handleCors(resp, request) cors := shuffle.HandleCors(resp, request)
if cors { if cors {
return return
} }
+10 -3
View File
@@ -49,6 +49,12 @@ if (window.location.port === "3000") {
//globalUrl = "http://localhost:5002" //globalUrl = "http://localhost:5002"
} }
if (globalUrl.includes("githubpreview.dev")) {
//globalUrl = globalUrl.replace("3000", "5001")
globalUrl = "https://frikky-shuffle-5gvr4xx62w64-5001.githubpreview.dev"
}
console.log("global: ", globalUrl)
const App = (message, props) => { const App = (message, props) => {
const [userdata, setUserData] = useState({}); const [userdata, setUserData] = useState({});
@@ -70,7 +76,7 @@ const App = (message, props) => {
checkLogin(); checkLogin();
setDataset(true); setDataset(true);
} }
}); }, []);
if ( if (
isLoaded && isLoaded &&
@@ -84,11 +90,12 @@ const App = (message, props) => {
} }
const getUserNotifications = () => { const getUserNotifications = () => {
fetch(`${globalUrl}/api/v1/notifications`, { fetch(`${globalUrl}/api/v1/users/notifications`, {
credentials: "include", credentials: "include",
headers: { headers: {
"Content-Type": "application/json", "Content-Type": "application/json",
}, },
cors: "cors",
}) })
.then((response) => response.json()) .then((response) => response.json())
.then((responseJson) => { .then((responseJson) => {
@@ -109,7 +116,7 @@ const App = (message, props) => {
const checkLogin = () => { const checkLogin = () => {
var baseurl = globalUrl; var baseurl = globalUrl;
fetch(baseurl + "/api/v1/users/getinfo", { fetch(`${globalUrl}/api/v1/getinfo`, {
credentials: "include", credentials: "include",
headers: { headers: {
"Content-Type": "application/json", "Content-Type": "application/json",
+5 -1
View File
@@ -515,7 +515,11 @@ const Apps = (props) => {
valid = "false"; valid = "false";
} }
if (data.actions === null || data.actions.length === 0) { if (data.actions === undefined || data.actions === null) {
data.actions = []
}
if (data === undefined || data.actions === undefined || data.actions === null || data.actions.length === 0) {
valid = "false"; valid = "false";
} }
+2 -1
View File
@@ -44,6 +44,7 @@ const LoginDialog = (props) => {
register, register,
checkLogin, checkLogin,
} = props; } = props;
const [username, setUsername] = useState(""); const [username, setUsername] = useState("");
const [password, setPassword] = useState(""); const [password, setPassword] = useState("");
const [firstRequest, setFirstRequest] = useState(true); const [firstRequest, setFirstRequest] = useState(true);
@@ -143,7 +144,7 @@ const LoginDialog = (props) => {
var baseurl = globalUrl; var baseurl = globalUrl;
if (register) { if (register) {
var url = baseurl + "/api/v1/users/login"; var url = baseurl + "/api/v1/login";
fetch(url, { fetch(url, {
mode: "cors", mode: "cors",
method: "POST", method: "POST",