File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -9,6 +9,7 @@ defineProps<{
99 users: User [];
1010 bannedUsers? : BannedUser [];
1111 canModerate? : boolean ;
12+ ownerId? : string ;
1213}>();
1314
1415const emit = defineEmits <{
@@ -83,7 +84,14 @@ const handleUnban = async (userId: string) => {
8384
8485 <div v-if =" canModerate && user.id !== userStore.id" class =" mod-actions" >
8586 <button class =" mod-btn kick" @click =" handleKick(user.id)" title =" Kick User" >K</button >
86- <button class =" mod-btn ban" @click =" handleBan(user.id)" title =" Ban User" >B</button >
87+ <button
88+ v-if =" user.id !== ownerId && !user.isAdmin"
89+ class =" mod-btn ban"
90+ @click =" handleBan(user.id)"
91+ title =" Ban User"
92+ >
93+ B
94+ </button >
8795 </div >
8896 </li >
8997 </ul >
Original file line number Diff line number Diff line change @@ -6,6 +6,7 @@ import { DISCONNECT_REASONS } from '../constants/disconnect.constants';
66export interface User {
77 id : string ;
88 username : string ;
9+ isAdmin ?: boolean ;
910}
1011
1112export const useLobbyStore = defineStore ( 'lobby' , ( ) => {
Original file line number Diff line number Diff line change @@ -277,6 +277,7 @@ onUnmounted(() => {
277277 :users =" users"
278278 :banned-users =" bannedUsers"
279279 :can-moderate =" hasLobbyPermissions"
280+ :owner-id =" lobbyOwnerId"
280281 @kick =" handleKickUser"
281282 @ban =" handleBanUser"
282283 @unban =" handleUnbanUser"
Original file line number Diff line number Diff line change @@ -185,6 +185,19 @@ export class LobbyController {
185185 }
186186
187187 // Persist Ban
188+ const targetUser = await import ( '../models/User.js' ) . then ( m => m . User . findById ( targetUserId ) ) ;
189+
190+ if ( ! targetUser ) {
191+ throw new AppError ( 'User not found' , 404 ) ;
192+ }
193+
194+ const isOwner = lobby . owner && ( lobby . owner . toString ( ) === targetUserId || ( lobby . owner as any ) . _id ?. toString ( ) === targetUserId ) ;
195+ const isAdmin = targetUser . isAdmin ;
196+
197+ if ( isOwner || isAdmin ) {
198+ throw new AppError ( 'Cannot ban lobby owner or admin' , 403 ) ;
199+ }
200+
188201 await LobbyService . banUser ( id , targetUserId ) ;
189202 console . log ( `[Lobby] Banning user ${ targetUserId } from ${ id } ` ) ;
190203
You can’t perform that action at this time.
0 commit comments