parent
259caa4577
commit
23322bc572
2 changed files with 29 additions and 6 deletions
|
@ -25,13 +25,13 @@
|
|||
</div>
|
||||
|
||||
<div quay-show="Features.DIRECT_LOGIN">
|
||||
<input type="text" class="form-control" name="username"
|
||||
placeholder="Username or E-mail Address" ng-model="user.username"
|
||||
<input type="text" class="form-control" id="signin-username" name="username"
|
||||
placeholder="Username or E-mail Address" ng-model="signInUser.username"
|
||||
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"
|
||||
placeholder="Password" ng-model="user.password">
|
||||
placeholder="Password" ng-model="signInUser.password">
|
||||
</div>
|
||||
|
||||
<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.EXTERNAL_LOGINS = ExternalLoginService.EXTERNAL_LOGINS;
|
||||
$scope.Features = Features;
|
||||
$scope.signInUser = {};
|
||||
|
||||
$scope.markStarted = function() {
|
||||
$scope.signingIn = true;
|
||||
|
@ -49,14 +50,36 @@ angular.module('quay').directive('signinForm', function () {
|
|||
$scope.signin = function() {
|
||||
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.cancelInterval();
|
||||
|
||||
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.needsEmailVerification = false;
|
||||
$scope.invalidCredentials = false;
|
||||
|
|
Reference in a new issue