Skip to content

Commit

Permalink
The user is set on the login screen if transmitted from the client
Browse files Browse the repository at this point in the history
  • Loading branch information
DeepDiver1975 committed Jul 31, 2017
1 parent 5846a0f commit 75e88e6
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 3 deletions.
13 changes: 11 additions & 2 deletions js/login.js
Original file line number Diff line number Diff line change
Expand Up @@ -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('<div class="warning"><div class="icon-info-white" />'+msg+'</div>');
var user = data.attr('user');
if (user) {
$('#password')
.val('')
.get(0).focus();
$('#user')
.val(user)
.prop('readonly', true);
}
}
});
6 changes: 5 additions & 1 deletion lib/AppInfo/Application.php
Original file line number Diff line number Diff line change
Expand Up @@ -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
}
Expand Down

0 comments on commit 75e88e6

Please sign in to comment.