@@ -6,10 +6,6 @@ import config from 'config'; | |||||
import { util } from '../_helpers'; | import { util } from '../_helpers'; | ||||
export const appService = { | export const appService = { | ||||
getMitmStatus, | |||||
enableMitm, | |||||
disableMitm, | |||||
getAppsByUserId, | getAppsByUserId, | ||||
getAppByUserId, | getAppByUserId, | ||||
getAppAssetByUserId, | getAppAssetByUserId, | ||||
@@ -30,19 +26,6 @@ export const appService = { | |||||
takeConfigAppAction | takeConfigAppAction | ||||
}; | }; | ||||
// MITM | |||||
function getMitmStatus(userId, messages, errors) { | |||||
return fetch(`${config.apiUrl}/users/${userId}/mitm`, util.getWithAuth()).then(util.handleCrudResponse(messages, errors)); | |||||
} | |||||
function enableMitm(userId, messages, errors) { | |||||
return fetch(`${config.apiUrl}/users/${userId}/mitm/enable`, util.postWithAuth()).then(util.handleCrudResponse(messages, errors)); | |||||
} | |||||
function disableMitm(userId, messages, errors) { | |||||
return fetch(`${config.apiUrl}/users/${userId}/mitm/disable`, util.postWithAuth()).then(util.handleCrudResponse(messages, errors)); | |||||
} | |||||
// Apps | // Apps | ||||
function getAppsByUserId(userId, messages, errors) { | function getAppsByUserId(userId, messages, errors) { | ||||
return fetch(`${config.apiUrl}/users/${userId}/apps`, util.getWithAuth()).then(util.handleCrudResponse(messages, errors)); | return fetch(`${config.apiUrl}/users/${userId}/apps`, util.getWithAuth()).then(util.handleCrudResponse(messages, errors)); | ||||
@@ -7,12 +7,10 @@ import { util } from '../_helpers'; | |||||
const state = { | const state = { | ||||
loading: { | loading: { | ||||
enableMitm: false, disableMitm: false, | |||||
apps: false, app: false, enableApp: false, disableApp: false, | apps: false, app: false, enableApp: false, disableApp: false, | ||||
sites: false, site: false, enableSite: false, disableSite: false, | sites: false, site: false, enableSite: false, disableSite: false, | ||||
appData: false, appConfig: false, action: false | appData: false, appConfig: false, action: false | ||||
}, | }, | ||||
mitmEnabled: null, | |||||
error: null, | error: null, | ||||
apps: [], | apps: [], | ||||
icons: {}, | icons: {}, | ||||
@@ -25,34 +23,6 @@ const state = { | |||||
}; | }; | ||||
const actions = { | const actions = { | ||||
// MITM | |||||
getMitmStatus({ commit }, {userId, messages, errors}) { | |||||
commit('getMitmStatusRequest'); | |||||
appService.getMitmStatus(userId, messages, errors) | |||||
.then( | |||||
enabled => commit('getMitmStatusSuccess', enabled), | |||||
error => commit('getMitmStatusFailure', error) | |||||
); | |||||
}, | |||||
enableMitm({ commit }, {userId, messages, errors}) { | |||||
commit('enableMitmRequest'); | |||||
appService.enableMitm(userId, messages, errors) | |||||
.then( | |||||
enabled => commit('enableMitmSuccess', enabled), | |||||
error => commit('enableMitmFailure', error) | |||||
); | |||||
}, | |||||
disableMitm({ commit }, {userId, messages, errors}) { | |||||
commit('disableMitmRequest'); | |||||
appService.disableMitm(userId, messages, errors) | |||||
.then( | |||||
enabled => commit('disableMitmSuccess', enabled), | |||||
error => commit('disableMitmFailure', error) | |||||
); | |||||
}, | |||||
// Apps | // Apps | ||||
getAppsByUserId({ commit }, {userId, messages, errors}) { | getAppsByUserId({ commit }, {userId, messages, errors}) { | ||||
commit('getAppsByUserIdRequest'); | commit('getAppsByUserIdRequest'); | ||||
@@ -210,43 +180,6 @@ const actions = { | |||||
}; | }; | ||||
const mutations = { | const mutations = { | ||||
// MITM | |||||
getMitmStatusRequest(state) { | |||||
state.loading.getMitmStatus = true; | |||||
}, | |||||
getMitmStatusSuccess(state, enabled) { | |||||
state.loading.getMitmStatus = false; | |||||
state.mitmEnabled = enabled; | |||||
}, | |||||
getMitmStatusFailure(state, error) { | |||||
state.loading.getMitmStatus = false; | |||||
state.error = error; | |||||
}, | |||||
enableMitmRequest(state) { | |||||
state.loading.enableMitm = true; | |||||
}, | |||||
enableMitmSuccess(state, enabled) { | |||||
state.loading.enableMitm = false; | |||||
state.mitmEnabled = enabled; | |||||
}, | |||||
enableMitmFailure(state, error) { | |||||
state.loading.apps = false; | |||||
state.error = error; | |||||
}, | |||||
disableMitmRequest(state) { | |||||
state.loading.disableMitm = true; | |||||
}, | |||||
disableMitmSuccess(state, enabled) { | |||||
state.loading.disableMitm = false; | |||||
state.mitmEnabled = enabled; | |||||
}, | |||||
disableMitmFailure(state, error) { | |||||
state.loading.apps = false; | |||||
state.error = error; | |||||
}, | |||||
// Apps | // Apps | ||||
getAppsByUserIdRequest(state) { | getAppsByUserIdRequest(state) { | ||||
state.loading.apps = true; | state.loading.apps = true; | ||||
@@ -36,7 +36,7 @@ | |||||
}; | }; | ||||
}, | }, | ||||
computed: { | computed: { | ||||
...mapState('apps', ['mitmEnabled', 'apps', 'app', 'icons']), | |||||
...mapState('apps', ['apps', 'app', 'icons']), | |||||
...mapState('system', ['messages']) | ...mapState('system', ['messages']) | ||||
}, | }, | ||||
created () { | created () { | ||||
@@ -103,15 +103,6 @@ | |||||
<a href="/api/auth/cacert?deviceType=firefox">{{messages.message_os_firefox}}</a> | <a href="/api/auth/cacert?deviceType=firefox">{{messages.message_os_firefox}}</a> | ||||
<hr/> | <hr/> | ||||
</div> | </div> | ||||
<div v-if="user && user.admin"> | |||||
<h4>{{messages.form_title_mitm}}: {{mitmEnabled ? messages.message_mitm_enabled : messages.message_mitm_disabled}}</h4> | |||||
<button v-if="mitmEnabled" :disabled="mitmLoading" @click="mitmOff()">{{messages.button_label_mitm_disable}}</button> | |||||
<button v-else :disabled="mitmLoading" @click="mitmOn()">{{messages.button_label_mitm_enable}}</button> | |||||
<div v-if="errors.has('mitm')" class="invalid-feedback d-block">{{ errors.first('mitm') }}</div> | |||||
<hr/> | |||||
</div> | |||||
</div> | </div> | ||||
</template> | </template> | ||||
@@ -132,12 +123,10 @@ | |||||
displayVpnConfig: {}, | displayVpnConfig: {}, | ||||
displayDeviceHelp: {}, | displayDeviceHelp: {}, | ||||
config: config, | config: config, | ||||
mitmLoading: true, | |||||
loadingImgSrc: loadingImgSrc | loadingImgSrc: loadingImgSrc | ||||
}; | }; | ||||
}, | }, | ||||
computed: { | computed: { | ||||
...mapState('apps', ['mitmEnabled']), | |||||
...mapState('devices', ['deviceTypes', 'devices', 'device', 'qrCodeImageBase64', 'vpnConfBase64']), | ...mapState('devices', ['deviceTypes', 'devices', 'device', 'qrCodeImageBase64', 'vpnConfBase64']), | ||||
...mapState('system', ['messages']), | ...mapState('system', ['messages']), | ||||
...mapGetters('devices', ['loading']), | ...mapGetters('devices', ['loading']), | ||||
@@ -146,11 +135,6 @@ | |||||
} | } | ||||
}, | }, | ||||
created () { | created () { | ||||
this.getMitmStatus({ | |||||
userId: this.userId, | |||||
messages: this.messages, | |||||
errors: this.errors | |||||
}); | |||||
this.getDevicesByUserId({ | this.getDevicesByUserId({ | ||||
userId: this.userId, | userId: this.userId, | ||||
messages: this.messages, | messages: this.messages, | ||||
@@ -171,7 +155,6 @@ | |||||
}); | }); | ||||
}, | }, | ||||
methods: { | methods: { | ||||
...mapActions('apps', ['getMitmStatus', 'enableMitm', 'disableMitm']), | |||||
...mapActions('devices', [ | ...mapActions('devices', [ | ||||
'getAllDeviceTypesByUserId', 'getDevicesByUserId', 'addDeviceByUserId', 'removeDeviceByUserId', | 'getAllDeviceTypesByUserId', 'getDevicesByUserId', 'addDeviceByUserId', 'removeDeviceByUserId', | ||||
'getDeviceQRcodeById', 'getDeviceVPNconfById' | 'getDeviceQRcodeById', 'getDeviceVPNconfById' | ||||
@@ -223,26 +206,7 @@ | |||||
this.displayDeviceHelp = {}; | this.displayDeviceHelp = {}; | ||||
this.displayDeviceHelp[id] = true; | this.displayDeviceHelp[id] = true; | ||||
}, | }, | ||||
hideDeviceHelp () { this.displayDeviceHelp = {}; }, | |||||
mitmOn () { | |||||
this.mitmLoading = true; | |||||
this.errors.clear(); | |||||
this.enableMitm({ | |||||
userId: this.user.uuid, | |||||
messages: this.messages, | |||||
errors: this.errors | |||||
}); | |||||
}, | |||||
mitmOff () { | |||||
this.mitmLoading = true; | |||||
this.errors.clear(); | |||||
this.disableMitm({ | |||||
userId: this.user.uuid, | |||||
messages: this.messages, | |||||
errors: this.errors | |||||
}); | |||||
} | |||||
hideDeviceHelp () { this.displayDeviceHelp = {}; } | |||||
}, | }, | ||||
watch: { | watch: { | ||||
device(dev) { | device(dev) { | ||||
@@ -252,9 +216,6 @@ | |||||
this.deviceType = null; | this.deviceType = null; | ||||
if (dev.uuid) this.displayDeviceHelp[dev.uuid] = true; | if (dev.uuid) this.displayDeviceHelp[dev.uuid] = true; | ||||
} | } | ||||
}, | |||||
mitmEnabled (m) { | |||||
this.mitmLoading = false; | |||||
} | } | ||||
} | } | ||||
}; | }; |
@@ -208,11 +208,26 @@ | |||||
<div>{{messages.field_description_network_ssh_key}}</div> | <div>{{messages.field_description_network_ssh_key}}</div> | ||||
<hr/> | <hr/> | ||||
<!-- error and metrics reporting --> | |||||
<!-- sync password --> | |||||
<div class="form-group"> | |||||
<label for="syncPassword">{{messages.field_label_sync_password}}</label> | |||||
<input type="checkbox" id="syncPassword" v-model="accountPlan.syncPassword"> | |||||
<div v-if="submitted && errors.has('syncPassword')" class="invalid-feedback d-block">{{ errors.first('syncPassword') }}</div> | |||||
<p>{{messages.field_label_sync_password_description}}</p> | |||||
</div> | |||||
<!-- error reporting --> | |||||
<div class="form-group" v-if="configs.requireSendMetrics && configs.requireSendMetrics !== true"> | |||||
<label for="sendErrors">{{messages.field_label_send_errors}}</label> | |||||
<input type="checkbox" id="sendErrors" v-model="accountPlan.sendErrors"> | |||||
<div v-if="submitted && errors.has('sendErrors')" class="invalid-feedback d-block">{{ errors.first('sendErrors') }}</div> | |||||
<p>{{messages.field_label_send_errors_description}}</p> | |||||
</div> | |||||
<!-- metrics reporting --> | |||||
<div class="form-group" v-if="configs.requireSendMetrics && configs.requireSendMetrics !== true"> | <div class="form-group" v-if="configs.requireSendMetrics && configs.requireSendMetrics !== true"> | ||||
<label for="sendMetrics">{{messages.field_label_send_metrics}}</label> | <label for="sendMetrics">{{messages.field_label_send_metrics}}</label> | ||||
<input type="checkbox" id="sendMetrics" v-model="accountPlan.sendMetrics"> | <input type="checkbox" id="sendMetrics" v-model="accountPlan.sendMetrics"> | ||||
<div v-if="submitted && errors.has('sendMetrics')" class="invalid-feedback d-block">{{ errors.first('sendMetrics') }}</div> | <div v-if="submitted && errors.has('sendMetrics')" class="invalid-feedback d-block">{{ errors.first('sendMetrics') }}</div> | ||||
<p>{{messages.field_label_send_metrics_description}}</p> | |||||
</div> | </div> | ||||
<hr/> | <hr/> | ||||
@@ -336,6 +351,8 @@ | |||||
}, | }, | ||||
sshKey: '', | sshKey: '', | ||||
forkHost: '', | forkHost: '', | ||||
syncPassword: true, | |||||
sendErrors: true, | |||||
sendMetrics: true | sendMetrics: true | ||||
}, | }, | ||||
networkType: 'bubble', | networkType: 'bubble', | ||||
@@ -602,7 +619,11 @@ | |||||
this.errors.add({field: 'region', msg: this.messages['err_region_notFound']}); | this.errors.add({field: 'region', msg: this.messages['err_region_notFound']}); | ||||
} else { | } else { | ||||
if (this.configs.requireSendMetrics) { | if (this.configs.requireSendMetrics) { | ||||
this.accountPlan.sendErrors = true; | |||||
this.accountPlan.sendMetrics = true; | this.accountPlan.sendMetrics = true; | ||||
} else { | |||||
if (this.accountPlan.sendErrors === null) this.accountPlan.sendErrors = true; | |||||
if (this.accountPlan.sendMetrics === null) this.accountPlan.sendMetrics = true; | |||||
} | } | ||||
this.addPlanAndStartNetwork({ | this.addPlanAndStartNetwork({ | ||||
userId: this.user.uuid, | userId: this.user.uuid, | ||||
@@ -85,6 +85,7 @@ | |||||
...mapState('system', ['messages']) | ...mapState('system', ['messages']) | ||||
}, | }, | ||||
methods: { | methods: { | ||||
...mapActions({ alertSuccess: 'alert/success', alertError: 'alert/error' }), | |||||
...mapActions('users', ['getUserById', 'getPolicyByUserId', 'changePassword', 'adminChangePassword']), | ...mapActions('users', ['getUserById', 'getPolicyByUserId', 'changePassword', 'adminChangePassword']), | ||||
...mapGetters('users', ['loading']), | ...mapGetters('users', ['loading']), | ||||
changePass (e) { | changePass (e) { | ||||
@@ -116,7 +117,6 @@ | |||||
// should never happen | // should never happen | ||||
console.warn('Not current user and not admin, API call would fail anyway, not sending'); | console.warn('Not current user and not admin, API call would fail anyway, not sending'); | ||||
} | } | ||||
console.log('changePass called'); | |||||
} | } | ||||
}, | }, | ||||
created () { | created () { | ||||
@@ -139,13 +139,17 @@ | |||||
} | } | ||||
} | } | ||||
} | } | ||||
console.log('watch.policy: setting requiredExternalAuthContacts = '+JSON.stringify(contacts)); | |||||
// console.log('watch.policy: setting requiredExternalAuthContacts = '+JSON.stringify(contacts)); | |||||
this.requiredExternalAuthContacts = contacts; | this.requiredExternalAuthContacts = contacts; | ||||
} | } | ||||
}, | }, | ||||
changePasswordResponse (r) { | changePasswordResponse (r) { | ||||
if (r) { | if (r) { | ||||
console.log('watch.changePasswordResponse: received '+JSON.stringify(r)); | |||||
if (r.uuid && r.token) { | |||||
this.alertSuccess(this.messages['message_change_password_request_sent']); | |||||
} else { | |||||
this.alertError(this.messages['message_change_password_error']); | |||||
} | |||||
} | } | ||||
} | } | ||||
} | } | ||||