Commit b67e28de authored by Randall Leeds's avatar Randall Leeds Committed by Aron Carroll

Break out callbacks in auth controller

parent 6eaf2e6d
......@@ -8,22 +8,11 @@ class AuthController
constructor: ( $scope, $timeout, session ) ->
timeout = null
this.submit = (form) ->
return unless form.$valid
data = {}
method = '$' + form.$name
for own key of session
delete session[key]
angular.extend session, $scope.model
session[method](
(session) ->
success = ->
$scope.model = null
$scope.$broadcast 'success'
, (response) ->
failure = (form, response) ->
{errors, reason} = response.data
if reason
......@@ -40,7 +29,18 @@ class AuthController
form[field].responseErrorMessage = error
$scope.$broadcast 'error', form.$name
)
this.submit = (form) ->
return unless form.$valid
data = {}
method = '$' + form.$name
for own key of session
delete session[key]
angular.extend session, $scope.model
session[method] success, angular.bind(this, failure, form)
$scope.$on '$destroy', ->
if timeout
......
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