fix: anyone_can_start not working as Admin
Build & Push Docker Image / build (push) Successful in 4m24s
Build & Push Docker Image / build (push) Successful in 4m24s
This commit is contained in:
@@ -485,9 +485,10 @@ router.post('/:uid/start', authenticateToken, async (req, res) => {
|
|||||||
return res.status(404).json({ error: 'Room not found' });
|
return res.status(404).json({ error: 'Room not found' });
|
||||||
}
|
}
|
||||||
|
|
||||||
// Check access: owner or shared
|
// Check access: owner, admin, shared, or anyone_can_start
|
||||||
const isOwner = room.user_id === req.user.id;
|
const isOwner = room.user_id === req.user.id;
|
||||||
if (!isOwner) {
|
const isAdmin = req.user.role === 'admin';
|
||||||
|
if (!isOwner && !isAdmin && !room.anyone_can_start) {
|
||||||
const share = await db.get('SELECT id FROM room_shares WHERE room_id = ? AND user_id = ?', [room.id, req.user.id]);
|
const share = await db.get('SELECT id FROM room_shares WHERE room_id = ? AND user_id = ?', [room.id, req.user.id]);
|
||||||
if (!share) {
|
if (!share) {
|
||||||
return res.status(403).json({ error: 'No permission' });
|
return res.status(403).json({ error: 'No permission' });
|
||||||
@@ -559,9 +560,10 @@ router.post('/:uid/end', authenticateToken, async (req, res) => {
|
|||||||
return res.status(404).json({ error: 'Room not found' });
|
return res.status(404).json({ error: 'Room not found' });
|
||||||
}
|
}
|
||||||
|
|
||||||
// Check access: owner or shared user
|
// Check access: owner, admin, or shared user
|
||||||
const isOwner = room.user_id === req.user.id;
|
const isOwner = room.user_id === req.user.id;
|
||||||
if (!isOwner) {
|
const isAdmin = req.user.role === 'admin';
|
||||||
|
if (!isOwner && !isAdmin) {
|
||||||
const share = await db.get('SELECT id FROM room_shares WHERE room_id = ? AND user_id = ?', [room.id, req.user.id]);
|
const share = await db.get('SELECT id FROM room_shares WHERE room_id = ? AND user_id = ?', [room.id, req.user.id]);
|
||||||
if (!share) {
|
if (!share) {
|
||||||
return res.status(403).json({ error: 'No permission' });
|
return res.status(403).json({ error: 'No permission' });
|
||||||
|
|||||||
@@ -62,7 +62,10 @@ export default function RoomDetail() {
|
|||||||
|
|
||||||
const isOwner = room && user && room.user_id === user.id;
|
const isOwner = room && user && room.user_id === user.id;
|
||||||
const isShared = room && !!room.shared;
|
const isShared = room && !!room.shared;
|
||||||
|
const isAdmin = user?.role === 'admin';
|
||||||
const canManage = isOwner || isShared;
|
const canManage = isOwner || isShared;
|
||||||
|
const canStart = canManage || isAdmin || !!room?.anyone_can_start;
|
||||||
|
const canEnd = canManage || isAdmin;
|
||||||
|
|
||||||
const fetchRoom = async () => {
|
const fetchRoom = async () => {
|
||||||
try {
|
try {
|
||||||
@@ -452,7 +455,7 @@ export default function RoomDetail() {
|
|||||||
<span className="hidden sm:inline">{t('federation.inviteRemote')}</span>
|
<span className="hidden sm:inline">{t('federation.inviteRemote')}</span>
|
||||||
</button>
|
</button>
|
||||||
)}
|
)}
|
||||||
{canManage && !status.running && !waitingToJoin && (
|
{canStart && !status.running && !waitingToJoin && (
|
||||||
<button onClick={handleStart} disabled={actionLoading === 'start'} className="btn-primary">
|
<button onClick={handleStart} disabled={actionLoading === 'start'} className="btn-primary">
|
||||||
{actionLoading === 'start' ? <Loader2 size={16} className="animate-spin" /> : <Play size={16} />}
|
{actionLoading === 'start' ? <Loader2 size={16} className="animate-spin" /> : <Play size={16} />}
|
||||||
{t('room.start')}
|
{t('room.start')}
|
||||||
@@ -467,7 +470,7 @@ export default function RoomDetail() {
|
|||||||
{(actionLoading === 'join' || waitingToJoin) ? <Loader2 size={16} className="animate-spin" /> : <ExternalLink size={16} />}
|
{(actionLoading === 'join' || waitingToJoin) ? <Loader2 size={16} className="animate-spin" /> : <ExternalLink size={16} />}
|
||||||
{waitingToJoin ? t('room.waitingToJoin') : t('room.join')}
|
{waitingToJoin ? t('room.waitingToJoin') : t('room.join')}
|
||||||
</button>
|
</button>
|
||||||
{canManage && status.running && (
|
{canEnd && status.running && (
|
||||||
<button onClick={handleEnd} disabled={actionLoading === 'end'} className="btn-danger">
|
<button onClick={handleEnd} disabled={actionLoading === 'end'} className="btn-danger">
|
||||||
{actionLoading === 'end' ? <Loader2 size={16} className="animate-spin" /> : <Square size={16} />}
|
{actionLoading === 'end' ? <Loader2 size={16} className="animate-spin" /> : <Square size={16} />}
|
||||||
{t('room.end')}
|
{t('room.end')}
|
||||||
|
|||||||
Reference in New Issue
Block a user