Fixed room owner bug in /delete

This commit is contained in:
Stranck 2024-01-13 14:58:06 +01:00
parent 0af0849f13
commit c82d075913
4 changed files with 6 additions and 4 deletions

2
ext.py
View File

@ -119,7 +119,7 @@ class Order:
self.pending_room = self.ans('pending_room')
self.pending_roommates = self.ans('pending_roommates').split(',') if self.ans('pending_roommates') else []
self.room_members = self.ans('room_members').split(',') if self.ans('room_members') else []
self.room_owner = (self.code == self.room_id)
self.room_owner = (self.code is not None and self.room_id is not None and self.code.strip() == self.room_id.strip())
self.room_secret = self.ans('room_secret')
self.app_token = self.ans('app_token')
self.nfc_id = self.ans('nfc_id')

View File

@ -7,7 +7,8 @@ function confirmAction (intent, sender) {
let intentFormAction = document.querySelector("#intentFormAction")
let intentSend = document.querySelector("#intentSend")
// Resetting ui
intentEdit.setAttribute('required', false)
intentEdit.removeAttribute('required')
intentEdit.removeAttribute('minlength')
intentFormAction.setAttribute('method', 'GET')
intentEditPanel.style.display = 'none';
@ -17,6 +18,7 @@ function confirmAction (intent, sender) {
case 'rename':
intentEditPanel.style.display = 'block';
intentEdit.setAttribute('required', true)
intentEdit.setAttribute('minlength', 4)
intentFormAction.setAttribute('method', 'POST')
document.getElementById("intentRename").value = sender.parentElement.parentElement.querySelector("span").innerText;
break

View File

@ -49,7 +49,7 @@ async def delete_room(request, order: Order):
if not order:
raise exceptions.Forbidden("You have been logged out. Please access the link in your E-Mail to login again!")
if order.room_owner:
if not order.room_owner:
raise exceptions.BadRequest("You are not allowed to delete room of others.")
if order.ans('room_confirmed'):

View File

@ -114,7 +114,7 @@
<p id="intentDescription"></p>
<div id="intentEditPanel">
<label for="name">Enter a new room name</label>
<input id="intentRename" name="name" type="text" value="" minlength="4" maxlength="64"/>
<input id="intentRename" name="name" type="text" value="" maxlength="64"/>
</div>
<footer>
<input id="intentSend" type="submit" value="Confirm" />