Skip to content
This repository was archived by the owner on May 30, 2019. It is now read-only.

Commit 998bd98

Browse files
committed
browser: force username and password into login attempt
Lacking change events from some browsers when autocompleting forms, we must manually read the values from the input elements just before attempting to submit the credentials to the server.
1 parent 299e36c commit 998bd98

File tree

2 files changed

+28
-2
lines changed

2 files changed

+28
-2
lines changed

appserver/java-spring/static/app/dialogs/login.js

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,18 @@ define(['app/module'], function (module) {
3535

3636
ssSession.create().attachScope($scope, 'session');
3737

38+
// some browsers don't raise events when they autocomplete
39+
var getFromInputByClass = function (className) {
40+
var el = angular.element(
41+
document.getElementsByClassName(className).item(0)
42+
);
43+
return el.val();
44+
};
45+
46+
var credentialsHack = function () {
47+
$scope.session.username = getFromInputByClass('ss-input-username');
48+
$scope.session.password = getFromInputByClass('ss-input-password');
49+
};
3850

3951
/**
4052
* @ngdoc method
@@ -48,6 +60,7 @@ define(['app/module'], function (module) {
4860
* property.
4961
*/
5062
$scope.authenticate = function () {
63+
credentialsHack();
5164
mlAuth.authenticate($scope.session).then(
5265
onAuthSuccess,
5366
onAuthFailure
@@ -86,7 +99,7 @@ define(['app/module'], function (module) {
8699

87100
$scope.random1 = randomName();
88101
$scope.random2 = randomName();
89-
102+
90103
}
91104
]);
92105

browser/src/app/dialogs/login.js

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,18 @@ define(['app/module'], function (module) {
3535

3636
ssSession.create().attachScope($scope, 'session');
3737

38+
// some browsers don't raise events when they autocomplete
39+
var getFromInputByClass = function (className) {
40+
var el = angular.element(
41+
document.getElementsByClassName(className).item(0)
42+
);
43+
return el.val();
44+
};
45+
46+
var credentialsHack = function () {
47+
$scope.session.username = getFromInputByClass('ss-input-username');
48+
$scope.session.password = getFromInputByClass('ss-input-password');
49+
};
3850

3951
/**
4052
* @ngdoc method
@@ -48,6 +60,7 @@ define(['app/module'], function (module) {
4860
* property.
4961
*/
5062
$scope.authenticate = function () {
63+
credentialsHack();
5164
mlAuth.authenticate($scope.session).then(
5265
onAuthSuccess,
5366
onAuthFailure
@@ -86,7 +99,7 @@ define(['app/module'], function (module) {
8699

87100
$scope.random1 = randomName();
88101
$scope.random2 = randomName();
89-
102+
90103
}
91104
]);
92105

0 commit comments

Comments
 (0)