Skip to content

Commit

Permalink
Shows password expiration time in the Share menu
Browse files Browse the repository at this point in the history
Signed-off-by: Cyrille Bollu <cyrpub@bollu.be>
  • Loading branch information
StCyr committed Apr 15, 2022
1 parent f0284c7 commit 619d1fa
Show file tree
Hide file tree
Showing 3 changed files with 32 additions and 1 deletion.
2 changes: 1 addition & 1 deletion apps/files_sharing/lib/Controller/ShareAPIController.php
Expand Up @@ -279,7 +279,7 @@ protected function formatShare(IShare $share, Node $recipientNode = null): array
} elseif ($share->getShareType() === IShare::TYPE_EMAIL) {
$result['share_with'] = $share->getSharedWith();
$result['password'] = $share->getPassword();
$result['password_expiration_time'] = $share->getPasswordExpirationTime();
$result['password_expiration_time'] = $share->getPasswordExpirationTime() !== null ? $share->getPasswordExpirationTime()->format(\DateTime::ATOM) : null;
$result['send_password_by_talk'] = $share->getSendPasswordByTalk();
$result['share_with_displayname'] = $this->getDisplayNameFromAddressBook($share->getSharedWith(), 'EMAIL');
$result['token'] = $share->getToken();
Expand Down
20 changes: 20 additions & 0 deletions apps/files_sharing/src/components/SharingEntryLink.vue
Expand Up @@ -192,6 +192,12 @@
@submit="onPasswordSubmit">
{{ t('files_sharing', 'Enter a password') }}
</ActionInput>
<ActionText v-if="passwordExpirationTime" icon="icon-info">
{{ t('files_sharing', 'Password expires {passwordExpirationTime}', {passwordExpirationTime}) }}
</ActionText>
<ActionText v-else-if="passwordExpirationTime !== null" icon="icon-error">
{{ t('files_sharing', 'Password expired') }}
</ActionText>

<!-- password protected by Talk -->
<ActionCheckbox v-if="isPasswordProtectedByTalkAvailable"
Expand Down Expand Up @@ -461,6 +467,20 @@ export default {
},
},
passwordExpirationTime() {
if (this.share.passwordExpirationTime === null) {
return null
}
var expirationTime = moment(this.share.passwordExpirationTime)
if (expirationTime.diff(moment()) < 0) {
return false
}
return expirationTime.fromNow()
},
/**
* Is Talk enabled?
*
Expand Down
11 changes: 11 additions & 0 deletions apps/files_sharing/src/models/Share.js
Expand Up @@ -358,6 +358,17 @@ export default class Share {
this._share.password = password
}

/**
* Password expiration time
*
* @return {boolean}
* @readonly
* @memberof Share
*/
get passwordExpirationTime() {
return this._share.password_expiration_time
}

/**
* Password protection by Talk of the share
*
Expand Down

0 comments on commit 619d1fa

Please sign in to comment.