Commit 11e809f7 authored by Randall Leeds's avatar Randall Leeds

Eliminate the explicit account module

Angular is smart enough to not instantiate the application until all
pending scripts have been loaded. That means that we can load optional
components by simply appending the script tags. We already load the
account component after the app component. By having the account
component attach its controllers and configuration functions to the
existing 'h' module, rather than defining a new angular module, the
app can avoid having a dependency on 'h.account'. This removes the
requirement that integrators define this module. Instead, they can
just attach a configuration function to the main module if they need
to configure the identity provider.

I have a mild preference for this pattern, since strictly speaking no
account module needs to be present. With a little morke tweaking, the
interface could be made to not have a sign in link and operate in an
anonymous mode by default, assuming that the server requires no
authorization to annotate.
parent 90c39fef
...@@ -87,5 +87,5 @@ class AccountController ...@@ -87,5 +87,5 @@ class AccountController
angular.module('h.account') angular.module('h')
.controller('AccountController', AccountController) .controller('AccountController', AccountController)
imports = [
'ngRoute'
'h.identity'
'h.helpers'
'h.session'
]
AUTH_SESSION_ACTIONS = [ AUTH_SESSION_ACTIONS = [
'login' 'login'
'logout' 'logout'
...@@ -126,6 +119,7 @@ configure = [ ...@@ -126,6 +119,7 @@ configure = [
] ]
angular.module('h.account', imports, configure) angular.module('h')
.config(configure)
.controller('AuthAppController', AuthAppController) .controller('AuthAppController', AuthAppController)
.controller('AuthPageController', AuthPageController) .controller('AuthPageController', AuthPageController)
...@@ -53,5 +53,5 @@ class AuthController ...@@ -53,5 +53,5 @@ class AuthController
, 300000 , 300000
angular.module('h.account') angular.module('h')
.controller('AuthController', AuthController) .controller('AuthController', AuthController)
...@@ -3,7 +3,6 @@ imports = [ ...@@ -3,7 +3,6 @@ imports = [
'ngRoute' 'ngRoute'
'ngSanitize' 'ngSanitize'
'ngTagsInput' 'ngTagsInput'
'h.account'
'h.helpers' 'h.helpers'
'h.identity' 'h.identity'
'h.session' 'h.session'
......
...@@ -2,7 +2,7 @@ assert = chai.assert ...@@ -2,7 +2,7 @@ assert = chai.assert
sinon.assert.expose assert, prefix: null sinon.assert.expose assert, prefix: null
sandbox = sinon.sandbox.create() sandbox = sinon.sandbox.create()
describe 'h.account.AccountController', -> describe 'AccountController', ->
$scope = null $scope = null
fakeFlash = null fakeFlash = null
fakeSession = null fakeSession = null
...@@ -14,7 +14,7 @@ describe 'h.account.AccountController', -> ...@@ -14,7 +14,7 @@ describe 'h.account.AccountController', ->
profilePromise = null profilePromise = null
createController = null createController = null
beforeEach module('h.account') beforeEach module('h')
beforeEach module ($provide, $filterProvider) -> beforeEach module ($provide, $filterProvider) ->
fakeSession = {} fakeSession = {}
......
...@@ -19,8 +19,13 @@ class MockSession ...@@ -19,8 +19,13 @@ class MockSession
mockFlash = sandbox.spy() mockFlash = sandbox.spy()
mockFormHelpers = applyValidationErrors: sandbox.spy() mockFormHelpers = applyValidationErrors: sandbox.spy()
describe 'h.account', -> describe 'AuthController', ->
beforeEach module('h.account') $scope = null
$timeout = null
auth = null
session = null
beforeEach module('h')
beforeEach module('h.templates') beforeEach module('h.templates')
beforeEach module ($provide) -> beforeEach module ($provide) ->
...@@ -30,15 +35,6 @@ describe 'h.account', -> ...@@ -30,15 +35,6 @@ describe 'h.account', ->
$provide.value 'formHelpers', mockFormHelpers $provide.value 'formHelpers', mockFormHelpers
return return
afterEach ->
sandbox.restore()
describe 'AuthController', ->
$scope = null
$timeout = null
auth = null
session = null
beforeEach inject ($controller, $rootScope, _$timeout_, _session_) -> beforeEach inject ($controller, $rootScope, _$timeout_, _session_) ->
$scope = $rootScope.$new() $scope = $rootScope.$new()
$timeout = _$timeout_ $timeout = _$timeout_
...@@ -46,6 +42,9 @@ describe 'h.account', -> ...@@ -46,6 +42,9 @@ describe 'h.account', ->
session = _session_ session = _session_
sandbox.spy session, 'login' sandbox.spy session, 'login'
afterEach ->
sandbox.restore()
describe '#submit()', -> describe '#submit()', ->
it 'should call session methods on submit', -> it 'should call session methods on submit', ->
......
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