Added auto-login for shuffle frontend during setup
This commit is contained in:
@@ -521,7 +521,7 @@ class AppBase:
|
|||||||
print("[INFO] Multiplier length: %d" % len(param_multiplier))
|
print("[INFO] Multiplier length: %d" % len(param_multiplier))
|
||||||
#tmp = ""
|
#tmp = ""
|
||||||
for subparams in param_multiplier:
|
for subparams in param_multiplier:
|
||||||
#print(f"SUBPARAMS IN MULTI: {subparams}")
|
print(f"SUBPARAMS IN MULTI: {subparams}")
|
||||||
try:
|
try:
|
||||||
#tmp = await func(**subparams)
|
#tmp = await func(**subparams)
|
||||||
|
|
||||||
@@ -530,6 +530,7 @@ class AppBase:
|
|||||||
tmp = await func(**subparams)
|
tmp = await func(**subparams)
|
||||||
break
|
break
|
||||||
except TypeError as e:
|
except TypeError as e:
|
||||||
|
print("BASE TYPEERROR: %s" % e)
|
||||||
errorstring = "%s" % e
|
errorstring = "%s" % e
|
||||||
if "got an unexpected keyword argument" in errorstring:
|
if "got an unexpected keyword argument" in errorstring:
|
||||||
fieldsplit = errorstring.split("'")
|
fieldsplit = errorstring.split("'")
|
||||||
@@ -2087,26 +2088,30 @@ class AppBase:
|
|||||||
newvalue = json.loads(action["parameters"][counter]["value"])
|
newvalue = json.loads(action["parameters"][counter]["value"])
|
||||||
deletekeys = []
|
deletekeys = []
|
||||||
for key, value in newvalue.items():
|
for key, value in newvalue.items():
|
||||||
print(key, value)
|
print("%s: %s" % (key, value))
|
||||||
if isinstance(value, str) and len(value) == 0:
|
if isinstance(value, str) and len(value) == 0:
|
||||||
deletekeys.append(key)
|
deletekeys.append(key)
|
||||||
continue
|
continue
|
||||||
|
|
||||||
if value == "${%s}" % key:
|
if value == "${%s}" % key:
|
||||||
print("Deleting %s because key = value")
|
print("Deleting %s because key = value" % key)
|
||||||
deletekeys.append(key)
|
deletekeys.append(key)
|
||||||
continue
|
continue
|
||||||
|
|
||||||
for deletekey in deletekeys:
|
for deletekey in deletekeys:
|
||||||
del newvalue[deletekey]
|
del newvalue[deletekey]
|
||||||
|
|
||||||
print("Post delete: %s" % newvalue)
|
#print("Post delete: %s" % newvalue)
|
||||||
for key, value in newvalue.items():
|
for key, value in newvalue.items():
|
||||||
|
if isinstance(value, bool):
|
||||||
|
continue
|
||||||
|
|
||||||
try:
|
try:
|
||||||
value = json.loads(value)
|
value = json.loads(value)
|
||||||
newvalue[key] = value
|
newvalue[key] = value
|
||||||
except json.decoder.JSONDecodeError as e:
|
except json.decoder.JSONDecodeError as e:
|
||||||
print("Inner overwrite issue: %s" % e)
|
print("Inner overwrite issue: %s" % e)
|
||||||
|
continue
|
||||||
|
|
||||||
action["parameters"][counter]["value"] = json.dumps(newvalue)
|
action["parameters"][counter]["value"] = json.dumps(newvalue)
|
||||||
|
|
||||||
|
|||||||
@@ -107,7 +107,7 @@ const App = (message, props) => {
|
|||||||
<div style={{ backgroundColor: "#1F2023", color: "rgba(255, 255, 255, 0.65)", minHeight: "100vh" }}>
|
<div style={{ backgroundColor: "#1F2023", color: "rgba(255, 255, 255, 0.65)", minHeight: "100vh" }}>
|
||||||
<ScrollToTop setCurpath={setCurpath} />
|
<ScrollToTop setCurpath={setCurpath} />
|
||||||
<Header checkLogin={checkLogin} cookies={cookies} removeCookie={removeCookie} isLoaded={isLoaded} globalUrl={globalUrl} setIsLoggedIn={setIsLoggedIn} isLoggedIn={isLoggedIn} userdata={userdata} {...props} />
|
<Header checkLogin={checkLogin} cookies={cookies} removeCookie={removeCookie} isLoaded={isLoaded} globalUrl={globalUrl} setIsLoggedIn={setIsLoggedIn} isLoggedIn={isLoggedIn} userdata={userdata} {...props} />
|
||||||
<Route exact path="/login" render={props => <LoginPage isLoggedIn={isLoggedIn} setIsLoggedIn={setIsLoggedIn} register={true} isLoaded={isLoaded} globalUrl={globalUrl} setCookie={setCookie} cookies={cookies} {...props} />} />
|
<Route exact path="/login" render={props => <LoginPage isLoggedIn={isLoggedIn} setIsLoggedIn={setIsLoggedIn} register={true} isLoaded={isLoaded} globalUrl={globalUrl} setCookie={setCookie} cookies={cookies} checkLogin={checkLogin} {...props} />} />
|
||||||
<Route exact path="/admin" render={props => <Admin userdata={userdata} isLoggedIn={isLoggedIn} setIsLoggedIn={setIsLoggedIn} register={true} isLoaded={isLoaded} globalUrl={globalUrl} setCookie={setCookie} cookies={cookies} {...props} />} />
|
<Route exact path="/admin" render={props => <Admin userdata={userdata} isLoggedIn={isLoggedIn} setIsLoggedIn={setIsLoggedIn} register={true} isLoaded={isLoaded} globalUrl={globalUrl} setCookie={setCookie} cookies={cookies} {...props} />} />
|
||||||
<Route exact path="/admin/:key" render={props => <Admin isLoggedIn={isLoggedIn} setIsLoggedIn={setIsLoggedIn} register={true} isLoaded={isLoaded} globalUrl={globalUrl} setCookie={setCookie} cookies={cookies} {...props} />} />
|
<Route exact path="/admin/:key" render={props => <Admin isLoggedIn={isLoggedIn} setIsLoggedIn={setIsLoggedIn} register={true} isLoaded={isLoaded} globalUrl={globalUrl} setCookie={setCookie} cookies={cookies} {...props} />} />
|
||||||
<Route exact path="/settings" render={props => <SettingsPage isLoaded={isLoaded} userdata={userdata} globalUrl={globalUrl} {...props} />} />
|
<Route exact path="/settings" render={props => <SettingsPage isLoaded={isLoaded} userdata={userdata} globalUrl={globalUrl} {...props} />} />
|
||||||
|
|||||||
@@ -1553,44 +1553,7 @@ const ParsedAction = (props) => {
|
|||||||
<Button color="primary" style={{}} fullWidth variant="contained" onClick={() => {
|
<Button color="primary" style={{}} fullWidth variant="contained" onClick={() => {
|
||||||
console.log(authenticationType)
|
console.log(authenticationType)
|
||||||
if (authenticationType.type === "oauth2" && authenticationType.redirect_uri !== undefined && authenticationType.redirect_uri !== null) {
|
if (authenticationType.type === "oauth2" && authenticationType.redirect_uri !== undefined && authenticationType.redirect_uri !== null) {
|
||||||
// FIXME: Sending client secret and senitive info like this may not be ok.
|
return null
|
||||||
const client_id = "dae24316-4bec-4832-b660-4cba6dc2477b"
|
|
||||||
const client_secret = "._Qu3EvYY-OW_D57uy79qwEo.32qD6.l0z"
|
|
||||||
|
|
||||||
const authentication_url = authenticationType.token_uri
|
|
||||||
|
|
||||||
const resources = "UserAuthenticationMethod.ReadWrite.All"
|
|
||||||
if (authenticationType.scope !== undefined && authenticationType.scope !== null) {
|
|
||||||
console.log("EDIT SCOPE!")
|
|
||||||
}
|
|
||||||
|
|
||||||
const redirectUri = `http://${window.location.host}/set_authentication`
|
|
||||||
const state = `workflow_id%3D${workflow.id}%26reference_action_id%3d${selectedAction.app_id}%26app_name%3d${selectedAction.app_name}%26app_id%3d${selectedAction.app_id}%26app_version%3d${selectedAction.app_version}%26authentication_url%3d${authentication_url}%26scope%3d${resources}%26client_id%3d${client_id}%26client_secret%3d${client_secret}`
|
|
||||||
|
|
||||||
const url = `${authenticationType.redirect_uri}?client_id=${client_id}&redirect_uri=${redirectUri}&response_type=code&scope=${resources}&state=${state}`
|
|
||||||
// &resource=https%3A%2F%2Fgraph.microsoft.com&
|
|
||||||
|
|
||||||
// Awful, but works for prototyping
|
|
||||||
var newwin = window.open(url, "", "width=200,height=100")
|
|
||||||
console.log(newwin)
|
|
||||||
setTimeout(() => {
|
|
||||||
console.log(newwin)
|
|
||||||
console.log("CLOSED", newwin.closed)
|
|
||||||
}, 1000)
|
|
||||||
setTimeout(() => {
|
|
||||||
console.log(newwin)
|
|
||||||
console.log("CLOSED", newwin.closed)
|
|
||||||
if (newwin.closed) {
|
|
||||||
getAppAuthentication(true)
|
|
||||||
setTimeout(() => {
|
|
||||||
console.log("APPAUTH: ", appAuthentication)
|
|
||||||
}, 1500)
|
|
||||||
}
|
|
||||||
}, 10000)
|
|
||||||
|
|
||||||
return
|
|
||||||
//do {
|
|
||||||
//} while (
|
|
||||||
}
|
}
|
||||||
|
|
||||||
setAuthenticationModalOpen(true)
|
setAuthenticationModalOpen(true)
|
||||||
|
|||||||
@@ -870,10 +870,10 @@ const Admin = (props) => {
|
|||||||
return response.json()
|
return response.json()
|
||||||
})
|
})
|
||||||
.then((responseJson) => {
|
.then((responseJson) => {
|
||||||
if (responseJson.files === undefined || responseJson.files === null) {
|
if (responseJson.files !== undefined && responseJson.files !== null) {
|
||||||
setFiles(responseJson)
|
|
||||||
} else {
|
|
||||||
setFiles(responseJson.files)
|
setFiles(responseJson.files)
|
||||||
|
} else {
|
||||||
|
setFiles([])
|
||||||
}
|
}
|
||||||
|
|
||||||
console.log("NAMESPACES: ", responseJson.namespaces)
|
console.log("NAMESPACES: ", responseJson.namespaces)
|
||||||
@@ -2237,7 +2237,7 @@ const Admin = (props) => {
|
|||||||
primary="File ID"
|
primary="File ID"
|
||||||
/>
|
/>
|
||||||
</ListItem>
|
</ListItem>
|
||||||
{files === undefined || files === null ? null : files.map((file, index) => {
|
{files === undefined || files === null || files.length === 0 ? null : files.map((file, index) => {
|
||||||
if (file.namespace === "") {
|
if (file.namespace === "") {
|
||||||
file.namespace = "default"
|
file.namespace = "default"
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,6 +1,7 @@
|
|||||||
/* eslint-disable react/no-multi-comp */
|
/* eslint-disable react/no-multi-comp */
|
||||||
import React, { useState } from 'react';
|
import React, { useState } from 'react';
|
||||||
import { makeStyles } from '@material-ui/styles';
|
import { makeStyles } from '@material-ui/styles';
|
||||||
|
import { useInterval } from 'react-powerhooks';
|
||||||
|
|
||||||
import {CircularProgress, TextField, Button, Paper, Typography} from '@material-ui/core'
|
import {CircularProgress, TextField, Button, Paper, Typography} from '@material-ui/core'
|
||||||
import { useTheme } from '@material-ui/core/styles';
|
import { useTheme } from '@material-ui/core/styles';
|
||||||
@@ -27,11 +28,12 @@ const useStyles = makeStyles({
|
|||||||
const LoginDialog = props => {
|
const LoginDialog = props => {
|
||||||
const theme = useTheme();
|
const theme = useTheme();
|
||||||
|
|
||||||
const { globalUrl, isLoaded, isLoggedIn, setIsLoggedIn, setCookie, register } = props;
|
const { globalUrl, isLoaded, isLoggedIn, setIsLoggedIn, setCookie, register, checkLogin } = 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);
|
||||||
const [loginLoading, setLoginLoading] = useState(false);
|
const [loginLoading, setLoginLoading] = useState(false);
|
||||||
|
const [loginViewLoading, setLoginViewLoading] = useState(false);
|
||||||
|
|
||||||
// Used to swap from login to register. True = login, false = register
|
// Used to swap from login to register. True = login, false = register
|
||||||
|
|
||||||
@@ -47,7 +49,6 @@ const LoginDialog = props => {
|
|||||||
window.location.pathname = "/workflows"
|
window.location.pathname = "/workflows"
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
const checkAdmin = () => {
|
const checkAdmin = () => {
|
||||||
const url = globalUrl + '/api/v1/checkusers';
|
const url = globalUrl + '/api/v1/checkusers';
|
||||||
fetch(url, {
|
fetch(url, {
|
||||||
@@ -58,6 +59,12 @@ const LoginDialog = props => {
|
|||||||
})
|
})
|
||||||
.then(response =>
|
.then(response =>
|
||||||
response.json().then(responseJson => {
|
response.json().then(responseJson => {
|
||||||
|
if (loginViewLoading) {
|
||||||
|
setLoginViewLoading(false)
|
||||||
|
checkLogin()
|
||||||
|
stop()
|
||||||
|
}
|
||||||
|
|
||||||
if (responseJson["success"] === false) {
|
if (responseJson["success"] === false) {
|
||||||
setLoginInfo(responseJson["reason"])
|
setLoginInfo(responseJson["reason"])
|
||||||
} else {
|
} else {
|
||||||
@@ -68,10 +75,21 @@ const LoginDialog = props => {
|
|||||||
}),
|
}),
|
||||||
)
|
)
|
||||||
.catch(error => {
|
.catch(error => {
|
||||||
setLoginInfo("Error logging in - please refresh in a minute ", error)
|
if (!loginViewLoading) {
|
||||||
|
setLoginViewLoading(true)
|
||||||
|
start()
|
||||||
|
}
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
|
const { start, stop } = useInterval({
|
||||||
|
duration: 3000,
|
||||||
|
startImmediate: false,
|
||||||
|
callback: () => {
|
||||||
|
checkAdmin()
|
||||||
|
}
|
||||||
|
})
|
||||||
|
|
||||||
if (firstRequest) {
|
if (firstRequest) {
|
||||||
setFirstRequest(false)
|
setFirstRequest(false)
|
||||||
checkAdmin()
|
checkAdmin()
|
||||||
@@ -178,6 +196,39 @@ const LoginDialog = props => {
|
|||||||
<div style={{position: "absolute", top: -imgsize/2-10, left: 250-imgsize/2, height: imgsize, width: imgsize, }}>
|
<div style={{position: "absolute", top: -imgsize/2-10, left: 250-imgsize/2, height: imgsize, width: imgsize, }}>
|
||||||
<img src="images/Shuffle_logo.png" style={{height: imgsize+10, width: imgsize+10, border: "2px solid rgba(255,255,255,0.6)", borderRadius: imgsize,}}/>
|
<img src="images/Shuffle_logo.png" style={{height: imgsize+10, width: imgsize+10, border: "2px solid rgba(255,255,255,0.6)", borderRadius: imgsize,}}/>
|
||||||
</div>
|
</div>
|
||||||
|
{loginViewLoading ?
|
||||||
|
<div style={{textAlign: "center", marginTop: 50, }}>
|
||||||
|
<Typography variant="body2" style={{marginBottom: 20, color: "white",}}>
|
||||||
|
Waiting for Shuffle the database to become available. This may take up to a minute.
|
||||||
|
</Typography>
|
||||||
|
<CircularProgress color="secondary" style={{color: "white",}} />
|
||||||
|
|
||||||
|
|
||||||
|
<Paper style={{
|
||||||
|
paddingLeft: "30px",
|
||||||
|
paddingRight: "30px",
|
||||||
|
paddingBottom: "30px",
|
||||||
|
paddingTop: "30px",
|
||||||
|
position: "relative",
|
||||||
|
backgroundColor: theme.palette.inputColor,
|
||||||
|
textAlign: "left",
|
||||||
|
marginTop: 15,
|
||||||
|
}}>
|
||||||
|
<Typography variant="body2" style={{marginBottom: 20, color: "white",}}>
|
||||||
|
<b>Make sure Shuffle is <a href="https://github.com/frikky/Shuffle/blob/master/.github/install-guide.md" style={{textDecoration: "none", color: "#f86a3e"}}>installed correctly</a></b>
|
||||||
|
</Typography>
|
||||||
|
<Typography variant="body2" style={{marginBottom: 20, color: "white",}}>
|
||||||
|
<b>1.</b> Make sure shuffle-database folder has correct access: <br/><br/>
|
||||||
|
sudo chown 1000:1000 -R shuffle-database
|
||||||
|
</Typography>
|
||||||
|
|
||||||
|
<Typography variant="body2" style={{marginBottom: 20, color: "white",}}>
|
||||||
|
<b>2</b>. Ensure vm.max_map_count is set:<br/><br/>
|
||||||
|
sudo sysctl -w vm.max_map_count=262144
|
||||||
|
</Typography>
|
||||||
|
</Paper>
|
||||||
|
</div>
|
||||||
|
:
|
||||||
<form onSubmit={onSubmit} style={{ margin: "15px 15px 15px 15px", color: "white", }}>
|
<form onSubmit={onSubmit} style={{ margin: "15px 15px 15px 15px", color: "white", }}>
|
||||||
<h2>{formtitle}</h2>
|
<h2>{formtitle}</h2>
|
||||||
Username
|
Username
|
||||||
@@ -241,6 +292,7 @@ const LoginDialog = props => {
|
|||||||
{loginInfo}
|
{loginInfo}
|
||||||
</div>
|
</div>
|
||||||
</form>
|
</form>
|
||||||
|
}
|
||||||
</Paper>
|
</Paper>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user