SigTools icon indicating copy to clipboard operation
SigTools copied to clipboard

Skip logged-in user for sending emails

Open fabiodrg opened this issue 4 years ago • 0 comments

Motivation

No, I don't want to email myself :smile:

image

Testing if a user is logged in?

document.querySelector('a.nomelogin')

If null, it is not. Otherwise, the returned element will be <a>. Get the href attribute and parse the query parameter pct_id=<other_id>. The complete URL looks like this: https://sigarra.up.pt/feup/pt/vld_entidades_geral.entidade_pagina?pct_id=<other_id> image

Getting the real user-id

For whatever reason, the ID used in the logged in user does not match the actual user identifier. It will be necessary to make a GET request for that hyperlink. The response is actually a redirect, notice the <meta http-equiv="Refresh">:

For students:

<html><head>
<meta http-equiv="Refresh" content="0;url=https://sigarra.up.pt/feup/pt/fest_geral.cursos_list?pv_num_unico=<id>">
<meta HTTP-EQUIV="Pragma" content="no-cache">
<meta name="ROBOTS" content="NOINDEX">

<a href="https://sigarra.up.pt/feup/pt/fest_geral.cursos_list?pv_num_unico=<id>"></a>
</head><body></body></html>

For staff:

<html><head>
<meta http-equiv="Refresh" content="0;url=https://sigarra.up.pt/feup/pt/func_geral.formview?p_codigo=<id>">
<meta HTTP-EQUIV="Pragma" content="no-cache">
<meta name="ROBOTS" content="NOINDEX">

<a href="https://sigarra.up.pt/feup/pt/func_geral.formview?p_codigo=<id>"></a>
</head><body></body></html>

Given the response, perhaps use the DOMParser and then make a query selector for <a> and parse the href.

Caching

It will be helpful to store a mapping of other_id to id to prevent requests on every new page load.

fabiodrg avatar Apr 01 '22 08:04 fabiodrg