Skip to content

Commit

Permalink
Initialised login auth service
Browse files Browse the repository at this point in the history
  • Loading branch information
zakhenry committed Jul 15, 2015
1 parent e1545ab commit 73b1fb9
Show file tree
Hide file tree
Showing 6 changed files with 97 additions and 3 deletions.
3 changes: 2 additions & 1 deletion app/bower.json
Expand Up @@ -33,7 +33,8 @@
"angular-material": "~0.10.0",
"toposort": "~0.3.1",
"angular-rest-adapter": "~1",
"angular-http-progress": "*"
"angular-http-progress": "*",
"angular-jwt-auth": "~1"
},
"devDependencies": {
"angular-mocks": "~1.3",
Expand Down
3 changes: 2 additions & 1 deletion app/src/app/guest/guest.ts
Expand Up @@ -36,7 +36,8 @@ module app.guest {
'app.guest.home',
'app.guest.articles',
'app.guest.sandbox',
'app.guest.error'
'app.guest.error',
'app.guest.login',
])
.config(GuestConfig);

Expand Down
38 changes: 38 additions & 0 deletions app/src/app/guest/login/login.spec.ts
@@ -0,0 +1,38 @@


describe('Login', () => {

describe('Configuration', () => {

let LoginController:ng.IControllerService,
$scope:ng.IScope,
authService:NgJwtAuth.NgJwtAuthService;

beforeEach(() => {

module('app');
});

beforeEach(()=> {
inject(($controller, $rootScope, _ngJwtAuthService_) => {
$scope = $rootScope.$new();
authService = _ngJwtAuthService_;
LoginController = $controller(app.guest.login.namespace+'.controller', {$scope: $scope});
})
});

it('should be a valid controller', () => {

expect(LoginController).to.be.ok;
});

it('should have initialised the auth service', () => {

expect((<any>authService).refreshTimerPromise).to.be.ok;

})


});

});
3 changes: 3 additions & 0 deletions app/src/app/guest/login/login.tpl.html
@@ -0,0 +1,3 @@
<h2>Success!</h2>
<h3>Your build of spira has succeeded</h3>
<md-icon> face </md-icon>
51 changes: 51 additions & 0 deletions app/src/app/guest/login/login.ts
@@ -0,0 +1,51 @@
module app.guest.login {

export const namespace = 'app.guest.login';

class LoginConfig {

static $inject = ['ngJwtAuthServiceProvider'];
constructor(private ngJwtAuthServiceProvider:NgJwtAuth.NgJwtAuthServiceProvider){

let config : NgJwtAuth.INgJwtAuthServiceConfig = {
refreshBeforeSeconds: 60 * 10, //10 mins
checkExpiryEverySeconds: 60, //1 min
};

ngJwtAuthServiceProvider.configure(config);

}

}

class LoginInit {

static $inject = ['ngJwtAuthService'];
constructor(
private ngJwtAuthService:NgJwtAuth.NgJwtAuthService
) {

ngJwtAuthService.init(); //initialise the auth service (kicks off the timers etc)
}

}

interface IScope extends ng.IScope
{
}

class LoginController {

static $inject = ['$scope'];
constructor(private $scope : IScope) {

}

}

angular.module(namespace, [])
.config(LoginConfig)
.run(LoginInit)
.controller(namespace+'.controller', LoginController);

}
2 changes: 1 addition & 1 deletion app/src/config/vendorModules.ts
Expand Up @@ -15,7 +15,7 @@ module config.vendorModules {
'hljs', //syntax highlighted code blocks - https://github.com/pc035860/angular-highlightjs
'ngHttpProgress', //http request progress meter - https://github.com/spira/angular-http-progress
'ngRestAdapter', // api helper methods - https://github.com/spira/angular-rest-adapter
//'ngJwtAuth', // json web token authentication - https://github.com/spira/angular-jwt-auth
'ngJwtAuth', // json web token authentication - https://github.com/spira/angular-jwt-auth
]);

}

0 comments on commit 73b1fb9

Please sign in to comment.