diff options
author | Joas Schilling <coding@schilljs.com> | 2018-07-25 18:31:16 +0300 |
---|---|---|
committer | Daniel Calviño Sánchez <danxuliu@gmail.com> | 2018-08-08 11:24:49 +0300 |
commit | 112c73b71cbc642937f8f2f2c9d903c014fd8f70 (patch) | |
tree | 0f82ed9a6f7365449ddb2ca2dfdf20efc043d6cc | |
parent | f81f5e0a7c17601a039f820b4d0fa59a561fe993 (diff) |
Open the call in a new tab for now
Signed-off-by: Joas Schilling <coding@schilljs.com>
-rw-r--r-- | appinfo/routes.php | 5 | ||||
-rw-r--r-- | css/publicshareauth.scss | 9 | ||||
-rw-r--r-- | js/publicshareauth.js | 12 | ||||
-rw-r--r-- | lib/Controller/PageController.php | 48 |
4 files changed, 73 insertions, 1 deletions
diff --git a/appinfo/routes.php b/appinfo/routes.php index 2422e13f0..98a76a92c 100644 --- a/appinfo/routes.php +++ b/appinfo/routes.php @@ -28,6 +28,11 @@ return [ 'url' => '/', 'verb' => 'GET', ], + [ + 'name' => 'Page#shareAuth', + 'url' => '/shareauth/{token}', + 'verb' => 'GET', + ], ], 'ocs' => [ /** diff --git a/css/publicshareauth.scss b/css/publicshareauth.scss index 218e385be..ef224f670 100644 --- a/css/publicshareauth.scss +++ b/css/publicshareauth.scss @@ -21,6 +21,15 @@ input#request-password-button:disabled ~ .icon { opacity: 0.5; } +/* Mimic the appearance of the log in button when a link is used. */ +.request-password-wrapper a { + display: block; + width: 269px; + padding: 13px 10px; + font-size: 20px; + margin: 5px; +} + /* Special layout to include the Talk sidebar */ diff --git a/js/publicshareauth.js b/js/publicshareauth.js index 014806d94..515605144 100644 --- a/js/publicshareauth.js +++ b/js/publicshareauth.js @@ -28,7 +28,8 @@ init: function() { var self = this; - this.setupRequestPasswordButton(); + // this.setupRequestPasswordButton(); + this.setupCallButton(); this.setupLayoutForTalkSidebar(); $('#request-password-button').click(function() { @@ -44,6 +45,15 @@ }); }, + setupCallButton: function() { + var url = OC.generateUrl('apps/spreed/shareauth/' + $('#sharingToken').val()); + + $('main').append('<div id="submit-wrapper" class="request-password-wrapper">' + + ' <a href="' + url + '" target="_blank" class="primary button">' + t('spreed', 'Request password') + '</a>' + + ' <div class="icon icon-confirm-white"></div>' + + '</div>'); + }, + setupRequestPasswordButton: function() { // "submit-wrapper" is used to mimic the login button and thus get // automatic colouring of the confirm icon by the Theming app diff --git a/lib/Controller/PageController.php b/lib/Controller/PageController.php index 96d13ff71..469c82c57 100644 --- a/lib/Controller/PageController.php +++ b/lib/Controller/PageController.php @@ -33,7 +33,9 @@ use OCA\Spreed\Room; use OCA\Spreed\TalkSession; use OCP\AppFramework\Controller; use OCP\AppFramework\Http; +use OCP\AppFramework\Http\Response; use OCP\AppFramework\Http\ContentSecurityPolicy; +use OCP\AppFramework\Http\NotFoundResponse; use OCP\AppFramework\Http\RedirectResponse; use OCP\AppFramework\Http\TemplateResponse; use OCP\AppFramework\Http\Template\PublicTemplateResponse; @@ -184,6 +186,52 @@ class PageController extends Controller { } /** + * @PublicPage + * @NoCSRFRequired + * + * @param string $token + * @return NotFoundResponse|RedirectResponse + */ + public function shareAuth($token = ''): Response { + try { + $share = \OC::$server->getShareManager()->getShareByToken($token); + } catch (\OCP\Share\Exceptions\ShareNotFound $e) { + return new NotFoundResponse(); + } + + if (!$share->getSendPasswordByTalk()) { + return new NotFoundResponse(); + } + + $sharerUser = \OC::$server->getUserManager()->get($share->getSharedBy()); + + if (!$sharerUser instanceof \OCP\IUser) { + return new NotFoundResponse(); + } + + // Create the room + $room = $this->manager->createPublicRoom($share->getSharedWith(), 'share:password', $token); + $room->addUsers([ + 'userId' => $sharerUser->getUID(), + 'participantType' => Participant::OWNER, + ]); + + // Notify the owner + $notification = $this->notificationManager->createNotification(); + $notification + ->setApp('spreed') + ->setObject('room', $room->getToken()) + ->setUser($sharerUser->getUID()) + ->setSubject('share:password', [ + 'sharedWith' => $share->getSharedWith(), + ]) + ->setDateTime(new \DateTime()); + $this->notificationManager->notify($notification); + + return new RedirectResponse($this->url->linkToRoute('spreed.Page.index', ['token' => $room->getToken()])); + } + + /** * @param string $token * @param string $password * @return TemplateResponse|RedirectResponse |