Skip to content

Commit

Permalink
item.routes: Allow requiring valid sesion when polling document view …
Browse files Browse the repository at this point in the history
…info

Fixes a bug where goto-link reports missing rights when a student actually does not have a valid session.
  • Loading branch information
dezhidki committed May 23, 2024
1 parent f9a8f0b commit 8b5cf09
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 4 deletions.
6 changes: 3 additions & 3 deletions timApp/item/routes.py
Original file line number Diff line number Diff line change
Expand Up @@ -290,17 +290,17 @@ def par_info(doc_id, par_id):


@view_page.get("/docViewInfo/<path:doc_name>")
def doc_access_info(doc_name):
def doc_access_info(doc_name: str, require_valid_session: bool = True):
doc_info = DocEntry.find_by_path(doc_name, fallback_to_id=True)
if not doc_info:
raise NotExist()

cur_user = get_current_user_object()
user_message = get_user_global_message(cur_user)

# If there is no valid session, just send out the global message
# If there is no valid session, but we don't require one, just send out the global message
# This allows sending global messages even if there is no valid session
if not has_valid_session(cur_user):
if not require_valid_session and not has_valid_session(cur_user):
return json_response(
{
"can_access": False,
Expand Down
6 changes: 5 additions & 1 deletion timApp/static/scripts/tim/document/viewctrl.ts
Original file line number Diff line number Diff line change
Expand Up @@ -474,7 +474,11 @@ export class ViewCtrl implements IController {
// Check against statePollInterval to allow stopping the polling
while (this.docViewInfoPollInterval) {
const r = await to(
$http.get<IDocumentViewInfoStatus>(`/docViewInfo/${docPath}`)
$http.get<IDocumentViewInfoStatus>(`/docViewInfo/${docPath}`, {
params: {
require_valid_session: false,
},
})
);

if (r.ok) {
Expand Down

0 comments on commit 8b5cf09

Please sign in to comment.