added user logout menu

This commit is contained in:
Silvio Montanari 2013-07-02 23:58:54 +10:00
parent bd3971e23d
commit ca837e5f02
5 changed files with 32 additions and 12 deletions

View File

@ -1,8 +1,15 @@
<!-- we can include some common header page stuff in here, i.e. menus, nav tabs etc. -->
<img src="image/logo.jpg" alt="mifosX"/>
<nav>
<a href="#/">Start page</a>
<a href="#/home">Home page</a>
<a href="#/login">Login page</a>
</nav>
<div>
<div class="menu-links">
<nav>
<a href="#/">Start page</a>
<a href="#/home">Home page</a>
<a href="#/login">Login page</a>
</nav>
</div>
<div class="menu-user" data-ng-hide="currentUser == null">
<div>User: <strong>{{currentUser.name}}</strong> <a data-ng-click="logout()">(Logout)</a></div>
</div>
</div>
<hr/>

View File

@ -39,7 +39,6 @@
if (!test) {
angular.bootstrap(document, ["MifosX_Application"]);
}
// require([], 'test/test_realtime_demo');
});
});
}());

View File

@ -1,6 +1,8 @@
(function(module) {
mifosX.models = _.extend(module, {
User: function(data) {
this.name = data.username;
this.getHomePageIdentifier = function() {
var role = _.first(data.selectedRoles || data.roles);
return mifosX.models.roleMap[role.id];

View File

@ -10,3 +10,15 @@ nav a:hover {
nav a:active {
color: #000000;
}
.menu-links {
float: left;
}
.menu-user {
margin-right: 20px;
float: right;
}
.menu-user a {
cursor: pointer;
}

View File

@ -1,26 +1,26 @@
describe("AuthenticationService", function() {
var scope, http, callbacks;
var scope, httpService, callbacks;
beforeEach(function() {
callbacks = {};
scope = jasmine.createSpyObj("$rootScope", ['$broadcast']);
http = jasmine.createSpyObj("$http", ['post', 'success', 'error']);
http.post.andReturn(http);
httpService = jasmine.createSpyObj("httpService", ['post', 'success', 'error']);
httpService.post.andReturn(httpService);
_.each(['success', 'error'], function(method) {
http[method].andCallFake(function(callback) {
httpService[method].andCallFake(function(callback) {
callbacks[method] = callback;
return this;
});
});
new mifosX.services.AuthenticationService(scope, http).authenticateWithUsernamePassword({
new mifosX.services.AuthenticationService(scope, httpService).authenticateWithUsernamePassword({
username: "test_username",
password: "test_password",
});
});
it("should pass the correct parameters to the post method", function() {
expect(http.post).toHaveBeenCalledWith("/authentication?username=test_username&password=test_password");
expect(httpService.post).toHaveBeenCalledWith("/authentication?username=test_username&password=test_password");
});
describe("On successful authentication", function() {