Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 11 additions & 0 deletions src/router/profile.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import apiClient from '@/api';
import { RouteRecordRaw } from 'vue-router';

export const profileRoutes: RouteRecordRaw[] = [
Expand All @@ -12,6 +13,16 @@ export const profileRoutes: RouteRecordRaw[] = [
{
path: ':id(\\d+)',
component: () => import('@/views/profile/ProfileView.vue'),
beforeEnter: async to => {
const { response } = await apiClient.GET('/auth/user/{user_id}', {
params: { path: { user_id: Number(to.params.id) } },
});
if (response.ok) {
return true;
} else {
return { path: '/error' };
}
},
},
// Раскомментируйте, если починили; удалите, если решили дропнуть
// {
Expand Down
4 changes: 2 additions & 2 deletions src/views/admin/AdminView.vue
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ onMounted(() => {

<template>
<IrdomLayout>
<h3>Информаця о пользователе</h3>
<h3>Информация о пользователе</h3>
<div class="info">
<h4>Ваш id: {{ profileStore.id }}</h4>
<h4>Токен:</h4>
Expand Down Expand Up @@ -83,7 +83,7 @@ onMounted(() => {
</v-btn>
</div>

<h3>Инструменты администратора</h3>
<h3 v-if="profileStore.hasTokenAccess('webapp.admin.show')">Инструменты администратора</h3>

<AccessRestricted :scope="scopename.auth.group.create">
<RouterLink to="/admin/groups" class="link">Группы пользователей</RouterLink>
Expand Down
16 changes: 9 additions & 7 deletions src/views/apps/ApplicationFrame.vue
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
<script setup lang="ts">
import { Ref, onMounted, ref, watch } from 'vue';
import { Ref, onMounted, ref } from 'vue';
import { useRoute, useRouter } from 'vue-router';
import { useToolbar } from '@/store/toolbar';
import { useProfileStore } from '@/store/profile';
Expand Down Expand Up @@ -27,7 +27,7 @@ const appState = ref(AppState.WaitLoad);
const scopes: Ref<string[]> = ref([]);

const scopeNamesToRequest: Ref<string[]> = ref([]);
const userScopeApproved: Ref<boolean | undefined> = ref();
// const userScopeApproved: Ref<boolean | undefined> = ref();

toolbar.setup({
backUrl: '/apps',
Expand All @@ -50,9 +50,10 @@ const composeUrl = async (url: URL, token: string | null, scopes: string[]) => {
function showApproveScopesScreen() {
appState.value = AppState.WaitApprove;
// immediately return a Promise
return new Promise(resolve => {
watch(userScopeApproved, value => resolve(value));
});
// return new Promise(resolve => {
// watch(userScopeApproved, value => resolve(value));
// });
return true;
}

const getToken = async () => {
Expand Down Expand Up @@ -169,15 +170,16 @@ onMounted(async () => {
allow="camera"
/>
<FullscreenLoader v-else-if="appState == AppState.WaitLoad" />
<div v-else-if="appState == AppState.WaitApprove" class="deligate-container">
<!-- Раскомментить, если появятся приложения от сторонних разработчиков -->
<!-- <div v-else-if="appState == AppState.WaitApprove" class="deligate-container">
<h2>Приложение запрашивает права на доступ к вашему аккаунту</h2>
<p>Для работы будут делегированы следующие права:</p>
<ul>
<li v-for="(scope, i) in scopeNamesToRequest" :key="i">{{ scope }}</li>
</ul>
<v-btn color="primary" @click="userScopeApproved = true">Разрешить</v-btn>
<v-btn variant="plain" @click="userScopeApproved = false">Запретить</v-btn>
</div>
</div> -->
<div v-else-if="appState == AppState.Blocked" class="exception-container">
<h2>У вас недостаточно прав для использования этого приложения</h2>
<v-btn @click="router.push('/apps')">Вернуться к списку приложений</v-btn>
Expand Down
3 changes: 2 additions & 1 deletion src/views/profile/ProfileEditAuthView.vue
Original file line number Diff line number Diff line change
Expand Up @@ -40,13 +40,14 @@ const canUnlinked = computed(() =>
</div>
</section>

<section v-if="profileStore.authMethods && profileStore.authMethods.length > 1" class="section">
<section v-if="profileStore.authMethods && profileStore.authMethods.length > 0" class="section">
<h2>Отвязать аккаунт</h2>
<div class="buttons">
<IrdomAuthButton
v-for="button of canUnlinked"
:key="button.method"
:button="button"
:disabled="profileStore.authMethods.length === 1"
unlink
/>
</div>
Expand Down
Loading