Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
synapse
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package registry
Container Registry
Model registry
Operate
Terraform modules
Monitor
Service Desk
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Timo Ley
synapse
Commits
7143f358
Commit
7143f358
authored
10 years ago
by
Emmanuel ROHEE
Browse files
Options
Downloads
Patches
Plain Diff
Detect when the user access token is no more valid and log the user out in this case
parent
613e468b
No related branches found
Branches containing commit
No related tags found
Tags containing commit
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
webclient/app-controller.js
+8
-2
8 additions, 2 deletions
webclient/app-controller.js
webclient/components/matrix/matrix-service.js
+12
-2
12 additions, 2 deletions
webclient/components/matrix/matrix-service.js
with
20 additions
and
4 deletions
webclient/app-controller.js
+
8
−
2
View file @
7143f358
...
...
@@ -55,8 +55,14 @@ angular.module('MatrixWebClientController', ['matrixService'])
// And go to the login page
$location
.
path
(
"
login
"
);
};
};
// Listen to the event indicating that the access token is no more valid.
// In this case, the user needs to log in again.
$scope
.
$on
(
"
M_UNKNOWN_TOKEN
"
,
function
()
{
console
.
log
(
"
Invalid access token -> log user out
"
);
$scope
.
logout
();
});
}]);
\ No newline at end of file
This diff is collapsed.
Click to expand it.
webclient/components/matrix/matrix-service.js
+
12
−
2
View file @
7143f358
...
...
@@ -17,7 +17,7 @@ limitations under the License.
'
use strict
'
;
angular
.
module
(
'
matrixService
'
,
[])
.
factory
(
'
matrixService
'
,
[
'
$http
'
,
'
$q
'
,
function
(
$http
,
$q
)
{
.
factory
(
'
matrixService
'
,
[
'
$http
'
,
'
$q
'
,
'
$rootScope
'
,
function
(
$http
,
$q
,
$rootScope
)
{
/*
* Permanent storage of user information
...
...
@@ -60,7 +60,6 @@ angular.module('matrixService', [])
headers
:
headers
})
.
success
(
function
(
data
,
status
,
headers
,
config
)
{
// @TODO: We could detect a bad access token here and make an automatic logout
deferred
.
resolve
(
data
,
status
,
headers
,
config
);
})
.
error
(
function
(
data
,
status
,
headers
,
config
)
{
...
...
@@ -70,6 +69,11 @@ angular.module('matrixService', [])
reason
=
JSON
.
stringify
(
data
);
}
deferred
.
reject
(
reason
,
data
,
status
,
headers
,
config
);
if
(
403
===
status
&&
"
M_UNKNOWN_TOKEN
"
===
data
.
errcode
)
{
// The access token is no more valid, broadcast the issue
$rootScope
.
$broadcast
(
"
M_UNKNOWN_TOKEN
"
);
}
});
return
deferred
.
promise
;
...
...
@@ -301,6 +305,12 @@ angular.module('matrixService', [])
return
doBaseRequest
(
config
.
identityServer
,
"
POST
"
,
path
,
{},
data
,
headers
);
},
//
testLogin
:
function
()
{
},
/****** Permanent storage of user information ******/
// Returns the current config
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment