Commit 5ec37709 authored by Sascha Pfeiffer's avatar Sascha Pfeiffer

fixing login form

Signed-off-by: 's avatarSascha Pfeiffer <sascha.pfeiffer@psono.com>
parent 024e2d42
......@@ -132,28 +132,28 @@
{{ provider.title }}
</div>
<div class="form-group">
<button ng-click="initiate_saml_login(provider, loginFormRemember, loginFormTrustDevice, true)" type="submit" class="btn btn-danger">{{ provider.button_name}} <i class="fa fa-sign-in" aria-hidden="true"></i></button>
<button ng-click="initiate_saml_login(provider, login_data.remember, login_data.trust, true)" type="submit" class="btn btn-danger">{{ provider.button_name}} <i class="fa fa-sign-in" aria-hidden="true"></i></button>
<a ng-if="provider.registration_url" ng-href="{{ provider.registration_url }}">{{'REGISTER' | translate}}</a>
</div>
</div>
<p ng-if="saml_enabled && (authkey_enabled || ldap_enabled)" class="horizontalline"><span>{{'OR' | translate}}</span></p>
<div ng-if="authkey_enabled || ldap_enabled" ng-class="{'input-group': loginFormUsername == null || loginFormUsername.indexOf('@') == -1}">
<input type="text" class="form-control" id="loginUsername" placeholder="{{'USERNAME' | translate}}" ng-model="loginFormUsername" required aria-describedby="username-addon" autofocus>
<span class="input-group-addon" id="username-addon" ng-if="loginFormUsername == null || loginFormUsername.indexOf('@') == -1">@{{selected_server_domain}}</span>
<div ng-if="authkey_enabled || ldap_enabled" ng-class="{'input-group': login_data.username == null || login_data.username.indexOf('@') == -1}">
<input type="text" class="form-control" id="loginUsername" placeholder="{{'USERNAME' | translate}}" ng-model="login_data.username" required aria-describedby="username-addon" autofocus>
<span class="input-group-addon" id="username-addon" ng-if="login_data.username == null || login_data.username.indexOf('@') == -1">@{{selected_server_domain}}</span>
</div>
<br ng-if="authkey_enabled || ldap_enabled">
<div ng-if="authkey_enabled || ldap_enabled" class="form-group">
<input type="password" class="form-control" id="loginPassword" placeholder="{{'PASSWORD' | translate}}" ng-model="loginFormPassword" required>
<input type="password" class="form-control" id="loginPassword" placeholder="{{'PASSWORD' | translate}}" ng-model="login_data.password" required>
</div>
<div class="checkbox">
<label><input type="checkbox" ng-model="loginFormRemember"> {{'REMEMBER_USERNAME_AND_SERVER' | translate}}</label>
<label><input type="checkbox" ng-model="login_data.remember"> {{'REMEMBER_USERNAME_AND_SERVER' | translate}}</label>
</div>
<div class="checkbox">
<label><input type="checkbox" ng-model="loginFormTrustDevice"> {{'TRUST_DEVICE' | translate}}</label>
<label><input type="checkbox" ng-model="login_data.trust"> {{'TRUST_DEVICE' | translate}}</label>
</div>
<div ng-if="authkey_enabled || ldap_enabled" class="form-group">
<button ng-if="authkey_enabled || ldap_enabled" ng-click="initiate_login(loginFormUsername, loginFormPassword, loginFormRemember, loginFormTrustDevice, false)" type="submit" class="btn btn-danger">{{'LOGIN' | translate}} <i class="fa fa-sign-in" aria-hidden="true"></i></button>
<button ng-if="authkey_enabled || ldap_enabled" ng-click="initiate_login(login_data.username, login_data.password, login_data.remember, login_data.trust, false)" type="submit" class="btn btn-danger">{{'LOGIN' | translate}} <i class="fa fa-sign-in" aria-hidden="true"></i></button>
<a ng-if="allow_registration && authkey_enabled" href="#" ng-click="open_tab('register.html')">{{'REGISTER' | translate}}</a>
</div>
......
......@@ -211,28 +211,28 @@
{{ provider.title }}
</div>
<div class="form-group">
<button ng-click="initiate_saml_login(provider, loginFormRemember, loginFormTrustDevice, true)" type="submit" class="btn btn-danger">{{ provider.button_name}} <i class="fa fa-sign-in" aria-hidden="true"></i></button>
<button ng-click="initiate_saml_login(provider, login_data.remember, login_data.trust, true)" type="submit" class="btn btn-danger">{{ provider.button_name}} <i class="fa fa-sign-in" aria-hidden="true"></i></button>
<a ng-if="provider.registration_url" ng-href="{{ provider.registration_url }}">{{'REGISTER' | translate}}</a>
</div>
</div>
<p ng-if="saml_enabled && (authkey_enabled || ldap_enabled)" class="horizontalline"><span>{{'OR' | translate}}</span></p>
<div ng-if="authkey_enabled || ldap_enabled" ng-class="{'input-group': loginFormUsername == null || loginFormUsername.indexOf('@') == -1}">
<input type="text" class="form-control" id="loginUsername" placeholder="{{'USERNAME' | translate}}" ng-model="loginFormUsername" required aria-describedby="username-addon" autofocus>
<span class="input-group-addon" id="username-addon" ng-if="loginFormUsername == null || loginFormUsername.indexOf('@') == -1">@{{selected_server_domain}}</span>
<div ng-if="authkey_enabled || ldap_enabled" ng-class="{'input-group': login_data.username == null || login_data.username.indexOf('@') == -1}">
<input type="text" class="form-control" id="loginUsername" placeholder="{{'USERNAME' | translate}}" ng-model="login_data.username" required aria-describedby="username-addon" autofocus>
<span class="input-group-addon" id="username-addon" ng-if="login_data.username == null || login_data.username.indexOf('@') == -1">@{{selected_server_domain}}</span>
</div>
<br ng-if="authkey_enabled || ldap_enabled">
<div ng-if="authkey_enabled || ldap_enabled" class="form-group">
<input type="password" class="form-control" id="loginPassword" placeholder="{{'PASSWORD' | translate}}" ng-model="loginFormPassword" required>
<input type="password" class="form-control" id="loginPassword" placeholder="{{'PASSWORD' | translate}}" ng-model="login_data.password" required>
</div>
<div class="checkbox">
<label><input type="checkbox" ng-model="loginFormRemember"> {{'REMEMBER_USERNAME_AND_SERVER' | translate}}</label>
<label><input type="checkbox" ng-model="login_data.remember"> {{'REMEMBER_USERNAME_AND_SERVER' | translate}}</label>
</div>
<div class="checkbox">
<label><input type="checkbox" ng-model="loginFormTrustDevice"> {{'TRUST_DEVICE' | translate}}</label>
<label><input type="checkbox" ng-model="login_data.trust"> {{'TRUST_DEVICE' | translate}}</label>
</div>
<div ng-if="authkey_enabled || ldap_enabled" class="form-group">
<button ng-if="authkey_enabled || ldap_enabled" ng-click="initiate_login(loginFormUsername, loginFormPassword, loginFormRemember, loginFormTrustDevice, true)" type="submit" class="btn btn-danger">{{'LOGIN' | translate}} <i class="fa fa-sign-in" aria-hidden="true"></i></button>
<button ng-if="authkey_enabled || ldap_enabled" ng-click="initiate_login(login_data.username, login_data.password, login_data.remember, login_data.trust, true)" type="submit" class="btn btn-danger">{{'LOGIN' | translate}} <i class="fa fa-sign-in" aria-hidden="true"></i></button>
<a ng-if="allow_registration && authkey_enabled" href="register.html">{{'REGISTER' | translate}}</a>
</div>
......
......@@ -35,6 +35,8 @@
$scope.active = {
'lang': languagePicker.get_active_language()
};
$scope.login_data = {
};
$scope.change_language = change_language;
$scope.select_server = select_server;
$scope.changing = changing;
......@@ -63,10 +65,10 @@
var persistent_trust_device = managerDatastoreUser.get_default('trust_device');
/* preselected values */
$scope.loginFormUsername = persistent_username;
// $scope.loginFormPassword = "myPassword";
$scope.loginFormRemember = persistent_username !== "";
$scope.loginFormTrustDevice = persistent_trust_device === true;
$scope.login_data['username'] = persistent_username;
//$scope.login_data['password'] = "myPassword";
$scope.login_data['remember'] = persistent_username !== "";
$scope.login_data['trust'] = persistent_trust_device === true;
$scope.allow_custom_server = !config.hasOwnProperty('allow_custom_server') || (config.hasOwnProperty('allow_custom_server') && config['allow_custom_server']);
$scope.allow_registration = !config.hasOwnProperty('allow_registration') || (config.hasOwnProperty('allow_registration') && config['allow_registration']);
......@@ -122,8 +124,8 @@
$scope.selected_server_domain = helper.get_domain(server.url);
}
if(helper.endsWith($scope.loginFormUsername, '@' + $scope.selected_server_domain)) {
$scope.loginFormUsername = $scope.loginFormUsername.slice(0, - ('@' + $scope.selected_server_domain).length);
if(helper.endsWith($scope.login_data.username, '@' + $scope.selected_server_domain)) {
$scope.login_data.username = $scope.login_data.username.slice(0, - ('@' + $scope.selected_server_domain).length);
}
}
......@@ -159,8 +161,8 @@
$scope.selected_server_domain = helper.get_domain(url);
$scope.filtered_servers = $filter('filter')($scope.servers, {url: url});
if(helper.endsWith($scope.loginFormUsername, '@' + $scope.selected_server_domain)) {
$scope.loginFormUsername = $scope.loginFormUsername.slice(0, - ('@' + $scope.selected_server_domain).length);
if(helper.endsWith($scope.login_data.username, '@' + $scope.selected_server_domain)) {
$scope.login_data.username = $scope.login_data.username.slice(0, - ('@' + $scope.selected_server_domain).length);
}
}
......@@ -184,7 +186,6 @@
}
var onError = function(data) {
console.log(data);
if (data.error_data === null) {
$scope.errors = ['Server offline.']
} else if (data.error_data.hasOwnProperty('non_field_errors')) {
......@@ -454,13 +455,13 @@
* @param {boolean} two_fa_redirect Redirect user to enforce-two-fa.html or let another controller handle it
*/
function initiate_login(username, password, remember, trust_device, two_fa_redirect) {
if (username === undefined || password === undefined) {
// Dont do anything if username or password is wrong,
// because the html5 form validation will tell the user
// whats wrong
return;
}
redirect_on_two_fa_missing = two_fa_redirect;
var onError = function() {
......
......@@ -82,28 +82,28 @@
{{ provider.title }}
</div>
<div class="form-group">
<button ng-click="initiate_saml_login(provider, loginFormRemember, loginFormTrustDevice, true)" type="submit" class="btn btn-danger">{{ provider.button_name}} <i class="fa fa-sign-in" aria-hidden="true"></i></button>
<button ng-click="initiate_saml_login(provider, login_data.remember, login_data.trust, true)" type="submit" class="btn btn-danger">{{ provider.button_name}} <i class="fa fa-sign-in" aria-hidden="true"></i></button>
<a ng-if="provider.registration_url" ng-href="{{ provider.registration_url }}">{{'REGISTER' | translate}}</a>
</div>
</div>
<p ng-if="saml_enabled && (authkey_enabled || ldap_enabled)" class="horizontalline"><span>{{'OR' | translate}}</span></p>
<div ng-if="authkey_enabled || ldap_enabled" ng-class="{'input-group': loginFormUsername == null || loginFormUsername.indexOf('@') == -1}">
<input type="text" class="form-control" id="loginUsername" placeholder="{{'USERNAME' | translate}}" ng-model="loginFormUsername" required aria-describedby="username-addon" autofocus>
<span class="input-group-addon" id="username-addon" ng-if="loginFormUsername == null || loginFormUsername.indexOf('@') == -1">@{{selected_server_domain}}</span>
<div ng-if="authkey_enabled || ldap_enabled" ng-class="{'input-group': login_data.username == null || login_data.username.indexOf('@') == -1}">
<input type="text" class="form-control" id="loginUsername" placeholder="{{'USERNAME' | translate}}" ng-model="login_data.username" required aria-describedby="username-addon" autofocus>
<span class="input-group-addon" id="username-addon" ng-if="login_data.username == null || login_data.username.indexOf('@') == -1">@{{selected_server_domain}}</span>
</div>
<br ng-if="authkey_enabled || ldap_enabled">
<div ng-if="authkey_enabled || ldap_enabled" class="form-group">
<input type="password" class="form-control" id="loginPassword" placeholder="{{'PASSWORD' | translate}}" ng-model="loginFormPassword" required>
<input type="password" class="form-control" id="loginPassword" placeholder="{{'PASSWORD' | translate}}" ng-model="login_data.password" required>
</div>
<div class="checkbox">
<label><input type="checkbox" ng-model="loginFormRemember"> {{'REMEMBER_USERNAME_AND_SERVER' | translate}}</label>
<label><input type="checkbox" ng-model="login_data.remember"> {{'REMEMBER_USERNAME_AND_SERVER' | translate}}</label>
</div>
<div class="checkbox">
<label><input type="checkbox" ng-model="loginFormTrustDevice"> {{'TRUST_DEVICE' | translate}}</label>
<label><input type="checkbox" ng-model="login_data.trust"> {{'TRUST_DEVICE' | translate}}</label>
</div>
<div ng-if="authkey_enabled || ldap_enabled" class="form-group">
<button ng-if="authkey_enabled || ldap_enabled" ng-click="initiate_login(loginFormUsername, loginFormPassword, loginFormRemember, loginFormTrustDevice, true)" type="submit" class="btn btn-danger">{{'LOGIN' | translate}} <i class="fa fa-sign-in" aria-hidden="true"></i></button>
<button ng-if="authkey_enabled || ldap_enabled" ng-click="initiate_login(login_data.username, login_data.password, login_data.remember, login_data.trust, true)" type="submit" class="btn btn-danger">{{'LOGIN' | translate}} <i class="fa fa-sign-in" aria-hidden="true"></i></button>
<a ng-if="allow_registration && authkey_enabled" href="register.html">{{'REGISTER' | translate}}</a>
</div>
......
......@@ -77,7 +77,7 @@
// it('login', function() {
//
// $scope.loginFormUsername = 'test-username';
// $scope.login_data.username = 'test-username';
// $scope.loginFormPassword = 'test-password';
//
// var user_validator = cryptoLibrary.generate_secret_key();;
......@@ -102,7 +102,7 @@
// function(method, url, data) {
// // Validate request parameters:
// data = JSON.parse(data);
// expect(data.username).toEqual($scope.loginFormUsername + '@psono.pw');
// expect(data.username).toEqual($scope.login_data.username + '@psono.pw');
// expect(data.authkey).toEqual('1b03cedd5c1d7816283bfd8ade4b7ca0d1e5e773bb54ceaa2d706a7a9efba6944404141e4944db7da01caa3ec8d53054f66158858dcef5f1934ea7d590198f36');
//
// var session_secret_key_enc = cryptoLibrary.encrypt_data_public_key(session_secret_key, data.public_key, session_key_pair.private_key);
......@@ -150,7 +150,7 @@
// }];
// });
//
// $scope.login($scope.loginFormUsername, $scope.loginFormPassword);
// $scope.login($scope.login_data.username, $scope.loginFormPassword);
// $httpBackend.flush();
//
// expect(storage.find_key('config', 'user_id')['value']).toEqual(user_id);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment