fix: let only the owner set logout time and move the attendance tab

This commit is contained in:
2026-10-19 13:54:09 +03:30
parent 8590579605
commit f15ebb72ea
4 changed files with 8 additions and 8 deletions
+1 -1
View File
@@ -68,7 +68,7 @@ export class UsersController {
}
@Patch(':id/logout-time')
@Roles('owner', 'admin')
@Roles('owner')
updateLogoutTime(
@CurrentUser() user: { organizationId: string; role: UserRole },
@Param('id') id: string,
+2 -2
View File
@@ -249,8 +249,8 @@ export class UsersService {
targetId: string,
logoutTime: string | null,
): Promise<OrgUserDto> {
if (actorRole !== 'owner' && actorRole !== 'admin') {
throw new ForbiddenException('فقط مالک یا مدیر می‌تواند ساعت خروج را تعیین کند');
if (actorRole !== 'owner') {
throw new ForbiddenException('فقط مالک می‌تواند ساعت خروج را تعیین کند');
}
const target = await this.memberships.findUserInOrgById(organizationId, targetId);
if (!target) throw new NotFoundException('کاربر پیدا نشد');
+1 -1
View File
@@ -30,10 +30,10 @@ type LogTab = 'all' | 'creates' | 'edits' | 'deletes' | 'attendance';
const TABS: Array<{ key: LogTab; label: string; action?: string }> = [
{ key: 'all', label: 'همه' },
{ key: 'attendance', label: 'ورود و خروج' },
{ key: 'creates', label: 'ایجاد', action: 'ایجاد' },
{ key: 'edits', label: 'ویرایش', action: 'ویرایش' },
{ key: 'deletes', label: 'حذف', action: 'حذف' },
{ key: 'attendance', label: 'ورود و خروج' },
];
const ENTITY_LABELS: Record<string, string> = {
+4 -4
View File
@@ -129,6 +129,7 @@ const avatarUrls = ref<Record<string, string>>({});
const loadedAvatars = new Set<string>();
const canInvite = computed(() => canManageUsers(auth.user?.role));
const canSetLogoutTime = computed(() => auth.user?.role === 'owner');
const canEditOrg = computed(() => canManageSettings(auth.user?.role));
const canEditRoles = computed(() => canManageUsers(auth.user?.role));
/** مالک واقعی می‌تواند از جدول کاربران وارد مشاهده شود / برگردد */
@@ -493,7 +494,7 @@ async function toggleStatus(user: OrgUserDto) {
}
async function changeLogoutTime(user: OrgUserDto, raw: string) {
if (!canInvite.value || user.role === 'owner') return;
if (!canSetLogoutTime.value || user.role === 'owner') return;
const next = raw.trim();
if (next === (user.logoutTime ?? '')) return;
error.value = '';
@@ -997,7 +998,7 @@ onUnmounted(() => {
<span :class="{ flip: !sortLoginDesc }">▴</span>
</button>
</th>
<th>ساعت خروج</th>
<th v-if="canSetLogoutTime">ساعت خروج</th>
<th class="ops" />
</tr>
</thead>
@@ -1037,7 +1038,7 @@ onUnmounted(() => {
</span>
</td>
<td class="muted">{{ formatLastLogin(user.lastLoginAt) }}</td>
<td @click.stop>
<td v-if="canSetLogoutTime" @click.stop>
<span v-if="user.role === 'owner'" class="muted">—</span>
<input
v-else
@@ -1045,7 +1046,6 @@ onUnmounted(() => {
type="time"
dir="ltr"
:value="user.logoutTime || ''"
:disabled="!canInvite"
:aria-label="`ساعت خروج ${user.fullName}`"
@change="changeLogoutTime(user, ($event.target as HTMLInputElement).value)"
/>