Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
What's new
10
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in / Register
Toggle navigation
Open sidebar
Motion Bank
Applications
Systems Frontend
Commits
37c057ea
Commit
37c057ea
authored
Oct 31, 2019
by
Anton
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Always check session before route change
parent
9ed6188a
Pipeline
#19622
passed with stage
in 2 minutes and 16 seconds
Changes
1
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
27 additions
and
36 deletions
+27
-36
src/router/index.js
src/router/index.js
+27
-36
No files found.
src/router/index.js
View file @
37c057ea
...
...
@@ -28,47 +28,38 @@ Router.beforeEach((to, from, next) => {
else
cb
()
}
waitForStore
(
Router
.
app
,
()
=>
{
if
(
!
Router
.
app
.
$store
.
state
.
auth
.
user
)
{
Router
.
app
.
$auth
.
checkSession
(
Router
.
app
.
$store
).
catch
(()
=>
{
if
(
to
.
meta
.
private
)
{
Router
.
app
.
$store
.
commit
(
'
auth/setRedirect
'
,
to
.
fullPath
)
Router
.
app
.
$auth
.
authenticate
()
Router
.
app
.
$auth
.
checkSession
(
Router
.
app
.
$store
).
catch
(()
=>
{
if
(
to
.
meta
.
private
)
{
Router
.
app
.
$store
.
commit
(
'
auth/setRedirect
'
,
to
.
fullPath
)
Router
.
app
.
$auth
.
authenticate
()
}
}).
then
(
result
=>
{
if
(
result
)
{
const
{
user
,
first
}
=
result
if
(
first
)
{
console
.
debug
(
'
Auth0 first login
'
,
user
)
next
({
name
:
'
users.manage
'
,
params
:
{
isFirst
:
true
,
redirect
:
to
}
})
}
}).
then
(
result
=>
{
if
(
result
)
{
const
{
user
,
first
}
=
result
if
(
first
)
{
console
.
debug
(
'
Auth0 first login
'
,
user
)
next
({
name
:
'
users.manage
'
,
params
:
{
isFirst
:
true
,
redirect
:
to
}
})
}
else
{
if
(
to
.
meta
.
feature
)
{
if
(
userHasFeature
(
Router
.
app
.
$store
.
state
.
auth
.
user
,
to
.
meta
.
feature
))
next
()
else
next
({
name
:
'
site.welcome
'
})
}
next
()
else
{
if
(
to
.
meta
.
feature
)
{
if
(
userHasFeature
(
Router
.
app
.
$store
.
state
.
auth
.
user
,
to
.
meta
.
feature
))
next
()
else
next
({
name
:
'
site.welcome
'
})
}
next
()
}
else
if
(
to
.
meta
.
private
)
{
if
(
process
.
env
.
IS_ELECTRON
)
next
()
else
{
Router
.
app
.
$store
.
commit
(
'
auth/setRedirect
'
,
to
.
fullPath
)
Router
.
app
.
$
auth
.
authenticate
(
)
}
}
else
if
(
to
.
meta
.
private
)
{
if
(
process
.
env
.
IS_ELECTRON
)
next
()
else
{
Router
.
app
.
$
store
.
commit
(
'
auth/setRedirect
'
,
to
.
fullPath
)
Router
.
app
.
$auth
.
authenticate
()
}
else
next
()
}).
catch
(
err
=>
{
Router
.
app
.
$captureException
(
err
)
Router
.
app
.
$auth
.
logout
()
})
}
else
{
if
(
to
.
meta
.
feature
)
{
if
(
userHasFeature
(
Router
.
app
.
$store
.
state
.
auth
.
user
,
to
.
meta
.
feature
))
next
()
else
next
({
name
:
'
site.welcome
'
})
}
next
()
}
else
next
()
}).
catch
(
err
=>
{
Router
.
app
.
$captureException
(
err
)
Router
.
app
.
$auth
.
logout
()
})
})
})
...
...
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