mirror of
https://github.com/BoostIo/Boostnote
synced 2025-12-13 01:36:22 +00:00
add http interceptor & register will broadcast userSignIn event
This commit is contained in:
@@ -5,4 +5,18 @@ angular.module('codexen')
|
||||
|
||||
$httpProvider.defaults.useXDomain = true
|
||||
delete $httpProvider.defaults.headers.common['X-Requested-With']
|
||||
$httpProvider.interceptors.push(function ($q, $injector) {
|
||||
return {
|
||||
responseError: function (res) {
|
||||
switch (res.status) {
|
||||
case 401:
|
||||
var $state = $injector.get('$state')
|
||||
$state.go('auth.signin')
|
||||
break
|
||||
}
|
||||
|
||||
return $q.reject(res)
|
||||
}
|
||||
}
|
||||
})
|
||||
})
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
/* global angular */
|
||||
angular.module('codexen')
|
||||
.controller('AuthRegisterController', function ($auth, $log) {
|
||||
.controller('AuthRegisterController', function ($auth, $log, $state, $rootScope) {
|
||||
var vm = this
|
||||
vm.isEmpty = function (obj) {
|
||||
for (var i in obj) if (obj.hasOwnProperty(i)) return false
|
||||
@@ -13,7 +13,8 @@ angular.module('codexen')
|
||||
name: vm.name,
|
||||
profileName: vm.profileName
|
||||
}).then(function (data) {
|
||||
console.log(data)
|
||||
$rootScope.$broadcast('userSignIn')
|
||||
$state.go('home')
|
||||
})
|
||||
}
|
||||
})
|
||||
|
||||
Reference in New Issue
Block a user