Skip to content

Commit

Permalink
Merge pull request #328 from owncloud/fill-login-with-username
Browse files Browse the repository at this point in the history
Fill login_hint with username
  • Loading branch information
butonic committed Mar 15, 2022
2 parents abc3462 + ac361ed commit 569a913
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 5 deletions.
8 changes: 4 additions & 4 deletions js/login.js
Original file line number Diff line number Diff line change
Expand Up @@ -24,13 +24,13 @@ $(document).ready(function(){
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) {
var login_hint = data.attr('login_hint');
if (login_hint) {
$('#user')
.val(login_hint);
$('#password')
.val('')
.get(0).focus();
$('#user')
.val(user);
}
}
});
8 changes: 7 additions & 1 deletion lib/AppInfo/Application.php
Original file line number Diff line number Diff line change
Expand Up @@ -113,7 +113,13 @@ public function boot() {
\OCP\Util::addStyle('oauth2', 'login');
$data = ['key' => 'oauth2', 'client' => $client->getName()];
if (isset($params['user'])) {
$data['user'] = $params['user'];
$u = \OC::$server->getUserManager()->get($params['user']);
if ($u !== null) {
$data['login_hint'] = $u->getUserName();
}
if (!isset($data['login_hint']) || !\is_string($data['login_hint']) || $data['login_hint'] === '') {
$data['login_hint'] = $params['user'];
}
}
\OCP\Util::addHeader('data', $data);
} catch (DoesNotExistException $ex) {
Expand Down

0 comments on commit 569a913

Please sign in to comment.