Skip to content

Commit

Permalink
🐛 Fix
Browse files Browse the repository at this point in the history
  • Loading branch information
samdenty committed Mar 25, 2018
1 parent 284fb67 commit 0b61d4a
Show file tree
Hide file tree
Showing 3 changed files with 44 additions and 16 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ const styles = (theme) => ({
color: '#fff'
},
copyIcon: {
height: 20,
height: 20
},
copyButton: {
marginRight: 10
Expand All @@ -78,7 +78,7 @@ const styles = (theme) => ({
},
codeLight: {
backgroundColor: 'rgba(0, 0, 0, 0.15)'
},
}
})

class InstallationCode extends React.Component {
Expand Down Expand Up @@ -131,7 +131,9 @@ class InstallationCode extends React.Component {
avatar={<PayloadIcon className={classes.icon} />}
className={settings.dark ? classes.headerDark : classes.header}
action={
<IconButton onClick={() => this.copy(code)} className={classes.copyButton}>
<IconButton
onClick={() => this.copy(code)}
className={classes.copyButton}>
{this.state.copied ? (
<CheckIcon className={classes.copyIcon} />
) : (
Expand Down
25 changes: 22 additions & 3 deletions src/inject/Websockets.ts
Original file line number Diff line number Diff line change
Expand Up @@ -158,10 +158,16 @@ class Session {
*/
if (/^core|auth$/.test(topic)) {
if (this.session.version === 0) {
/**
* Payload version 0
*/
transport = JSON.stringify({
d: data
})
} else {
/**
* Payload version 1
*/
transport = data
}
}
Expand Down Expand Up @@ -365,7 +371,6 @@ class Session {
}
}


/**
* Deliver the Injectify Core
*/
Expand All @@ -374,12 +379,26 @@ class Session {
* Client has the current version of the Core cached
*/
variables.__server.cached = true
this.send('core', Transforms.cache(variables, this.session.debug, this.session.project.config.autoexecute))
this.send(
'core',
Transforms.cache(
variables,
this.session.debug,
this.session.project.config.autoexecute
)
)
} else {
/**
* Core loader
*/
this.send('core', Transforms.core(this.core, variables, this.session.project.config.autoexecute))
this.send(
'core',
Transforms.core(
this.core,
variables,
this.session.project.config.autoexecute
)
)
}
})
}
Expand Down
27 changes: 17 additions & 10 deletions src/main.ts
Original file line number Diff line number Diff line change
Expand Up @@ -315,6 +315,7 @@ MongoClient.connect(config.mongodb, (err, client) => {
admins: [],
readonly: []
},
console: {},
config: {
autoexecute: `injectify.module('passwords')`,
filter: {
Expand Down Expand Up @@ -1257,22 +1258,28 @@ MongoClient.connect(config.mongodb, (err, client) => {
}
}
if (command === 'autoexecute') {
if (data.project && typeof data.code === 'string' && thisProject.myPermissionLevel < 3) {
if (
data.project &&
typeof data.code === 'string' &&
thisProject.myPermissionLevel < 3
) {
Update(data.project, {
$set: {
'config.autoexecute': data.code
}
}).then(() => {
socket.emit('notify', {
title: 'Updated',
message: 'Successfully updated code'
})
.then(() => {
socket.emit('notify', {
title: 'Updated',
message: 'Successfully updated code'
})
})
}).catch(() => {
socket.emit('err', {
title: 'Error',
message: 'Failed to update code'
.catch(() => {
socket.emit('err', {
title: 'Error',
message: 'Failed to update code'
})
})
})
} else {
socket.emit('err', {
title: 'Error',
Expand Down

0 comments on commit 0b61d4a

Please sign in to comment.