Test case fix

This commit is contained in:
Madhukar 2014-03-14 13:40:43 +05:30
parent f40b9819f1
commit c4ba5209b6
5 changed files with 61 additions and 17 deletions

View File

@ -185,6 +185,7 @@
"label.percentage": "Percentage",
"label.outstanding.amount":"Loan outstanding amount",
"label.and": "and",
"label.message.password.expired":"Your password is expired, please reset your password",
"#Enumeration & Error Messages": "..",
"label.error": "Error",
@ -387,6 +388,7 @@
"label.button.month": "Month",
"label.button.day": "Day",
"label.button.signin": "Sign In",
"label.button.resetPassword": "Reset Password",
"label.button.viewpermissions":"View Permissions",
"#Misc Labels": "..",

View File

@ -26,13 +26,24 @@
</span>
</div>
<br/><br/>
<div class="pull-right">
<input ng-autofocus="true" type="text" data-ng-model="loginCredentials.username" placeholder="{{ 'label.input.username' | translate }}" class="input-small" required id="uid">
<input type="password" data-ng-model="loginCredentials.password" placeholder="{{ 'label.input.password' | translate }}" class="input-small" required id="pwd">
<button class="btn btn-success" type="submit" data-ng-click="login()" id="login-button">{{ 'label.button.signin' | translate }}</button>
<div ng-hide="resetPassword">
<div class="pull-right">
<input ng-autofocus="true" type="text" data-ng-model="loginCredentials.username" placeholder="{{ 'label.input.username' | translate }}" class="input-small" required id="uid">
<input type="password" data-ng-model="loginCredentials.password" placeholder="{{ 'label.input.password' | translate }}" class="input-small" required id="pwd">
<button class="btn btn-success" type="submit" data-ng-click="login()" id="login-button">{{ 'label.button.signin' | translate }}</button>
</div>
<div class="pull-right" data-ng-show="authenticationFailed">
<p>{{ 'error.login.failed' | translate }}</p>
</div>
</div>
<div class="pull-right" data-ng-show="authenticationFailed">
<p>{{ 'error.login.failed' | translate }}</p>
<div ng-show="resetPassword">
<div class="pull-right">
<label><strong>{{ 'label.message.password.expired' | translate }}</strong></label>
<br/>
<input type="password" data-ng-model="passwordDetails.password" placeholder="{{ 'label.input.password' | translate }}" class="input-small" required id="password">
<input type="password" data-ng-model="passwordDetails.repeatPassword" placeholder="{{ 'label.input.repeatpassword' | translate }}" class="input-small" required id="repeatPassword">
<button class="btn btn-success" type="submit" data-ng-click="updatePassword()" id="updatepassword-button">{{ 'label.button.resetPassword' | translate }}</button>
</div>
</div>
</div>
<div class="row span8 offset2 paddedbottom">

View File

@ -1,24 +1,44 @@
(function (module) {
mifosX.controllers = _.extend(module, {
LoginFormController: function (scope, authenticationService) {
LoginFormController: function (scope, authenticationService, resourceFactory, httpService) {
scope.loginCredentials = {};
scope.passwordDetails = {};
scope.authenticationFailed = false;
scope.login = function () {
authenticationService.authenticateWithUsernamePassword(scope.loginCredentials);
//clearing username and password fields
scope.loginCredentials = {};
};
$('#pwd').keypress(function (e) {
if (e.which == 13) {
scope.login();
}
});
$('#repeatPassword').keypress(function (e) {
if (e.which == 13) {
scope.login();
}
});
scope.$on("UserAuthenticationFailureEvent", function (data) {
scope.authenticationFailed = true;
});
scope.updatePassword = function (){
resourceFactory.userListResource.update({'userId': scope.loggedInUserId}, scope.passwordDetails, function (data) {
//clear the old authorization token
httpService.cancelAuthorization();
scope.authenticationFailed = false;
scope.loginCredentials.password = scope.passwordDetails.password;
authenticationService.authenticateWithUsernamePassword(scope.loginCredentials);
});
};
}
});
mifosX.ng.application.controller('LoginFormController', ['$scope', 'AuthenticationService', mifosX.controllers.LoginFormController]).run(function ($log) {
mifosX.ng.application.controller('LoginFormController', ['$scope', 'AuthenticationService', 'ResourceFactory', 'HttpService', mifosX.controllers.LoginFormController]).run(function ($log) {
$log.info("LoginFormController initialized");
});
}(mifosX.controllers || {}));

View File

@ -72,12 +72,18 @@
scope.leftnav = false;
scope.$on("UserAuthenticationSuccessEvent", function (event, data) {
scope.currentSession = sessionManager.get(data);
scope.start(scope.currentSession);
if (scope.currentSession.user && scope.currentSession.user.userPermissions) {
$rootScope.setPermissions(scope.currentSession.user.userPermissions);
}
location.path('/home').replace();
scope.authenticationFailed = false;
scope.resetPassword = data.shouldRenewPassword;
if (sessionManager.get(data)) {
scope.currentSession = sessionManager.get(data);
scope.start(scope.currentSession);
if (scope.currentSession.user && scope.currentSession.user.userPermissions) {
$rootScope.setPermissions(scope.currentSession.user.userPermissions);
}
location.path('/home').replace();
} else{
scope.loggedInUserId = data.userId;
};
});
scope.search = function () {
@ -89,6 +95,7 @@
scope.logout = function () {
scope.currentSession = sessionManager.clear();
scope.resetPassword = false;
location.path('/').replace();
};

View File

@ -4,9 +4,13 @@
var EMPTY_SESSION = {};
this.get = function (data) {
webStorage.add("sessionData", {userId: data.userId, authenticationKey: data.base64EncodedAuthenticationKey, userPermissions: data.permissions});
httpService.setAuthorization(data.base64EncodedAuthenticationKey);
return {user: new mifosX.models.LoggedInUser(data)};
if (data.shouldRenewPassword) {
httpService.setAuthorization(data.base64EncodedAuthenticationKey);
} else{
webStorage.add("sessionData", {userId: data.userId, authenticationKey: data.base64EncodedAuthenticationKey, userPermissions: data.permissions});
httpService.setAuthorization(data.base64EncodedAuthenticationKey);
return {user: new mifosX.models.LoggedInUser(data)};
};
}
this.clear = function () {