-
-
Notifications
You must be signed in to change notification settings - Fork 4.2k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add support for sending the password for a share by Nextcloud Talk #10238
Add support for sending the password for a share by Nextcloud Talk #10238
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hmm
core/templates/publicshareauth.php
Outdated
@@ -25,3 +25,7 @@ class="svg icon-confirm input-button-inline" value="" disabled="disabled" /> | |||
</p> | |||
</fieldset> | |||
</form> | |||
|
|||
<?php if ($_['sendPasswordByTalk']): ?> | |||
<?php echo (new \OCP\Template('spreed', 'publicshareauth'))->fetchPage($_['sendPasswordByTalk']); ?> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Cross app reference
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should also be possible to add an event in the relevant controller.
Talk could then load a JS script which creates the UI instead?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I do not know if the template system provides any event to add more content to a page. Even if all the markup was generated using JavaScript in the browser at the very least the page would need to be extended with the links in the header to load the scripts.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Well basically it should work like OCA\Files::loadAdditionalScripts
and the first run wizard
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Mmm, I think that would not work here. The reason is that, besides the scripts themselves, the handler of the event has to add some HTML elements too (in order to provide the share token in a data property). As far as I know currently it is not possible to add arbitrary elements to be rendered.
I think that the template system would have to be extended to add another template class that allows rendering subtemplates (like the PublicTemplateResponse
and the IMenuAction
, but generic). Or am I missing something?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
As far as I know currently it is not possible to add arbitrary elements to be rendered
you can do this quite easily?
$('form.searchbox').after($('<div>').attr('id', 'notifications'));
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes, adding an element from the Talk script is no problem (that is what it is done already for the sidebar). The problem is injecting the share token, which should be done when the template is rendered, not when the JavaScript is executed.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
OK, that's it, I'm officially dumb xD I have just realized that I can simply add a hidden input field in the publicshareauth
template with the share token, just like it is done in the public share template; there is no real need to inject it only when Talk is used.
Not really nice IMO 🙈 |
20d46ac
to
02d6e55
Compare
core/templates/publicshareauth.php
Outdated
@@ -25,3 +25,7 @@ class="svg icon-confirm input-button-inline" value="" disabled="disabled" /> | |||
</p> | |||
</fieldset> | |||
</form> | |||
|
|||
<?php if ($_['sendPasswordByTalk']): ?> | |||
<?php echo (new \OCP\Template('spreed', 'publicshareauth'))->fetchPage($_['sendPasswordByTalk']); ?> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should also be possible to add an event in the relevant controller.
Talk could then load a JS script which creates the UI instead?
02d6e55
to
7a29e67
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks good. 🐘
I'd say lets merge it and iron out tiny bugs later.
381f5db
to
8a6514c
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Fine by me too
No direct code call anymore
Signed-off-by: Daniel Calviño Sánchez <danxuliu@gmail.com>
Signed-off-by: Daniel Calviño Sánchez <danxuliu@gmail.com>
Signed-off-by: Daniel Calviño Sánchez <danxuliu@gmail.com>
When a password was set for a mail share an e-mail was sent to the recipient with the password. Now the e-mail is no longer sent if the password is meant to be sent by Talk. However, before the e-mail was not sent when the share was updated but the password was not changed. Now an e-mail is sent in that case too if switching from a password sent by Talk to a password sent by mail. On the other hand, when switching from a password sent by mail to a password sent by Talk it is mandatory to change the password; otherwise the recipient would already have access to the share without having to call the sharer to verify her identity. Signed-off-by: Daniel Calviño Sánchez <danxuliu@gmail.com>
Signed-off-by: Daniel Calviño Sánchez <danxuliu@gmail.com>
Before the public share authentication page is rendered now an event to load additional scripts is dispatched. Thanks to this any app can load its own scripts that, when run on the browser, adjust as needed the page generated by the server. Note, however, that during the handling of the event apps are only able to add scripts or styles to be loaded; they can not render arbitrary content on the page, or change how the content is rendered by the original template; all those changes have to be done by the scripts at run-time. This implies that the scripts of the apps can use only those parameters, like the token of the share, added to the page when it is generated by the "publicshareauth" template. Due to this, and given that the event is being introduced to be used by Talk to inject the UI needed to request the password for a share, the token of the share is now provided in the generated page, just like done in the public share page. Signed-off-by: Daniel Calviño Sánchez <danxuliu@gmail.com>
8a6514c
to
cd6d99c
Compare
I have rebased onto master to fix the merge conflicts. Note that now this pull request adds a migration with a previous date than another one already in master, but given that the version is bumped too according to @nickvergessen it should not be a problem. |
Until now the password to be sent by mail was set by enabling a checkbox in the share menu and then entering the password in an input field shown below. Now, when Talk is enabled, another item is added to the share menu to do the same for a password to be sent by Talk. Sending the password by mail and sending it by Talk are mutually exclusive actions, so when one of the checkboxes is enabled the other one is automatically disabled. Note that the icon set for the field, "icon-passwordtalk", does not currently exist; it simply mimics the "icon-passwordmail" (which does not exist either) used for the field of the password protect by mail to get the right padding in the menu. Signed-off-by: Daniel Calviño Sánchez <danxuliu@gmail.com>
cd6d99c
to
9110935
Compare
For me there is now no such sharing option anymore :/ |
Known issue unrelated to this pull request; it was broken by #9982 |
Server part of nextcloud/spreed#1049
When a file is shared by email the file can be accessed by anyone as long as the token of the share is known, so to limit that access the share can be protected with a password. When a password was set it was also sent by email to the sharee. This pull request (and its Talk counterpart) adds another option: sending the password with Nextcloud Talk.
Now when the sharer protects the share with a password no email is sent. Instead, when the receiver tries to open the share the public share authentication page is shown, which now contains a Request password button. When that button is clicked an embedded Nextcloud UI is shown and a conversation is started between the sharer and the user trying to open the file, which allows the sharer to verify the identity of the user before telling her the password and thus granting her access to the file.
Note that it is the sharer who decides whether the receiver of an email share can call her or not; you will not be bothered with password requests if you do not choose to ;-)
This pull request updates the server parts needed to provide that feature, which are basically those related to shares; the handling of rooms and the Talk UI is isolated from the server and done in the Talk app. The "bridge" between the public share authentication page and the Talk UI is the share controller, that simply appends a Talk template when sending the password by Talk is enabled for the share. That template just loads some JavaScript code that, when run on the browser, adjusts the page generated by the server to inject the Talk UI as needed.
Regardind the share menu, a new item was added to the menu, Password protect by Talk, that behaves like the previous Password protect; sending the password by mail and sending it by Talk are mutually exclusive actions, so when one of the checkboxes is enabled the other one is automatically disabled (radio buttons may have been better, but it would be strange to have radio buttons mixed with the rest of checkboxes in the menu).
When switching from sending by Talk to sending by email the previous password is reused; however, when switching from sending by email to sending by Talk a new password must be provided, and the share will not be updated until that is done.
For reviewers, note that in ShareAPIController the
ServerContainer
is injected and then theAppManager
is got from the container, instead of directly injecting theAppManager
; this is on purpose, as theServerContainer
will be necessary for another pull request in the works ;-)Also note that when a password is set in the list of shares the loading icon is misplaced; that happens too in current master and is not related to this pull request.