fix admin
This commit is contained in:
@@ -232,8 +232,38 @@ const onDeploy = async () => {
|
||||
});
|
||||
return;
|
||||
}
|
||||
|
||||
deployLoading.value = true;
|
||||
try {
|
||||
const { data }: {data: {code: string, groups: {code: string}[]}} = await api.get('api/v1/defaultgroup');
|
||||
if (data.code === 'CB_WA01') {
|
||||
$q.notify({
|
||||
type: 'negative',
|
||||
caption: 'エラー',
|
||||
message: 'ユーザーのパスワード認証に失敗しました。'
|
||||
});
|
||||
deployLoading.value = false;
|
||||
return;
|
||||
} else if (!data.groups || !data.groups.some((group: {code: string}) => group.code === 'Administrators')){
|
||||
$q.notify({
|
||||
type: 'negative',
|
||||
caption: 'エラー',
|
||||
message: 'この操作には管理者権限が必要です。'
|
||||
});
|
||||
deployLoading.value = false;
|
||||
return;
|
||||
}
|
||||
} catch (e) {
|
||||
$q.notify({
|
||||
type: 'negative',
|
||||
caption: 'エラー',
|
||||
message: 'サーバーに接続できませんでした。'
|
||||
});
|
||||
deployLoading.value = false;
|
||||
return;
|
||||
}
|
||||
|
||||
try {
|
||||
deployLoading.value = true;
|
||||
await store.deploy();
|
||||
deployLoading.value = false;
|
||||
$q.notify({
|
||||
|
||||
@@ -53,21 +53,21 @@
|
||||
<div class="text-h6 q-ma-sm">Kintone Account</div>
|
||||
</q-card-section>
|
||||
|
||||
<q-card-section class="q-pt-none q-mt-none">
|
||||
<q-card-section class="q-py-none q-mt-none">
|
||||
<div class="q-gutter-lg">
|
||||
|
||||
<q-input filled v-model="name" label="環境名 *" hint="kintoneの環境名を入力してください" lazy-rules
|
||||
:rules="[val => val && val.length > 0 || 'kintoneの環境名を入力してください。']" />
|
||||
|
||||
<q-input filled type="url" v-model.trim="url" label="Kintone url" hint="KintoneのURLを入力してください" lazy-rules
|
||||
<q-input filled v-model.trim="url" :readonly="!isCreate" label="Kintone url" :hint="isCreate ? 'KintoneのURLを入力してください':'KintoneのURLは変更できません。新規作成してください。'" lazy-rules
|
||||
:rules="[val => val && val.length > 0 || 'KintoneのURLを入力してください']" />
|
||||
|
||||
<q-input filled v-model="kintoneuser" label="ログイン名 *" hint="Kintoneのログイン名を入力してください" lazy-rules
|
||||
<q-input v-if="isCreate" filled v-model="kintoneuser" label="ログイン名 *" hint="Kintoneのログイン名を入力してください" lazy-rules
|
||||
:rules="[val => val && val.length > 0 || 'Kintoneのログイン名を入力してください']" autocomplete="new-password" />
|
||||
|
||||
<q-input v-if="isCreate" v-model="kintonepwd" filled :type="isPwd ? 'password' : 'text'"
|
||||
hint="パスワード" label="パスワード" :disable="!isCreate" lazy-rules
|
||||
:rules="[val => val && val.length > 0 || 'Please type something']" autocomplete="new-password">
|
||||
hint="Kintoneのパスワードを入力してください" label="パスワード" :disable="!isCreate" lazy-rules
|
||||
:rules="[val => val && val.length > 0 || 'Kintoneのパスワードを入力してください']" autocomplete="new-password">
|
||||
<template v-slot:append>
|
||||
<q-icon :name="isPwd ? 'visibility_off' : 'visibility'" class="cursor-pointer"
|
||||
@click="isPwd = !isPwd" />
|
||||
@@ -88,30 +88,51 @@
|
||||
|
||||
<q-item tag="label" class="q-pl-sm q-pr-none q-py-xs">
|
||||
<q-item-section>
|
||||
<q-item-label>パスワードリセット</q-item-label>
|
||||
<q-item-label>管理者アカウントの変更</q-item-label>
|
||||
</q-item-section>
|
||||
<q-item-section avatar>
|
||||
<q-toggle v-model="resetPsw" @update:model-value="updateResetPsw" />
|
||||
<q-toggle v-model="changeAccount" @update:model-value="updateChangeAccount" />
|
||||
</q-item-section>
|
||||
</q-item>
|
||||
|
||||
<q-input v-model="kintonepwd" filled :type="isPwd ? 'password' : 'text'" hint="パスワードを入力してください"
|
||||
label="パスワード" :disable="!resetPsw" lazy-rules
|
||||
:rules="[val => val && val.length > 0 || 'Please type something']" autocomplete="new-password">
|
||||
<template v-slot:append>
|
||||
<q-icon :name="isPwd ? 'visibility_off' : 'visibility'" class="cursor-pointer"
|
||||
@click="isPwd = !isPwd" />
|
||||
</template>
|
||||
</q-input>
|
||||
<!-- <q-btn label="asdf"/> -->
|
||||
<q-expansion-item
|
||||
header-class="hidden"
|
||||
class="q-mt-none"
|
||||
v-model="changeAccount"
|
||||
>
|
||||
<q-input filled v-model="kintoneuser" label="ログイン名 *" hint="Kintoneのログイン名を入力してください" :disable="!changeAccount"
|
||||
:rules="[val => val && val.length > 0 || 'Kintoneのログイン名を入力してください']" lazy-rules class="q-mt-md"/>
|
||||
|
||||
<q-input v-model="kintonepwd" filled :type="isPwd ? 'password' : 'text'" hint="Kintoneのパスワードを入力してください"
|
||||
label="パスワード" :disable="!changeAccount" lazy-rules class="q-mt-lg q-mb-md"
|
||||
:rules="[val => val && val.length > 0 || 'Kintoneのパスワードを入力してください']" autocomplete="new-password">
|
||||
<template v-slot:append>
|
||||
<q-icon :name="isPwd ? 'visibility_off' : 'visibility'" class="cursor-pointer"
|
||||
@click="isPwd = !isPwd" />
|
||||
</template>
|
||||
</q-input>
|
||||
<!-- <q-btn label="asdf"/> -->
|
||||
</q-expansion-item>
|
||||
|
||||
|
||||
</div>
|
||||
</div>
|
||||
|
||||
</q-card-section>
|
||||
<q-card-actions align="right" class="text-primary q-mb-md q-mx-sm">
|
||||
<q-btn :loading="addEditLoading" label="保存" type="submit" color="primary" />
|
||||
<q-btn label="キャンセル" type="cancel" color="primary" flat class="q-ml-sm" @click="closeDg()" />
|
||||
</q-card-actions>
|
||||
|
||||
<div class="q-mt-none">
|
||||
<q-banner dense :class="['text-white q-mt-sm q-py-xs q-mx-md', testResult?.success ? 'bg-green':'bg-red', testResult?.msg ? '':'invisible']">
|
||||
{{ testResult?.msg }}
|
||||
</q-banner>
|
||||
<q-card-actions class="text-primary q-mb-md q-mx-sm relative-position">
|
||||
<q-btn v-if="isCreate || changeAccount" :disable="!isConnectable" :loading="!!connectLoading" padding="xs md" :label="!!connectLoading ? '確認中...' : '接続確認'"
|
||||
color="primary" outline @click="tryConnect()"/>
|
||||
<q-btn v-if="!!connectLoading" label="停止" color="negative" flat class="q-ml-sm" @click="stopConnect" />
|
||||
<q-space />
|
||||
<q-btn :loading="addEditLoading" padding="xs md" label="保存" type="submit" color="primary" />
|
||||
<q-btn label="キャンセル" type="cancel" color="primary" flat class="q-ml-sm" @click="closeDg()" />
|
||||
</q-card-actions>
|
||||
</div>
|
||||
</q-form>
|
||||
</q-card>
|
||||
|
||||
@@ -187,12 +208,14 @@ const pagination = ref({ sortBy: 'id', descending: true, rowsPerPage: 20 });
|
||||
const loading = ref(false);
|
||||
const addEditLoading = ref(false);
|
||||
const deleteLoadingState = ref<number>(-1); // -2: deleteLoading, -1: loading, 0: allow, > 0: user count
|
||||
const connectLoading = ref<AbortController|null>(null);
|
||||
|
||||
const filter = ref('');
|
||||
const rows = ref<IDomainOwnerDisplay[]>([]);
|
||||
const show = ref(false);
|
||||
const confirm = ref(false);
|
||||
const resetPsw = ref(false);
|
||||
const changeAccount = ref(false);
|
||||
const testResult = ref<{msg: string, success?: boolean}|null>(null);
|
||||
|
||||
const currentDomainId = computed(() => authStore.currentDomain.id);
|
||||
// const tenantid = ref(authStore.currentDomain.id);
|
||||
@@ -200,8 +223,8 @@ const name = ref('');
|
||||
const url = ref('');
|
||||
const isPwd = ref(true);
|
||||
const kintoneuser = ref('');
|
||||
const kintoneuserBK = ref('');
|
||||
const kintonepwd = ref('');
|
||||
const kintonepwdBK = ref('');
|
||||
const domainActive = ref(true);
|
||||
const isCreate = ref(true);
|
||||
let editId = ref(0);
|
||||
@@ -316,19 +339,20 @@ function editRow(row: any) {
|
||||
name.value = row.name;
|
||||
url.value = row.url;
|
||||
kintoneuser.value = row.user;
|
||||
kintonepwd.value = row.password;
|
||||
kintoneuserBK.value = row.user;
|
||||
kintonepwd.value = ''
|
||||
domainActive.value = row.domainActive;
|
||||
isPwd.value = true;
|
||||
show.value = true;
|
||||
};
|
||||
|
||||
const updateResetPsw = (value: boolean) => {
|
||||
if (value === true) {
|
||||
kintonepwd.value = ''
|
||||
isPwd.value = true
|
||||
} else {
|
||||
kintonepwd.value = kintonepwdBK.value
|
||||
}
|
||||
const updateChangeAccount = () => {
|
||||
kintoneuser.value = kintoneuserBK.value;
|
||||
kintonepwd.value = ''
|
||||
connectLoading.value = null
|
||||
isPwd.value = true
|
||||
stopConnect();
|
||||
testResult.value = null;
|
||||
}
|
||||
|
||||
const closeDg = () => {
|
||||
@@ -336,8 +360,60 @@ const closeDg = () => {
|
||||
onReset();
|
||||
}
|
||||
|
||||
const onSubmit = () => {
|
||||
const tryConnect = async (isTest = true) => {
|
||||
testResult.value = null;
|
||||
if (isTest) {
|
||||
connectLoading.value = new AbortController();
|
||||
}
|
||||
try {
|
||||
const { data }: {data: {code: string, groups: {code: string}[]}} = await api.get('api/v1/group', {
|
||||
params:{
|
||||
kintoneurl: ensureHttps(url.value),
|
||||
kintoneuser: kintoneuser.value,
|
||||
kintonepwd: kintonepwd.value,
|
||||
},
|
||||
signal: (isTest && connectLoading.value) ? connectLoading.value.signal : undefined
|
||||
});
|
||||
if (data.code === 'CB_WA01') {
|
||||
testResult.value = { msg: 'ユーザーのパスワード認証に失敗しました。' }
|
||||
} else if (data.groups && data.groups.some((group: {code: string}) => group.code === 'Administrators')){
|
||||
testResult.value = { success: true, msg: isTest ? 'kintoneの管理者アカウントで接続に成功しました。' : '' }
|
||||
return true;
|
||||
} else {
|
||||
testResult.value = { msg: 'このアカウントはkintoneの管理者アカウントではありません。' }
|
||||
}
|
||||
return false;
|
||||
} catch (e) {
|
||||
const error = e as { code?: string };
|
||||
if (error.code === 'ERR_CANCELED') {
|
||||
console.log('Aborted');
|
||||
} else {
|
||||
testResult.value = { msg: 'サーバーに接続できませんでした。' }
|
||||
throw error;
|
||||
}
|
||||
return false;
|
||||
} finally {
|
||||
connectLoading.value = null;
|
||||
}
|
||||
}
|
||||
|
||||
const ensureHttps = (url: string) => {
|
||||
return !/^https?:\/\//i.test(url) ? 'https://' + url : url;
|
||||
}
|
||||
|
||||
const stopConnect = () => {
|
||||
if (!connectLoading.value) return;
|
||||
connectLoading.value?.abort();
|
||||
connectLoading.value = null;
|
||||
}
|
||||
|
||||
const onSubmit = async () => {
|
||||
addEditLoading.value = true;
|
||||
const tryResult = await tryConnect(false);
|
||||
if (!tryResult) {
|
||||
addEditLoading.value = false;
|
||||
return
|
||||
};
|
||||
const method = editId.value !== 0 ? 'put' : 'post';
|
||||
const param: IDomainSubmit = {
|
||||
'id': editId.value,
|
||||
@@ -345,7 +421,7 @@ const onSubmit = () => {
|
||||
'name': name.value,
|
||||
'url': url.value,
|
||||
'kintoneuser': kintoneuser.value,
|
||||
'kintonepwd': ((isCreate.value && editId.value == 0) || resetPsw.value) ? kintonepwd.value : '',
|
||||
'kintonepwd': ((isCreate.value && editId.value == 0) || changeAccount.value) ? kintonepwd.value : '',
|
||||
'is_active': domainActive.value,
|
||||
'ownerid': authStore.userId || ''
|
||||
}
|
||||
@@ -374,17 +450,24 @@ function openShareDg(type: typeof SHARE_MANAGE|typeof SHARE_USE, row: IDomainOwn
|
||||
}
|
||||
};
|
||||
|
||||
const isConnectable = computed(()=> {
|
||||
return url.value && kintoneuser.value && kintonepwd.value
|
||||
})
|
||||
|
||||
const onReset = () => {
|
||||
name.value = '';
|
||||
url.value = '';
|
||||
kintoneuser.value = '';
|
||||
kintoneuserBK.value = '';
|
||||
kintonepwd.value = '';
|
||||
isPwd.value = true;
|
||||
editId.value = 0;
|
||||
isCreate.value = true;
|
||||
domainActive.value = true;
|
||||
resetPsw.value = false
|
||||
changeAccount.value = false;
|
||||
addEditLoading.value = false;
|
||||
connectLoading.value = null
|
||||
testResult.value = null;
|
||||
}
|
||||
</script>
|
||||
<style lang="scss">
|
||||
|
||||
@@ -80,14 +80,14 @@
|
||||
|
||||
<q-input v-if="isCreate" v-model="pwd" filled :type="isPwd ? 'password' : 'text'" hint="パスワード"
|
||||
label="パスワード" :disable="!isCreate" lazy-rules
|
||||
:rules="[val => val && val.length > 0 || 'Please type something']" autocomplete="new-password">
|
||||
:rules="[val => val && val.length > 0 || 'パスワードを入力してください']" autocomplete="new-password">
|
||||
<template v-slot:append>
|
||||
<q-icon :name="isPwd ? 'visibility_off' : 'visibility'" class="cursor-pointer"
|
||||
@click="isPwd = !isPwd" />
|
||||
</template>
|
||||
</q-input>
|
||||
|
||||
<q-item tag="label" class="q-pl-sm q-pr-none q-py-xs">
|
||||
<q-item tag="label" v-if="authStore.isSuperAdmin" class="q-pl-sm q-pr-none q-py-xs">
|
||||
<q-item-section>
|
||||
<q-item-label>システム管理者</q-item-label>
|
||||
</q-item-section>
|
||||
@@ -118,7 +118,7 @@
|
||||
</q-item>
|
||||
|
||||
<q-input v-model="pwd" filled :type="isPwd ? 'password' : 'text'" hint="パスワードを入力してください" label="パスワード"
|
||||
:disable="!resetPsw" lazy-rules :rules="[val => val && val.length > 0 || 'Please type something']"
|
||||
:disable="!resetPsw" lazy-rules :rules="[val => val && val.length > 0 || 'パスワードを入力してください']"
|
||||
autocomplete="new-password">
|
||||
<template v-slot:append>
|
||||
<q-icon :name="isPwd ? 'visibility_off' : 'visibility'" class="cursor-pointer"
|
||||
@@ -131,7 +131,7 @@
|
||||
|
||||
</q-card-section>
|
||||
<q-card-actions align="right" class="text-primary q-mb-md q-mx-sm">
|
||||
<q-btn :loading="addEditLoading" label="保存" type="submit" color="primary" />
|
||||
<q-btn :loading="addEditLoading" padding="xs md" label="保存" type="submit" color="primary" />
|
||||
<q-btn label="キャンセル" type="cancel" color="primary" flat class="q-ml-sm" @click="closeDg()" />
|
||||
</q-card-actions>
|
||||
</q-form>
|
||||
@@ -160,10 +160,12 @@
|
||||
import { ref, onMounted, computed } from 'vue';
|
||||
import TableActionMenu from 'components/TableActionMenu.vue';
|
||||
import { useUserStore } from 'stores/useUserStore';
|
||||
import { useAuthStore } from 'stores/useAuthStore';
|
||||
import { IUserDisplay, IUserRolesDisplay } from 'src/types/UserTypes';
|
||||
import { Actions } from 'boot/permissions';
|
||||
|
||||
const userStore = useUserStore();
|
||||
const authStore = useAuthStore();
|
||||
|
||||
const columns = [
|
||||
{ name: 'id', label: 'ID', field: 'id', align: 'left', sortable: true },
|
||||
|
||||
Reference in New Issue
Block a user