From 75e88e61c5e6d085d110dde2bf35b0b1dc684c4e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Thomas=20M=C3=BCller?= Date: Mon, 31 Jul 2017 10:25:24 +0200 Subject: [PATCH] The user is set on the login screen if transmitted from the client --- js/login.js | 13 +++++++++++-- lib/AppInfo/Application.php | 6 +++++- 2 files changed, 16 insertions(+), 3 deletions(-) diff --git a/js/login.js b/js/login.js index bca68d5b..6aed3916 100644 --- a/js/login.js +++ b/js/login.js @@ -21,8 +21,17 @@ $(document).ready(function(){ var $loginMessage = $('#body-login').find('#message'); if ($loginMessage.length) { - var client = $("data[key='oauth2']").attr('value'); - var msg = t('oauth2', 'The application "{app}" is requesting access to your account. To authorize it, please log in first.', {app : client}); + var data = $("data[key='oauth2']"); + var msg = t('oauth2', 'The application "{app}" is requesting access to your account. To authorize it, please log in first.', {app : data.attr('client')}); $loginMessage.parent().append('
'+msg+'
'); + var user = data.attr('user'); + if (user) { + $('#password') + .val('') + .get(0).focus(); + $('#user') + .val(user) + .prop('readonly', true); + } } }); diff --git a/lib/AppInfo/Application.php b/lib/AppInfo/Application.php index c4d3a4a9..2b95446c 100644 --- a/lib/AppInfo/Application.php +++ b/lib/AppInfo/Application.php @@ -105,7 +105,11 @@ public function boot() { $client = $mapper->findByIdentifier($params['client_id']); \OCP\Util::addScript('oauth2', 'login'); \OCP\Util::addStyle('oauth2', 'login'); - \OCP\Util::addHeader('data', ['key' => 'oauth2', 'value' => $client->getName()]); + $data = ['key' => 'oauth2', 'client' => $client->getName()]; + if (isset($params['user'])) { + $data['user'] = $params['user']; + } + \OCP\Util::addHeader('data', $data); } catch (DoesNotExistException $ex) { // ignore - the given client id is not known }