Skip to content

Commit

Permalink
Open the call in a new tab for now
Browse files Browse the repository at this point in the history
Signed-off-by: Joas Schilling <coding@schilljs.com>
  • Loading branch information
nickvergessen authored and danxuliu committed Aug 1, 2018
1 parent 0311011 commit bac2e68
Show file tree
Hide file tree
Showing 4 changed files with 73 additions and 1 deletion.
5 changes: 5 additions & 0 deletions appinfo/routes.php
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,11 @@
'url' => '/',
'verb' => 'GET',
],
[
'name' => 'Page#shareAuth',
'url' => '/shareauth/{token}',
'verb' => 'GET',
],
],
'ocs' => [
/**
Expand Down
9 changes: 9 additions & 0 deletions css/publicshareauth.scss
Original file line number Diff line number Diff line change
Expand Up @@ -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 */
Expand Down
12 changes: 11 additions & 1 deletion js/publicshareauth.js
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,8 @@
init: function() {
var self = this;

this.setupRequestPasswordButton();
// this.setupRequestPasswordButton();
this.setupCallButton();
this.setupLayoutForTalkSidebar();

$('#request-password-button').click(function() {
Expand All @@ -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
Expand Down
48 changes: 48 additions & 0 deletions lib/Controller/PageController.php
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,9 @@
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;
Expand Down Expand Up @@ -183,6 +185,52 @@ public function index($token = '', $callUser = '', $password = '') {
return $response;
}

/**
* @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->getId())
->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
Expand Down

0 comments on commit bac2e68

Please sign in to comment.