fix admin
This commit is contained in:
@@ -232,8 +232,38 @@ const onDeploy = async () => {
|
|||||||
});
|
});
|
||||||
return;
|
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 {
|
try {
|
||||||
deployLoading.value = true;
|
|
||||||
await store.deploy();
|
await store.deploy();
|
||||||
deployLoading.value = false;
|
deployLoading.value = false;
|
||||||
$q.notify({
|
$q.notify({
|
||||||
|
|||||||
@@ -53,21 +53,21 @@
|
|||||||
<div class="text-h6 q-ma-sm">Kintone Account</div>
|
<div class="text-h6 q-ma-sm">Kintone Account</div>
|
||||||
</q-card-section>
|
</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">
|
<div class="q-gutter-lg">
|
||||||
|
|
||||||
<q-input filled v-model="name" label="環境名 *" hint="kintoneの環境名を入力してください" lazy-rules
|
<q-input filled v-model="name" label="環境名 *" hint="kintoneの環境名を入力してください" lazy-rules
|
||||||
:rules="[val => val && val.length > 0 || 'kintoneの環境名を入力してください。']" />
|
: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を入力してください']" />
|
: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" />
|
:rules="[val => val && val.length > 0 || 'Kintoneのログイン名を入力してください']" autocomplete="new-password" />
|
||||||
|
|
||||||
<q-input v-if="isCreate" v-model="kintonepwd" filled :type="isPwd ? 'password' : 'text'"
|
<q-input v-if="isCreate" v-model="kintonepwd" filled :type="isPwd ? 'password' : 'text'"
|
||||||
hint="パスワード" label="パスワード" :disable="!isCreate" lazy-rules
|
hint="Kintoneのパスワードを入力してください" label="パスワード" :disable="!isCreate" lazy-rules
|
||||||
:rules="[val => val && val.length > 0 || 'Please type something']" autocomplete="new-password">
|
:rules="[val => val && val.length > 0 || 'Kintoneのパスワードを入力してください']" autocomplete="new-password">
|
||||||
<template v-slot:append>
|
<template v-slot:append>
|
||||||
<q-icon :name="isPwd ? 'visibility_off' : 'visibility'" class="cursor-pointer"
|
<q-icon :name="isPwd ? 'visibility_off' : 'visibility'" class="cursor-pointer"
|
||||||
@click="isPwd = !isPwd" />
|
@click="isPwd = !isPwd" />
|
||||||
@@ -88,30 +88,51 @@
|
|||||||
|
|
||||||
<q-item tag="label" class="q-pl-sm q-pr-none q-py-xs">
|
<q-item tag="label" class="q-pl-sm q-pr-none q-py-xs">
|
||||||
<q-item-section>
|
<q-item-section>
|
||||||
<q-item-label>パスワードリセット</q-item-label>
|
<q-item-label>管理者アカウントの変更</q-item-label>
|
||||||
</q-item-section>
|
</q-item-section>
|
||||||
<q-item-section avatar>
|
<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-section>
|
||||||
</q-item>
|
</q-item>
|
||||||
|
|
||||||
<q-input v-model="kintonepwd" filled :type="isPwd ? 'password' : 'text'" hint="パスワードを入力してください"
|
<q-expansion-item
|
||||||
label="パスワード" :disable="!resetPsw" lazy-rules
|
header-class="hidden"
|
||||||
:rules="[val => val && val.length > 0 || 'Please type something']" autocomplete="new-password">
|
class="q-mt-none"
|
||||||
<template v-slot:append>
|
v-model="changeAccount"
|
||||||
<q-icon :name="isPwd ? 'visibility_off' : 'visibility'" class="cursor-pointer"
|
>
|
||||||
@click="isPwd = !isPwd" />
|
<q-input filled v-model="kintoneuser" label="ログイン名 *" hint="Kintoneのログイン名を入力してください" :disable="!changeAccount"
|
||||||
</template>
|
:rules="[val => val && val.length > 0 || 'Kintoneのログイン名を入力してください']" lazy-rules class="q-mt-md"/>
|
||||||
</q-input>
|
|
||||||
<!-- <q-btn label="asdf"/> -->
|
<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>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
</q-card-section>
|
</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" />
|
<div class="q-mt-none">
|
||||||
<q-btn label="キャンセル" type="cancel" color="primary" flat class="q-ml-sm" @click="closeDg()" />
|
<q-banner dense :class="['text-white q-mt-sm q-py-xs q-mx-md', testResult?.success ? 'bg-green':'bg-red', testResult?.msg ? '':'invisible']">
|
||||||
</q-card-actions>
|
{{ 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-form>
|
||||||
</q-card>
|
</q-card>
|
||||||
|
|
||||||
@@ -187,12 +208,14 @@ const pagination = ref({ sortBy: 'id', descending: true, rowsPerPage: 20 });
|
|||||||
const loading = ref(false);
|
const loading = ref(false);
|
||||||
const addEditLoading = ref(false);
|
const addEditLoading = ref(false);
|
||||||
const deleteLoadingState = ref<number>(-1); // -2: deleteLoading, -1: loading, 0: allow, > 0: user count
|
const deleteLoadingState = ref<number>(-1); // -2: deleteLoading, -1: loading, 0: allow, > 0: user count
|
||||||
|
const connectLoading = ref<AbortController|null>(null);
|
||||||
|
|
||||||
const filter = ref('');
|
const filter = ref('');
|
||||||
const rows = ref<IDomainOwnerDisplay[]>([]);
|
const rows = ref<IDomainOwnerDisplay[]>([]);
|
||||||
const show = ref(false);
|
const show = ref(false);
|
||||||
const confirm = 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 currentDomainId = computed(() => authStore.currentDomain.id);
|
||||||
// const tenantid = ref(authStore.currentDomain.id);
|
// const tenantid = ref(authStore.currentDomain.id);
|
||||||
@@ -200,8 +223,8 @@ const name = ref('');
|
|||||||
const url = ref('');
|
const url = ref('');
|
||||||
const isPwd = ref(true);
|
const isPwd = ref(true);
|
||||||
const kintoneuser = ref('');
|
const kintoneuser = ref('');
|
||||||
|
const kintoneuserBK = ref('');
|
||||||
const kintonepwd = ref('');
|
const kintonepwd = ref('');
|
||||||
const kintonepwdBK = ref('');
|
|
||||||
const domainActive = ref(true);
|
const domainActive = ref(true);
|
||||||
const isCreate = ref(true);
|
const isCreate = ref(true);
|
||||||
let editId = ref(0);
|
let editId = ref(0);
|
||||||
@@ -316,19 +339,20 @@ function editRow(row: any) {
|
|||||||
name.value = row.name;
|
name.value = row.name;
|
||||||
url.value = row.url;
|
url.value = row.url;
|
||||||
kintoneuser.value = row.user;
|
kintoneuser.value = row.user;
|
||||||
kintonepwd.value = row.password;
|
kintoneuserBK.value = row.user;
|
||||||
|
kintonepwd.value = ''
|
||||||
domainActive.value = row.domainActive;
|
domainActive.value = row.domainActive;
|
||||||
isPwd.value = true;
|
isPwd.value = true;
|
||||||
show.value = true;
|
show.value = true;
|
||||||
};
|
};
|
||||||
|
|
||||||
const updateResetPsw = (value: boolean) => {
|
const updateChangeAccount = () => {
|
||||||
if (value === true) {
|
kintoneuser.value = kintoneuserBK.value;
|
||||||
kintonepwd.value = ''
|
kintonepwd.value = ''
|
||||||
isPwd.value = true
|
connectLoading.value = null
|
||||||
} else {
|
isPwd.value = true
|
||||||
kintonepwd.value = kintonepwdBK.value
|
stopConnect();
|
||||||
}
|
testResult.value = null;
|
||||||
}
|
}
|
||||||
|
|
||||||
const closeDg = () => {
|
const closeDg = () => {
|
||||||
@@ -336,8 +360,60 @@ const closeDg = () => {
|
|||||||
onReset();
|
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;
|
addEditLoading.value = true;
|
||||||
|
const tryResult = await tryConnect(false);
|
||||||
|
if (!tryResult) {
|
||||||
|
addEditLoading.value = false;
|
||||||
|
return
|
||||||
|
};
|
||||||
const method = editId.value !== 0 ? 'put' : 'post';
|
const method = editId.value !== 0 ? 'put' : 'post';
|
||||||
const param: IDomainSubmit = {
|
const param: IDomainSubmit = {
|
||||||
'id': editId.value,
|
'id': editId.value,
|
||||||
@@ -345,7 +421,7 @@ const onSubmit = () => {
|
|||||||
'name': name.value,
|
'name': name.value,
|
||||||
'url': url.value,
|
'url': url.value,
|
||||||
'kintoneuser': kintoneuser.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,
|
'is_active': domainActive.value,
|
||||||
'ownerid': authStore.userId || ''
|
'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 = () => {
|
const onReset = () => {
|
||||||
name.value = '';
|
name.value = '';
|
||||||
url.value = '';
|
url.value = '';
|
||||||
kintoneuser.value = '';
|
kintoneuser.value = '';
|
||||||
|
kintoneuserBK.value = '';
|
||||||
kintonepwd.value = '';
|
kintonepwd.value = '';
|
||||||
isPwd.value = true;
|
isPwd.value = true;
|
||||||
editId.value = 0;
|
editId.value = 0;
|
||||||
isCreate.value = true;
|
isCreate.value = true;
|
||||||
domainActive.value = true;
|
domainActive.value = true;
|
||||||
resetPsw.value = false
|
changeAccount.value = false;
|
||||||
addEditLoading.value = false;
|
addEditLoading.value = false;
|
||||||
|
connectLoading.value = null
|
||||||
|
testResult.value = null;
|
||||||
}
|
}
|
||||||
</script>
|
</script>
|
||||||
<style lang="scss">
|
<style lang="scss">
|
||||||
|
|||||||
@@ -80,14 +80,14 @@
|
|||||||
|
|
||||||
<q-input v-if="isCreate" v-model="pwd" filled :type="isPwd ? 'password' : 'text'" hint="パスワード"
|
<q-input v-if="isCreate" v-model="pwd" filled :type="isPwd ? 'password' : 'text'" hint="パスワード"
|
||||||
label="パスワード" :disable="!isCreate" lazy-rules
|
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>
|
<template v-slot:append>
|
||||||
<q-icon :name="isPwd ? 'visibility_off' : 'visibility'" class="cursor-pointer"
|
<q-icon :name="isPwd ? 'visibility_off' : 'visibility'" class="cursor-pointer"
|
||||||
@click="isPwd = !isPwd" />
|
@click="isPwd = !isPwd" />
|
||||||
</template>
|
</template>
|
||||||
</q-input>
|
</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-section>
|
||||||
<q-item-label>システム管理者</q-item-label>
|
<q-item-label>システム管理者</q-item-label>
|
||||||
</q-item-section>
|
</q-item-section>
|
||||||
@@ -118,7 +118,7 @@
|
|||||||
</q-item>
|
</q-item>
|
||||||
|
|
||||||
<q-input v-model="pwd" filled :type="isPwd ? 'password' : 'text'" hint="パスワードを入力してください" label="パスワード"
|
<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">
|
autocomplete="new-password">
|
||||||
<template v-slot:append>
|
<template v-slot:append>
|
||||||
<q-icon :name="isPwd ? 'visibility_off' : 'visibility'" class="cursor-pointer"
|
<q-icon :name="isPwd ? 'visibility_off' : 'visibility'" class="cursor-pointer"
|
||||||
@@ -131,7 +131,7 @@
|
|||||||
|
|
||||||
</q-card-section>
|
</q-card-section>
|
||||||
<q-card-actions align="right" class="text-primary q-mb-md q-mx-sm">
|
<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-btn label="キャンセル" type="cancel" color="primary" flat class="q-ml-sm" @click="closeDg()" />
|
||||||
</q-card-actions>
|
</q-card-actions>
|
||||||
</q-form>
|
</q-form>
|
||||||
@@ -160,10 +160,12 @@
|
|||||||
import { ref, onMounted, computed } from 'vue';
|
import { ref, onMounted, computed } from 'vue';
|
||||||
import TableActionMenu from 'components/TableActionMenu.vue';
|
import TableActionMenu from 'components/TableActionMenu.vue';
|
||||||
import { useUserStore } from 'stores/useUserStore';
|
import { useUserStore } from 'stores/useUserStore';
|
||||||
|
import { useAuthStore } from 'stores/useAuthStore';
|
||||||
import { IUserDisplay, IUserRolesDisplay } from 'src/types/UserTypes';
|
import { IUserDisplay, IUserRolesDisplay } from 'src/types/UserTypes';
|
||||||
import { Actions } from 'boot/permissions';
|
import { Actions } from 'boot/permissions';
|
||||||
|
|
||||||
const userStore = useUserStore();
|
const userStore = useUserStore();
|
||||||
|
const authStore = useAuthStore();
|
||||||
|
|
||||||
const columns = [
|
const columns = [
|
||||||
{ name: 'id', label: 'ID', field: 'id', align: 'left', sortable: true },
|
{ name: 'id', label: 'ID', field: 'id', align: 'left', sortable: true },
|
||||||
|
|||||||
Reference in New Issue
Block a user