Merge pull request #1508 from coreos-inc/login-angular
Fix login form for password managers
This commit is contained in:
commit
747e63f4ea
2 changed files with 29 additions and 6 deletions
|
@ -25,13 +25,13 @@
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div quay-show="Features.DIRECT_LOGIN">
|
<div quay-show="Features.DIRECT_LOGIN">
|
||||||
<input type="text" class="form-control" name="username"
|
<input type="text" class="form-control" id="signin-username" name="username"
|
||||||
placeholder="Username or E-mail Address" ng-model="user.username"
|
placeholder="Username or E-mail Address" ng-model="signInUser.username"
|
||||||
ng-disabled="tryAgainSoon > 0 || signingIn" autofocus>
|
ng-disabled="tryAgainSoon > 0 || signingIn" autofocus>
|
||||||
|
|
||||||
<input type="password" class="form-control" name="password"
|
<input type="password" class="form-control" id="signin-password" name="password"
|
||||||
ng-disabled="tryAgainSoon > 0 || signingIn"
|
ng-disabled="tryAgainSoon > 0 || signingIn"
|
||||||
placeholder="Password" ng-model="user.password">
|
placeholder="Password" ng-model="signInUser.password">
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<button class="btn btn-primary btn-block" type="submit" quay-show="Features.DIRECT_LOGIN" ng-disabled="tryAgainSoon > 0">
|
<button class="btn btn-primary btn-block" type="submit" quay-show="Features.DIRECT_LOGIN" ng-disabled="tryAgainSoon > 0">
|
||||||
|
|
|
@ -20,6 +20,7 @@ angular.module('quay').directive('signinForm', function () {
|
||||||
$scope.signingIn = false;
|
$scope.signingIn = false;
|
||||||
$scope.EXTERNAL_LOGINS = ExternalLoginService.EXTERNAL_LOGINS;
|
$scope.EXTERNAL_LOGINS = ExternalLoginService.EXTERNAL_LOGINS;
|
||||||
$scope.Features = Features;
|
$scope.Features = Features;
|
||||||
|
$scope.signInUser = {};
|
||||||
|
|
||||||
$scope.markStarted = function() {
|
$scope.markStarted = function() {
|
||||||
$scope.signingIn = true;
|
$scope.signingIn = true;
|
||||||
|
@ -49,14 +50,36 @@ angular.module('quay').directive('signinForm', function () {
|
||||||
$scope.signin = function() {
|
$scope.signin = function() {
|
||||||
if ($scope.tryAgainSoon > 0 || !Features.DIRECT_LOGIN) { return; }
|
if ($scope.tryAgainSoon > 0 || !Features.DIRECT_LOGIN) { return; }
|
||||||
|
|
||||||
|
var checkIfEmpty = function(fieldName) {
|
||||||
|
if (!$scope.signInUser[fieldName]) {
|
||||||
|
$scope.signInUser[fieldName] = $('#signin-' + fieldName).val() || '';
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
// Check for empty username and/or password. If found, we try to manually retrieve
|
||||||
|
// the values as some password managers will not call the necessary Angular events.
|
||||||
|
checkIfEmpty('username');
|
||||||
|
checkIfEmpty('password');
|
||||||
|
|
||||||
|
// If still empty, don't submit.
|
||||||
|
if (!$scope.signInUser.username) {
|
||||||
|
$('#signin-username').focus();
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!$scope.signInUser.password) {
|
||||||
|
$('#signin-password').focus();
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
$scope.markStarted();
|
$scope.markStarted();
|
||||||
$scope.cancelInterval();
|
$scope.cancelInterval();
|
||||||
|
|
||||||
if ($scope.inviteCode) {
|
if ($scope.inviteCode) {
|
||||||
$scope.user['invite_code'] = $scope.inviteCode;
|
$scope.signInUser['invite_code'] = $scope.inviteCode;
|
||||||
}
|
}
|
||||||
|
|
||||||
ApiService.signinUser($scope.user).then(function() {
|
ApiService.signinUser($scope.signInUser).then(function() {
|
||||||
$scope.signingIn = false;
|
$scope.signingIn = false;
|
||||||
$scope.needsEmailVerification = false;
|
$scope.needsEmailVerification = false;
|
||||||
$scope.invalidCredentials = false;
|
$scope.invalidCredentials = false;
|
||||||
|
|
Reference in a new issue