Skip to content

Commit 11c28f4

Browse files
committed
Shows password expiration time in the Share menu
Signed-off-by: Cyrille Bollu <cyrpub@bollu.be>
1 parent d9ee834 commit 11c28f4

File tree

3 files changed

+32
-1
lines changed

3 files changed

+32
-1
lines changed

apps/files_sharing/lib/Controller/ShareAPIController.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -279,7 +279,7 @@ protected function formatShare(IShare $share, Node $recipientNode = null): array
279279
} elseif ($share->getShareType() === IShare::TYPE_EMAIL) {
280280
$result['share_with'] = $share->getSharedWith();
281281
$result['password'] = $share->getPassword();
282-
$result['password_expiration_time'] = $share->getPasswordExpirationTime();
282+
$result['password_expiration_time'] = $share->getPasswordExpirationTime() !== null ? $share->getPasswordExpirationTime()->format(\DateTime::ATOM) : null;
283283
$result['send_password_by_talk'] = $share->getSendPasswordByTalk();
284284
$result['share_with_displayname'] = $this->getDisplayNameFromAddressBook($share->getSharedWith(), 'EMAIL');
285285
$result['token'] = $share->getToken();

apps/files_sharing/src/components/SharingEntryLink.vue

+20
Original file line numberDiff line numberDiff line change
@@ -192,6 +192,12 @@
192192
@submit="onPasswordSubmit">
193193
{{ t('files_sharing', 'Enter a password') }}
194194
</ActionInput>
195+
<ActionText v-if="passwordExpirationTime" icon="icon-info">
196+
{{ t('files_sharing', 'Password expires {passwordExpirationTime}', {passwordExpirationTime}) }}
197+
</ActionText>
198+
<ActionText v-else-if="passwordExpirationTime !== null" icon="icon-error">
199+
{{ t('files_sharing', 'Password expired') }}
200+
</ActionText>
195201

196202
<!-- password protected by Talk -->
197203
<ActionCheckbox v-if="isPasswordProtectedByTalkAvailable"
@@ -461,6 +467,20 @@ export default {
461467
},
462468
},
463469

470+
passwordExpirationTime() {
471+
if (this.share.passwordExpirationTime === null) {
472+
return null
473+
}
474+
475+
var expirationTime = moment(this.share.passwordExpirationTime)
476+
477+
if (expirationTime.diff(moment()) < 0) {
478+
return false
479+
}
480+
481+
return expirationTime.fromNow()
482+
},
483+
464484
/**
465485
* Is Talk enabled?
466486
*

apps/files_sharing/src/models/Share.js

+11
Original file line numberDiff line numberDiff line change
@@ -358,6 +358,17 @@ export default class Share {
358358
this._share.password = password
359359
}
360360

361+
/**
362+
* Password expiration time
363+
*
364+
* @return {boolean}
365+
* @readonly
366+
* @memberof Share
367+
*/
368+
get passwordExpirationTime() {
369+
return this._share.password_expiration_time
370+
}
371+
361372
/**
362373
* Password protection by Talk of the share
363374
*

0 commit comments

Comments
 (0)