Skip to content

Commit

Permalink
🚸 Add a link to web view
Browse files Browse the repository at this point in the history
Allowing usage of the password into a subsystem which target human
  • Loading branch information
XREvo committed Mar 30, 2024
1 parent b692904 commit e480397
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 4 deletions.
4 changes: 3 additions & 1 deletion README.rst
Original file line number Diff line number Diff line change
Expand Up @@ -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
}
Expand Down
9 changes: 6 additions & 3 deletions snappass/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
}
Expand Down

0 comments on commit e480397

Please sign in to comment.