Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
W
wiki-js
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
1
Issues
1
List
Board
Labels
Milestones
Merge Requests
1
Merge Requests
1
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Registry
Registry
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Jacklull
wiki-js
Commits
10f17c57
Commit
10f17c57
authored
Jul 19, 2020
by
NGPixel
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
feat: redirect on login based on group
parent
be499e57
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
17 additions
and
4 deletions
+17
-4
admin-groups-edit.vue
client/components/admin/admin-groups-edit.vue
+1
-1
login.vue
client/components/login.vue
+3
-0
authentication.graphql
server/graph/schemas/authentication.graphql
+1
-0
users.js
server/models/users.js
+12
-3
No files found.
client/components/admin/admin-groups-edit.vue
View file @
10f17c57
...
...
@@ -61,7 +61,7 @@
style='max-width: 600px;'
:disabled='group.id <= 2'
)
template(v-if='group.id
>
2')
template(v-if='group.id
!==
2')
v-divider
v-card-text
v-text-field(
...
...
client/components/login.vue
View file @
10f17c57
...
...
@@ -350,6 +350,7 @@ export default {
mustChangePwd
mustProvideTFA
continuationToken
redirect
}
}
}
...
...
@@ -386,6 +387,8 @@ export default {
if
(
loginRedirect
)
{
Cookies
.
remove
(
'loginRedirect'
)
window
.
location
.
replace
(
loginRedirect
)
}
else
if
(
respObj
.
redirect
)
{
window
.
location
.
replace
(
respObj
.
redirect
)
}
else
{
window
.
location
.
replace
(
'/'
)
}
...
...
server/graph/schemas/authentication.graphql
View file @
10f17c57
...
...
@@ -109,6 +109,7 @@ type AuthenticationLoginResponse {
mustChangePwd
:
Boolean
mustProvideTFA
:
Boolean
continuationToken
:
String
redirect
:
String
}
type
AuthenticationRegisterResponse
{
...
...
server/models/users.js
View file @
10f17c57
...
...
@@ -281,6 +281,13 @@ module.exports = class User extends Model {
if
(
err
)
{
return
reject
(
err
)
}
if
(
!
user
)
{
return
reject
(
new
WIKI
.
Error
.
AuthLoginFailed
())
}
// Get redirect target
user
.
groups
=
await
user
.
$relatedQuery
(
'groups'
).
select
(
'groups.id'
,
'permissions'
,
'redirectOnLogin'
)
let
redirect
=
'/'
if
(
user
.
groups
&&
user
.
groups
.
length
>
0
)
{
redirect
=
user
.
groups
[
0
].
redirectOnLogin
}
// Must Change Password?
if
(
user
.
mustChangePwd
)
{
try
{
...
...
@@ -291,7 +298,8 @@ module.exports = class User extends Model {
return
resolve
({
mustChangePwd
:
true
,
continuationToken
:
pwdChangeToken
continuationToken
:
pwdChangeToken
,
redirect
})
}
catch
(
errc
)
{
WIKI
.
logger
.
warn
(
errc
)
...
...
@@ -308,7 +316,8 @@ module.exports = class User extends Model {
})
return
resolve
({
tfaRequired
:
true
,
continuationToken
:
tfaToken
continuationToken
:
tfaToken
,
redirect
})
}
catch
(
errc
)
{
WIKI
.
logger
.
warn
(
errc
)
...
...
@@ -319,7 +328,7 @@ module.exports = class User extends Model {
context
.
req
.
logIn
(
user
,
{
session
:
!
strInfo
.
useForm
},
async
errc
=>
{
if
(
errc
)
{
return
reject
(
errc
)
}
const
jwtToken
=
await
WIKI
.
models
.
users
.
refreshToken
(
user
)
resolve
({
jwt
:
jwtToken
.
token
})
resolve
({
jwt
:
jwtToken
.
token
,
redirect
})
})
})(
context
.
req
,
context
.
res
,
()
=>
{})
})
...
...
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