Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
U
ulakbus-ui
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
ulakbus
ulakbus-ui
Commits
69e56e4f
Commit
69e56e4f
authored
Jul 06, 2015
by
Evren Kutar
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
interceptors in seperate file
parent
07e5cc53
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
33 additions
and
24 deletions
+33
-24
app_routes.js
app/app_routes.js
+1
-24
index.html
app/index.html
+1
-0
interceptors.js
app/zetalib/interceptors.js
+31
-0
No files found.
app/app_routes.js
View file @
69e56e4f
...
@@ -174,27 +174,4 @@ app.config(['$routeProvider', function ($routeProvider) {
...
@@ -174,27 +174,4 @@ app.config(['$routeProvider', function ($routeProvider) {
}
}
}
}
});
});
}).
config
([
'$httpProvider'
,
function
(
$httpProvider
)
{
});
/**
\ No newline at end of file
* the interceptor for all requests to check response
* 4xx - 5xx errors will be handled here
*/
$httpProvider
.
interceptors
.
push
(
function
(
$q
)
{
return
{
'response'
:
function
(
response
)
{
//Will only be called for HTTP up to 300
return
response
;
},
'responseError'
:
function
(
rejection
)
{
// if unauthorized then redirect to login page
if
(
rejection
.
status
===
400
)
{
location
.
reload
();
}
if
(
rejection
.
status
===
401
)
{
location
.
path
(
'#/login'
);
}
return
$q
.
reject
(
rejection
);
}
};
});
}]);
\ No newline at end of file
app/index.html
View file @
69e56e4f
...
@@ -84,6 +84,7 @@
...
@@ -84,6 +84,7 @@
<script
type=
"text/javascript"
src=
"bower_components/angular-schema-form/dist/bootstrap-decorator.min.js"
></script>
<script
type=
"text/javascript"
src=
"bower_components/angular-schema-form/dist/bootstrap-decorator.min.js"
></script>
<script
src=
"app.js"
></script>
<script
src=
"app.js"
></script>
<script
src=
"zetalib/interceptors.js"
></script>
<script
src=
"app_routes.js"
></script>
<script
src=
"app_routes.js"
></script>
<!--<script src="zlib/general.js"></script>-->
<!--<script src="zlib/general.js"></script>-->
...
...
app/zetalib/interceptors.js
0 → 100644
View file @
69e56e4f
/**
* Copyright (C) 2015 ZetaOps Inc.
*
* This file is licensed under the GNU General Public License v3
* (GPLv3). See LICENSE.txt for details.
*/
app
.
config
([
'$httpProvider'
,
function
(
$httpProvider
)
{
/**
* the interceptor for all requests to check response
* 4xx - 5xx errors will be handled here
*/
$httpProvider
.
interceptors
.
push
(
function
(
$q
)
{
return
{
'response'
:
function
(
response
)
{
//Will only be called for HTTP up to 300
return
response
;
},
'responseError'
:
function
(
rejection
)
{
// if unauthorized then redirect to login page
if
(
rejection
.
status
===
400
)
{
location
.
reload
();
}
if
(
rejection
.
status
===
401
)
{
location
.
path
(
'#/login'
);
}
return
$q
.
reject
(
rejection
);
}
};
});
}]);
\ No newline at end of file
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment