Signed-off-by: Roeland Jago Douma <roeland@famdouma.nl> Signed-off-by: npmbuildbot[bot] <npmbuildbot[bot]@users.noreply.github.com>tags/v19.0.0RC2
import axios from '@nextcloud/axios' | import axios from '@nextcloud/axios' | ||||
import { Multiselect } from '@nextcloud/vue' | import { Multiselect } from '@nextcloud/vue' | ||||
import _ from 'lodash' | import _ from 'lodash' | ||||
import { generateUrl, generateOcsUrl } from '@nextcloud/router' | |||||
export default { | export default { | ||||
name: 'AdminTwoFactor', | name: 'AdminTwoFactor', | ||||
methods: { | methods: { | ||||
searchGroup: _.debounce(function(query) { | searchGroup: _.debounce(function(query) { | ||||
this.loadingGroups = true | this.loadingGroups = true | ||||
axios.get(OC.linkToOCS(`cloud/groups?offset=0&search=${encodeURIComponent(query)}&limit=20`, 2)) | |||||
axios.get(generateOcsUrl(`cloud/groups?offset=0&search=${encodeURIComponent(query)}&limit=20`, 2)) | |||||
.then(res => res.data.ocs) | .then(res => res.data.ocs) | ||||
.then(ocs => ocs.data.groups) | .then(ocs => ocs.data.groups) | ||||
.then(groups => { this.groups = _.sortedUniq(_.uniq(this.groups.concat(groups))) }) | .then(groups => { this.groups = _.sortedUniq(_.uniq(this.groups.concat(groups))) }) | ||||
enforcedGroups: this.enforcedGroups, | enforcedGroups: this.enforcedGroups, | ||||
excludedGroups: this.excludedGroups, | excludedGroups: this.excludedGroups, | ||||
} | } | ||||
axios.put(OC.generateUrl('/settings/api/admin/twofactorauth'), data) | |||||
axios.put(generateUrl('/settings/api/admin/twofactorauth'), data) | |||||
.then(resp => resp.data) | .then(resp => resp.data) | ||||
.then(state => { | .then(state => { | ||||
this.state = state | this.state = state |
<img :src="scoreImage" class="app-score-image"> | <img :src="scoreImage" class="app-score-image"> | ||||
</template> | </template> | ||||
<script> | <script> | ||||
import { imagePath } from '@nextcloud/router' | |||||
export default { | export default { | ||||
name: 'AppScore', | name: 'AppScore', | ||||
props: ['score'], | props: ['score'], | ||||
scoreImage() { | scoreImage() { | ||||
const score = Math.round(this.score * 10) | const score = Math.round(this.score * 10) | ||||
const imageName = 'rating/s' + score + '.svg' | const imageName = 'rating/s' + score + '.svg' | ||||
return OC.imagePath('core', imageName) | |||||
return imagePath('core', imageName) | |||||
}, | }, | ||||
}, | }, | ||||
} | } |
<script> | <script> | ||||
import axios from '@nextcloud/axios' | import axios from '@nextcloud/axios' | ||||
import confirmPassword from '@nextcloud/password-confirmation' | import confirmPassword from '@nextcloud/password-confirmation' | ||||
import { generateUrl } from '@nextcloud/router' | |||||
import AuthTokenList from './AuthTokenList' | import AuthTokenList from './AuthTokenList' | ||||
import AuthTokenSetupDialogue from './AuthTokenSetupDialogue' | import AuthTokenSetupDialogue from './AuthTokenSetupDialogue' | ||||
}, | }, | ||||
data() { | data() { | ||||
return { | return { | ||||
baseUrl: OC.generateUrl('/settings/personal/authtokens'), | |||||
baseUrl: generateUrl('/settings/personal/authtokens'), | |||||
} | } | ||||
}, | }, | ||||
methods: { | methods: { |
<button class="button" | <button class="button" | ||||
:disabled="loading" | :disabled="loading" | ||||
@click="submit"> | @click="submit"> | ||||
{{ t('settings', 'Create new app password') }} | |||||
{{ t('settings', 'Create new app password') }} | |||||
</button> | </button> | ||||
</div> | </div> | ||||
<div v-else> | <div v-else> | ||||
<script> | <script> | ||||
import QR from '@chenfengyuan/vue-qrcode' | import QR from '@chenfengyuan/vue-qrcode' | ||||
import confirmPassword from '@nextcloud/password-confirmation' | import confirmPassword from '@nextcloud/password-confirmation' | ||||
import { getRootUrl } from '@nextcloud/router' | |||||
export default { | export default { | ||||
name: 'AuthTokenSetupDialogue', | name: 'AuthTokenSetupDialogue', | ||||
this.loginName = token.loginName | this.loginName = token.loginName | ||||
this.appPassword = token.token | this.appPassword = token.token | ||||
const server = window.location.protocol + '//' + window.location.host + OC.getRootPath() | |||||
const server = window.location.protocol + '//' + window.location.host + getRootUrl() | |||||
this.qrUrl = `nc://login/user:${token.loginName}&password:${token.token}&server:${server}` | this.qrUrl = `nc://login/user:${token.loginName}&password:${token.token}&server:${server}` | ||||
this.$nextTick(() => { | this.$nextTick(() => { |
httpWarning: Boolean, | httpWarning: Boolean, | ||||
isHttps: { | isHttps: { | ||||
type: Boolean, | type: Boolean, | ||||
default: false | |||||
} | |||||
default: false, | |||||
}, | |||||
}, | }, | ||||
data() { | data() { | ||||
return { | return { |
{{ t('settings', 'Your browser does not support WebAuthn.') }} | {{ t('settings', 'Your browser does not support WebAuthn.') }} | ||||
</p> | </p> | ||||
<AddDevice v-if="hasPublicKeyCredential" :isHttps="isHttps" @added="deviceAdded" /> | |||||
<AddDevice v-if="hasPublicKeyCredential" :is-https="isHttps" @added="deviceAdded" /> | |||||
</div> | </div> | ||||
</template> | </template> | ||||
* | * | ||||
*/ | */ | ||||
import { generateUrl } from '@nextcloud/router' | |||||
export default { | export default { | ||||
props: { | props: { | ||||
user: { | user: { | ||||
* @returns {string} | * @returns {string} | ||||
*/ | */ | ||||
generateAvatar(user, size = 32) { | generateAvatar(user, size = 32) { | ||||
return OC.generateUrl( | |||||
return generateUrl( | |||||
'/avatar/{user}/{size}?v={version}', | '/avatar/{user}/{size}?v={version}', | ||||
{ | { | ||||
user: user, | user: user, |
import Vue from 'vue' | import Vue from 'vue' | ||||
import Router from 'vue-router' | import Router from 'vue-router' | ||||
import { generateUrl } from '@nextcloud/router' | |||||
// Dynamic loading | // Dynamic loading | ||||
const Users = () => import('./views/Users') | const Users = () => import('./views/Users') | ||||
mode: 'history', | mode: 'history', | ||||
// if index.php is in the url AND we got this far, then it's working: | // if index.php is in the url AND we got this far, then it's working: | ||||
// let's keep using index.php in the url | // let's keep using index.php in the url | ||||
base: OC.generateUrl(''), | |||||
base: generateUrl(''), | |||||
linkActiveClass: 'active', | linkActiveClass: 'active', | ||||
routes: [ | routes: [ | ||||
{ | { |
* you'll need to be careful when using it. | * you'll need to be careful when using it. | ||||
* e.g | * e.g | ||||
* // store | * // store | ||||
* action(context) { | |||||
* return api.requireAdmin().then((response) => { | |||||
* return api.get('url') | |||||
* .then((response) => {API success}) | |||||
* .catch((error) => {API failure}); | |||||
* }).catch((error) => {requireAdmin failure}); | |||||
* } | |||||
* action(context) { | |||||
* return api.requireAdmin().then((response) => { | |||||
* return api.get('url') | |||||
* .then((response) => {API success}) | |||||
* .catch((error) => {API failure}); | |||||
* }).catch((error) => {requireAdmin failure}); | |||||
* } | |||||
* // vue | * // vue | ||||
* this.$store.dispatch('action').then(() => {always executed}) | |||||
* this.$store.dispatch('action').then(() => {always executed}) | |||||
* | * | ||||
* Since Promise.then().catch().then() will always execute the last then | * Since Promise.then().catch().then() will always execute the last then | ||||
* this.$store.dispatch('action').then will always be executed | * this.$store.dispatch('action').then will always be executed | ||||
* you will need to throw a new error in the api.get.catch() | * you will need to throw a new error in the api.get.catch() | ||||
* | * | ||||
* e.g | * e.g | ||||
* api.requireAdmin().then((response) => { | |||||
* api.get('url') | |||||
* .then((response) => {API success}) | |||||
* .catch((error) => {throw error;}); | |||||
* }).catch((error) => {requireAdmin OR API failure}); | |||||
* api.requireAdmin().then((response) => { | |||||
* api.get('url') | |||||
* .then((response) => {API success}) | |||||
* .catch((error) => {throw error;}); | |||||
* }).catch((error) => {requireAdmin OR API failure}); | |||||
* | * | ||||
* @returns {Promise} | * @returns {Promise} | ||||
*/ | */ |
import api from './api' | import api from './api' | ||||
import Vue from 'vue' | import Vue from 'vue' | ||||
import { generateUrl } from '@nextcloud/router' | |||||
const state = { | const state = { | ||||
apps: [], | apps: [], | ||||
return api.requireAdmin().then((response) => { | return api.requireAdmin().then((response) => { | ||||
context.commit('startLoading', apps) | context.commit('startLoading', apps) | ||||
context.commit('startLoading', 'install') | context.commit('startLoading', 'install') | ||||
return api.post(OC.generateUrl(`settings/apps/enable`), { appIds: apps, groups: groups }) | |||||
return api.post(generateUrl(`settings/apps/enable`), { appIds: apps, groups: groups }) | |||||
.then((response) => { | .then((response) => { | ||||
context.commit('stopLoading', apps) | context.commit('stopLoading', apps) | ||||
context.commit('stopLoading', 'install') | context.commit('stopLoading', 'install') | ||||
}) | }) | ||||
// check for server health | // check for server health | ||||
return api.get(OC.generateUrl('apps/files')) | |||||
return api.get(generateUrl('apps/files')) | |||||
.then(() => { | .then(() => { | ||||
if (response.data.update_required) { | if (response.data.update_required) { | ||||
OC.dialogs.info( | OC.dialogs.info( | ||||
return api.requireAdmin().then(() => { | return api.requireAdmin().then(() => { | ||||
context.commit('startLoading', apps) | context.commit('startLoading', apps) | ||||
context.commit('startLoading', 'install') | context.commit('startLoading', 'install') | ||||
return api.post(OC.generateUrl(`settings/apps/force`), { appId }) | |||||
return api.post(generateUrl(`settings/apps/force`), { appId }) | |||||
.then((response) => { | .then((response) => { | ||||
// TODO: find a cleaner solution | // TODO: find a cleaner solution | ||||
location.reload() | location.reload() | ||||
} | } | ||||
return api.requireAdmin().then((response) => { | return api.requireAdmin().then((response) => { | ||||
context.commit('startLoading', apps) | context.commit('startLoading', apps) | ||||
return api.post(OC.generateUrl(`settings/apps/disable`), { appIds: apps }) | |||||
return api.post(generateUrl(`settings/apps/disable`), { appIds: apps }) | |||||
.then((response) => { | .then((response) => { | ||||
context.commit('stopLoading', apps) | context.commit('stopLoading', apps) | ||||
apps.forEach(_appId => { | apps.forEach(_appId => { | ||||
uninstallApp(context, { appId }) { | uninstallApp(context, { appId }) { | ||||
return api.requireAdmin().then((response) => { | return api.requireAdmin().then((response) => { | ||||
context.commit('startLoading', appId) | context.commit('startLoading', appId) | ||||
return api.get(OC.generateUrl(`settings/apps/uninstall/${appId}`)) | |||||
return api.get(generateUrl(`settings/apps/uninstall/${appId}`)) | |||||
.then((response) => { | .then((response) => { | ||||
context.commit('stopLoading', appId) | context.commit('stopLoading', appId) | ||||
context.commit('uninstallApp', appId) | context.commit('uninstallApp', appId) | ||||
return api.requireAdmin().then((response) => { | return api.requireAdmin().then((response) => { | ||||
context.commit('startLoading', appId) | context.commit('startLoading', appId) | ||||
context.commit('startLoading', 'install') | context.commit('startLoading', 'install') | ||||
return api.get(OC.generateUrl(`settings/apps/update/${appId}`)) | |||||
return api.get(generateUrl(`settings/apps/update/${appId}`)) | |||||
.then((response) => { | .then((response) => { | ||||
context.commit('stopLoading', 'install') | context.commit('stopLoading', 'install') | ||||
context.commit('stopLoading', appId) | context.commit('stopLoading', appId) | ||||
getAllApps(context) { | getAllApps(context) { | ||||
context.commit('startLoading', 'list') | context.commit('startLoading', 'list') | ||||
return api.get(OC.generateUrl(`settings/apps/list`)) | |||||
return api.get(generateUrl(`settings/apps/list`)) | |||||
.then((response) => { | .then((response) => { | ||||
context.commit('setAllApps', response.data.apps) | context.commit('setAllApps', response.data.apps) | ||||
context.commit('stopLoading', 'list') | context.commit('stopLoading', 'list') | ||||
getCategories(context) { | getCategories(context) { | ||||
context.commit('startLoading', 'categories') | context.commit('startLoading', 'categories') | ||||
return api.get(OC.generateUrl('settings/apps/categories')) | |||||
return api.get(generateUrl('settings/apps/categories')) | |||||
.then((response) => { | .then((response) => { | ||||
if (response.data.length > 0) { | if (response.data.length > 0) { | ||||
context.commit('appendCategories', response.data) | context.commit('appendCategories', response.data) |
*/ | */ | ||||
import api from './api' | import api from './api' | ||||
import { generateOcsUrl } from '@nextcloud/router' | |||||
const state = {} | const state = {} | ||||
const mutations = {} | const mutations = {} | ||||
*/ | */ | ||||
setAppConfig(context, { app, key, value }) { | setAppConfig(context, { app, key, value }) { | ||||
return api.requireAdmin().then((response) => { | return api.requireAdmin().then((response) => { | ||||
return api.post(OC.linkToOCS(`apps/provisioning_api/api/v1/config/apps/${app}/${key}`, 2), { value: value }) | |||||
return api.post(generateOcsUrl(`apps/provisioning_api/api/v1/config/apps/${app}/${key}`, 2), { value: value }) | |||||
.catch((error) => { throw error }) | .catch((error) => { throw error }) | ||||
}).catch((error) => context.commit('API_FAILURE', { app, key, value, error })) | }).catch((error) => context.commit('API_FAILURE', { app, key, value, error })) | ||||
}, | }, |
*/ | */ | ||||
import api from './api' | import api from './api' | ||||
import { generateOcsUrl } from '@nextcloud/router' | |||||
const orderGroups = function(groups, orderBy) { | const orderGroups = function(groups, orderBy) { | ||||
/* const SORT_USERCOUNT = 1; | /* const SORT_USERCOUNT = 1; | ||||
search = typeof search === 'string' ? search : '' | search = typeof search === 'string' ? search : '' | ||||
group = typeof group === 'string' ? group : '' | group = typeof group === 'string' ? group : '' | ||||
if (group !== '') { | if (group !== '') { | ||||
return api.get(OC.linkToOCS(`cloud/groups/${encodeURIComponent(encodeURIComponent(group))}/users/details?offset=${offset}&limit=${limit}&search=${search}`, 2)) | |||||
return api.get(generateOcsUrl(`cloud/groups/${encodeURIComponent(encodeURIComponent(group))}/users/details?offset=${offset}&limit=${limit}&search=${search}`, 2)) | |||||
.then((response) => { | .then((response) => { | ||||
if (Object.keys(response.data.ocs.data.users).length > 0) { | if (Object.keys(response.data.ocs.data.users).length > 0) { | ||||
context.commit('appendUsers', response.data.ocs.data.users) | context.commit('appendUsers', response.data.ocs.data.users) | ||||
.catch((error) => context.commit('API_FAILURE', error)) | .catch((error) => context.commit('API_FAILURE', error)) | ||||
} | } | ||||
return api.get(OC.linkToOCS(`cloud/users/details?offset=${offset}&limit=${limit}&search=${search}`, 2)) | |||||
return api.get(generateOcsUrl(`cloud/users/details?offset=${offset}&limit=${limit}&search=${search}`, 2)) | |||||
.then((response) => { | .then((response) => { | ||||
if (Object.keys(response.data.ocs.data.users).length > 0) { | if (Object.keys(response.data.ocs.data.users).length > 0) { | ||||
context.commit('appendUsers', response.data.ocs.data.users) | context.commit('appendUsers', response.data.ocs.data.users) | ||||
getGroups(context, { offset, limit, search }) { | getGroups(context, { offset, limit, search }) { | ||||
search = typeof search === 'string' ? search : '' | search = typeof search === 'string' ? search : '' | ||||
const limitParam = limit === -1 ? '' : `&limit=${limit}` | const limitParam = limit === -1 ? '' : `&limit=${limit}` | ||||
return api.get(OC.linkToOCS(`cloud/groups?offset=${offset}&search=${search}${limitParam}`, 2)) | |||||
return api.get(generateOcsUrl(`cloud/groups?offset=${offset}&search=${search}${limitParam}`, 2)) | |||||
.then((response) => { | .then((response) => { | ||||
if (Object.keys(response.data.ocs.data.groups).length > 0) { | if (Object.keys(response.data.ocs.data.groups).length > 0) { | ||||
response.data.ocs.data.groups.forEach(function(group) { | response.data.ocs.data.groups.forEach(function(group) { | ||||
*/ | */ | ||||
getUsersFromList(context, { offset, limit, search }) { | getUsersFromList(context, { offset, limit, search }) { | ||||
search = typeof search === 'string' ? search : '' | search = typeof search === 'string' ? search : '' | ||||
return api.get(OC.linkToOCS(`cloud/users/details?offset=${offset}&limit=${limit}&search=${search}`, 2)) | |||||
return api.get(generateOcsUrl(`cloud/users/details?offset=${offset}&limit=${limit}&search=${search}`, 2)) | |||||
.then((response) => { | .then((response) => { | ||||
if (Object.keys(response.data.ocs.data.users).length > 0) { | if (Object.keys(response.data.ocs.data.users).length > 0) { | ||||
context.commit('appendUsers', response.data.ocs.data.users) | context.commit('appendUsers', response.data.ocs.data.users) | ||||
* @returns {Promise} | * @returns {Promise} | ||||
*/ | */ | ||||
getUsersFromGroup(context, { groupid, offset, limit }) { | getUsersFromGroup(context, { groupid, offset, limit }) { | ||||
return api.get(OC.linkToOCS(`cloud/users/${encodeURIComponent(encodeURIComponent(groupid))}/details?offset=${offset}&limit=${limit}`, 2)) | |||||
return api.get(generateOcsUrl(`cloud/users/${encodeURIComponent(encodeURIComponent(groupid))}/details?offset=${offset}&limit=${limit}`, 2)) | |||||
.then((response) => context.commit('getUsersFromList', response.data.ocs.data.users)) | .then((response) => context.commit('getUsersFromList', response.data.ocs.data.users)) | ||||
.catch((error) => context.commit('API_FAILURE', error)) | .catch((error) => context.commit('API_FAILURE', error)) | ||||
}, | }, | ||||
*/ | */ | ||||
addGroup(context, gid) { | addGroup(context, gid) { | ||||
return api.requireAdmin().then((response) => { | return api.requireAdmin().then((response) => { | ||||
return api.post(OC.linkToOCS(`cloud/groups`, 2), { groupid: gid }) | |||||
return api.post(generateOcsUrl(`cloud/groups`, 2), { groupid: gid }) | |||||
.then((response) => { | .then((response) => { | ||||
context.commit('addGroup', { gid: gid, displayName: gid }) | context.commit('addGroup', { gid: gid, displayName: gid }) | ||||
return { gid: gid, displayName: gid } | return { gid: gid, displayName: gid } | ||||
*/ | */ | ||||
removeGroup(context, gid) { | removeGroup(context, gid) { | ||||
return api.requireAdmin().then((response) => { | return api.requireAdmin().then((response) => { | ||||
return api.delete(OC.linkToOCS(`cloud/groups/${encodeURIComponent(encodeURIComponent(gid))}`, 2)) | |||||
return api.delete(generateOcsUrl(`cloud/groups/${encodeURIComponent(encodeURIComponent(gid))}`, 2)) | |||||
.then((response) => context.commit('removeGroup', gid)) | .then((response) => context.commit('removeGroup', gid)) | ||||
.catch((error) => { throw error }) | .catch((error) => { throw error }) | ||||
}).catch((error) => context.commit('API_FAILURE', { gid, error })) | }).catch((error) => context.commit('API_FAILURE', { gid, error })) | ||||
*/ | */ | ||||
addUserGroup(context, { userid, gid }) { | addUserGroup(context, { userid, gid }) { | ||||
return api.requireAdmin().then((response) => { | return api.requireAdmin().then((response) => { | ||||
return api.post(OC.linkToOCS(`cloud/users/${userid}/groups`, 2), { groupid: gid }) | |||||
return api.post(generateOcsUrl(`cloud/users/${userid}/groups`, 2), { groupid: gid }) | |||||
.then((response) => context.commit('addUserGroup', { userid, gid })) | .then((response) => context.commit('addUserGroup', { userid, gid })) | ||||
.catch((error) => { throw error }) | .catch((error) => { throw error }) | ||||
}).catch((error) => context.commit('API_FAILURE', { userid, error })) | }).catch((error) => context.commit('API_FAILURE', { userid, error })) | ||||
*/ | */ | ||||
removeUserGroup(context, { userid, gid }) { | removeUserGroup(context, { userid, gid }) { | ||||
return api.requireAdmin().then((response) => { | return api.requireAdmin().then((response) => { | ||||
return api.delete(OC.linkToOCS(`cloud/users/${userid}/groups`, 2), { groupid: gid }) | |||||
return api.delete(generateOcsUrl(`cloud/users/${userid}/groups`, 2), { groupid: gid }) | |||||
.then((response) => context.commit('removeUserGroup', { userid, gid })) | .then((response) => context.commit('removeUserGroup', { userid, gid })) | ||||
.catch((error) => { throw error }) | .catch((error) => { throw error }) | ||||
}).catch((error) => { | }).catch((error) => { | ||||
*/ | */ | ||||
addUserSubAdmin(context, { userid, gid }) { | addUserSubAdmin(context, { userid, gid }) { | ||||
return api.requireAdmin().then((response) => { | return api.requireAdmin().then((response) => { | ||||
return api.post(OC.linkToOCS(`cloud/users/${userid}/subadmins`, 2), { groupid: gid }) | |||||
return api.post(generateOcsUrl(`cloud/users/${userid}/subadmins`, 2), { groupid: gid }) | |||||
.then((response) => context.commit('addUserSubAdmin', { userid, gid })) | .then((response) => context.commit('addUserSubAdmin', { userid, gid })) | ||||
.catch((error) => { throw error }) | .catch((error) => { throw error }) | ||||
}).catch((error) => context.commit('API_FAILURE', { userid, error })) | }).catch((error) => context.commit('API_FAILURE', { userid, error })) | ||||
*/ | */ | ||||
removeUserSubAdmin(context, { userid, gid }) { | removeUserSubAdmin(context, { userid, gid }) { | ||||
return api.requireAdmin().then((response) => { | return api.requireAdmin().then((response) => { | ||||
return api.delete(OC.linkToOCS(`cloud/users/${userid}/subadmins`, 2), { groupid: gid }) | |||||
return api.delete(generateOcsUrl(`cloud/users/${userid}/subadmins`, 2), { groupid: gid }) | |||||
.then((response) => context.commit('removeUserSubAdmin', { userid, gid })) | .then((response) => context.commit('removeUserSubAdmin', { userid, gid })) | ||||
.catch((error) => { throw error }) | .catch((error) => { throw error }) | ||||
}).catch((error) => context.commit('API_FAILURE', { userid, error })) | }).catch((error) => context.commit('API_FAILURE', { userid, error })) | ||||
*/ | */ | ||||
wipeUserDevices(context, userid) { | wipeUserDevices(context, userid) { | ||||
return api.requireAdmin().then((response) => { | return api.requireAdmin().then((response) => { | ||||
return api.post(OC.linkToOCS(`cloud/users/${userid}/wipe`, 2)) | |||||
return api.post(generateOcsUrl(`cloud/users/${userid}/wipe`, 2)) | |||||
.catch((error) => { throw error }) | .catch((error) => { throw error }) | ||||
}).catch((error) => context.commit('API_FAILURE', { userid, error })) | }).catch((error) => context.commit('API_FAILURE', { userid, error })) | ||||
}, | }, | ||||
*/ | */ | ||||
deleteUser(context, userid) { | deleteUser(context, userid) { | ||||
return api.requireAdmin().then((response) => { | return api.requireAdmin().then((response) => { | ||||
return api.delete(OC.linkToOCS(`cloud/users/${userid}`, 2)) | |||||
return api.delete(generateOcsUrl(`cloud/users/${userid}`, 2)) | |||||
.then((response) => context.commit('deleteUser', userid)) | .then((response) => context.commit('deleteUser', userid)) | ||||
.catch((error) => { throw error }) | .catch((error) => { throw error }) | ||||
}).catch((error) => context.commit('API_FAILURE', { userid, error })) | }).catch((error) => context.commit('API_FAILURE', { userid, error })) | ||||
*/ | */ | ||||
addUser({ commit, dispatch }, { userid, password, displayName, email, groups, subadmin, quota, language }) { | addUser({ commit, dispatch }, { userid, password, displayName, email, groups, subadmin, quota, language }) { | ||||
return api.requireAdmin().then((response) => { | return api.requireAdmin().then((response) => { | ||||
return api.post(OC.linkToOCS(`cloud/users`, 2), { userid, password, displayName, email, groups, subadmin, quota, language }) | |||||
return api.post(generateOcsUrl(`cloud/users`, 2), { userid, password, displayName, email, groups, subadmin, quota, language }) | |||||
.then((response) => dispatch('addUserData', userid || response.data.ocs.data.id)) | .then((response) => dispatch('addUserData', userid || response.data.ocs.data.id)) | ||||
.catch((error) => { throw error }) | .catch((error) => { throw error }) | ||||
}).catch((error) => { | }).catch((error) => { | ||||
*/ | */ | ||||
addUserData(context, userid) { | addUserData(context, userid) { | ||||
return api.requireAdmin().then((response) => { | return api.requireAdmin().then((response) => { | ||||
return api.get(OC.linkToOCS(`cloud/users/${userid}`, 2)) | |||||
return api.get(generateOcsUrl(`cloud/users/${userid}`, 2)) | |||||
.then((response) => context.commit('addUserData', response)) | .then((response) => context.commit('addUserData', response)) | ||||
.catch((error) => { throw error }) | .catch((error) => { throw error }) | ||||
}).catch((error) => context.commit('API_FAILURE', { userid, error })) | }).catch((error) => context.commit('API_FAILURE', { userid, error })) | ||||
enableDisableUser(context, { userid, enabled = true }) { | enableDisableUser(context, { userid, enabled = true }) { | ||||
const userStatus = enabled ? 'enable' : 'disable' | const userStatus = enabled ? 'enable' : 'disable' | ||||
return api.requireAdmin().then((response) => { | return api.requireAdmin().then((response) => { | ||||
return api.put(OC.linkToOCS(`cloud/users/${userid}/${userStatus}`, 2)) | |||||
return api.put(generateOcsUrl(`cloud/users/${userid}/${userStatus}`, 2)) | |||||
.then((response) => context.commit('enableDisableUser', { userid, enabled })) | .then((response) => context.commit('enableDisableUser', { userid, enabled })) | ||||
.catch((error) => { throw error }) | .catch((error) => { throw error }) | ||||
}).catch((error) => context.commit('API_FAILURE', { userid, error })) | }).catch((error) => context.commit('API_FAILURE', { userid, error })) | ||||
) | ) | ||||
) { | ) { | ||||
return api.requireAdmin().then((response) => { | return api.requireAdmin().then((response) => { | ||||
return api.put(OC.linkToOCS(`cloud/users/${userid}`, 2), { key: key, value: value }) | |||||
return api.put(generateOcsUrl(`cloud/users/${userid}`, 2), { key: key, value: value }) | |||||
.then((response) => context.commit('setUserData', { userid, key, value })) | .then((response) => context.commit('setUserData', { userid, key, value })) | ||||
.catch((error) => { throw error }) | .catch((error) => { throw error }) | ||||
}).catch((error) => context.commit('API_FAILURE', { userid, error })) | }).catch((error) => context.commit('API_FAILURE', { userid, error })) | ||||
*/ | */ | ||||
sendWelcomeMail(context, userid) { | sendWelcomeMail(context, userid) { | ||||
return api.requireAdmin().then((response) => { | return api.requireAdmin().then((response) => { | ||||
return api.post(OC.linkToOCS(`cloud/users/${userid}/welcome`, 2)) | |||||
return api.post(generateOcsUrl(`cloud/users/${userid}/welcome`, 2)) | |||||
.then(response => true) | .then(response => true) | ||||
.catch((error) => { throw error }) | .catch((error) => { throw error }) | ||||
}).catch((error) => context.commit('API_FAILURE', { userid, error })) | }).catch((error) => context.commit('API_FAILURE', { userid, error })) |