Update Share Link

This commit is contained in:
Inga Kirschnick 2023-02-23 09:50:09 +01:00
parent 5881588160
commit a459d6607a
3 changed files with 14 additions and 8 deletions

View File

@ -78,11 +78,8 @@ def follow_corpus(corpus_id, token):
options={'require': ['exp', 'iat', 'iss']} options={'require': ['exp', 'iat', 'iss']}
) )
except jwt.PyJWTError: except jwt.PyJWTError:
abort(403) abort(410)
# permission = payload.get('sub') # permission = payload.get('sub')
expiration = payload.get('exp')
if expiration < int(datetime.utcnow().timestamp()):
abort(403)
if not current_user.is_following_corpus(corpus): if not current_user.is_following_corpus(corpus):
current_user.follow_corpus(corpus) current_user.follow_corpus(corpus)
db.session.commit() db.session.commit()

View File

@ -123,6 +123,7 @@ class CorpusDisplay extends RessourceDisplay {
let generateShareLinkButton = this.displayElement.querySelector('#generate-share-link-button'); let generateShareLinkButton = this.displayElement.querySelector('#generate-share-link-button');
let copyShareLinkButton = this.displayElement.querySelector('#copy-share-link-button'); let copyShareLinkButton = this.displayElement.querySelector('#copy-share-link-button');
let shareLinkInput = this.displayElement.querySelector('#share-link-input'); let shareLinkInput = this.displayElement.querySelector('#share-link-input');
let shareLinkContainer = this.displayElement.querySelector('#share-link-container');
// let permissionSelect = this.displayElement.querySelector('#permission-select'); // let permissionSelect = this.displayElement.querySelector('#permission-select');
let expirationDate = this.displayElement.querySelector('#expiration'); let expirationDate = this.displayElement.querySelector('#expiration');
@ -131,7 +132,7 @@ class CorpusDisplay extends RessourceDisplay {
// Utils.generateCorpusShareLinkRequest(`${this.corpusId}`, permissionSelect.value, expirationDate.value) // Utils.generateCorpusShareLinkRequest(`${this.corpusId}`, permissionSelect.value, expirationDate.value)
Utils.generateCorpusShareLinkRequest(`${this.corpusId}`, expirationDate.value) Utils.generateCorpusShareLinkRequest(`${this.corpusId}`, expirationDate.value)
.then((shareLink) => { .then((shareLink) => {
shareLinkInput.parentElement.classList.remove('hide'); shareLinkContainer.classList.remove('hide');
shareLinkInput.value = shareLink; shareLinkInput.value = shareLink;
}); });
}); });

View File

@ -119,10 +119,18 @@
<div class="row"> <div class="row">
<div class="col s12"> <div class="col s12">
<a class="action-button btn waves-effect waves-light" id="generate-share-link-button">Generate Share Link</a> <a class="action-button btn waves-effect waves-light" id="generate-share-link-button">Generate Share Link</a>
<div class="hide"> </div>
<input id="share-link-input" readonly> <div class="col s12 hide" id="share-link-container">
<p></p>
<br>
<div class="row">
<div class="col s1">
<a class="action-button btn-small waves-effect waves-light" id="copy-share-link-button">Copy</a> <a class="action-button btn-small waves-effect waves-light" id="copy-share-link-button">Copy</a>
</div> </div>
<div class="col s11">
<input id="share-link-input" readonly>
</div>
</div>
</div> </div>
</div> </div>
</div> </div>