Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
G
Géocontrib Frontend
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Redmine
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Deploy
Releases
Package Registry
Container Registry
Model registry
Operate
Terraform modules
Analyze
Contributor 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
GéoContrib
Géocontrib Frontend
Commits
0dbcb8e5
Commit
0dbcb8e5
authored
1 year ago
by
Timothee P
Browse files
Options
Downloads
Patches
Plain Diff
get token in url and login user by calling new api endpoint
parent
4e7c34e3
No related branches found
No related tags found
1 merge request
!591
REDMINE_ISSUE-17472 | Connexion annuaire MRN WP et GéoContrib
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
src/store/index.js
+19
-2
19 additions, 2 deletions
src/store/index.js
with
19 additions
and
2 deletions
src/store/index.js
+
19
−
2
View file @
0dbcb8e5
...
...
@@ -54,7 +54,7 @@ export default new Vuex.Store({
SET_CONFIG
(
state
,
payload
)
{
state
.
configuration
=
payload
;
},
SET_COOKIE
(
state
,
cookie
)
{
SET_COOKIE
(
state
,
cookie
)
{
// ! not called anywhere. Delete it ?
state
.
cookie
=
cookie
;
},
SET_STATIC_PAGES
(
state
,
staticPages
)
{
...
...
@@ -175,7 +175,7 @@ export default new Vuex.Store({
}
},
USER_INFO
({
state
,
commit
})
{
USER_INFO
({
state
,
commit
,
dispatch
})
{
if
(
!
state
.
user
)
{
axios
.
get
(
`
${
this
.
state
.
configuration
.
VUE_APP_DJANGO_API_BASE
}
user_info/`
)
...
...
@@ -187,6 +187,7 @@ export default new Vuex.Store({
})
.
catch
(()
=>
{
//* if an url to redirect to an external authentification system is present, do not redirect to the login page
const
token
=
new
URLSearchParams
(
window
.
location
.
search
).
get
(
'
token
'
);
if
(
!
state
.
configuration
.
VUE_APP_LOGIN_URL
)
{
const
url
=
window
.
location
.
href
;
if
(
url
.
includes
(
'
projet-partage
'
))
{
...
...
@@ -195,11 +196,27 @@ export default new Vuex.Store({
}
else
{
router
.
push
({
name
:
'
login
'
});
}
}
else
if
(
token
)
{
dispatch
(
'
CONNECT_SSO_WITH_TOKEN
'
,
token
);
}
});
}
},
async
CONNECT_SSO_WITH_TOKEN
({
commit
},
token
)
{
axios
.
get
(
`
${
this
.
state
.
configuration
.
VUE_APP_DJANGO_API_BASE
}
login-token/?token=
${
token
}
`
)
.
then
((
response
)
=>
{
if
(
response
&&
(
response
.
status
===
200
||
response
.
status
===
201
))
{
const
user
=
response
.
data
;
commit
(
'
SET_USER
'
,
user
);
}
})
.
catch
((
err
)
=>
{
console
.
error
(
err
);
})
},
async
GET_USER_TOKEN
({
commit
})
{
const
response
=
await
axios
.
get
(
`
${
this
.
state
.
configuration
.
VUE_APP_DJANGO_API_BASE
}
get-token`
);
if
(
...
...
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