🚸 Add a link to web view

Allowing usage of the password into a subsystem which target human
This commit is contained in:
Emilien GUILMINEAU 2024-03-30 20:47:03 +01:00
parent b69290425a
commit e4803977c0
2 changed files with 9 additions and 4 deletions

View file

@ -151,11 +151,13 @@ This will return a JSON response with a token and the password link:
::
{
"token": "snappassbedf19b161794fd288faec3eba15fa41~hHnILpQ50ZfJc3nurDfHCb_22rBr5gGEya68e_cZOrY%3D",
"token": "snappassbedf19b161794fd288faec3eba15fa41~hHnILpQ50ZfJc3nurDfHCb_22rBr5gGEya68e_cZOrY=",
"links": [{
"rel": "self",
"href": "http://127.0.0.1:5000/api/v2/passwords/snappassbedf19b161794fd288faec3eba15fa41~hHnILpQ50ZfJc3nurDfHCb_22rBr5gGEya68e_cZOrY%3D",
},{
"rel": "web-view",
"href": "http://127.0.0.1:5000/snappassbedf19b161794fd288faec3eba15fa41~hHnILpQ50ZfJc3nurDfHCb_22rBr5gGEya68e_cZOrY%3D",
}],
"ttl":1209600
}

View file

@ -282,13 +282,16 @@ def api_v2_set_password():
token = set_password(password, ttl)
url_token = quote_plus(token)
base_url = set_base_url(request)
link = urljoin(base_url, request.path + "/" + url_token)
api_link = urljoin(base_url, request.path + "/" + url_token)
web_link = urljoin(base_url, url_token)
response_content = {
"token": url_token,
"token": token,
"links": [{
"rel": "self",
"href": link
"href": api_link
}, {
"rel": "web-view",
"href": web_link
}],
"ttl": ttl
}