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
82ba7d0a
Commit
82ba7d0a
authored
Sep 28, 2019
by
Nick
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
feat: import users from v1 - db + create users
parent
41716e52
Expand all
Hide whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
104 additions
and
8 deletions
+104
-8
admin-utilities-importv1.vue
client/components/admin/admin-utilities-importv1.vue
+0
-0
editor-markdown.vue
client/components/editor/editor-markdown.vue
+5
-2
utilities-mutation-importv1-users.gql
...aph/admin/utilities/utilities-mutation-importv1-users.gql
+19
-0
app.scss
client/themes/default/scss/app.scss
+6
-6
system.js
server/graph/resolvers/system.js
+50
-0
system.graphql
server/graph/schemas/system.graphql
+24
-0
No files found.
client/components/admin/admin-utilities-importv1.vue
View file @
82ba7d0a
This diff is collapsed.
Click to expand it.
client/components/editor/editor-markdown.vue
View file @
82ba7d0a
...
...
@@ -597,6 +597,7 @@ $editor-height-mobile: calc(100vh - 112px - 16px);
position: relative;
height: $editor-height;
overflow: hidden;
padding: 1rem;
@at-root .theme--dark & {
background-color: mc('grey', '900');
...
...
@@ -622,8 +623,8 @@ $editor-height-mobile: calc(100vh - 112px - 16px);
&-content {
height: $editor-height;
overflow-y: scroll;
padding:
1rem 1rem 1rem 1rem
;
width: calc(100% + 1
rem + 1
7px);
padding:
0
;
width: calc(100% + 17px);
// -ms-overflow-style: none;
// &::-webkit-scrollbar {
...
...
@@ -701,6 +702,8 @@ $editor-height-mobile: calc(100vh - 112px - 16px);
.CodeMirror {
height: auto;
font-family: 'Roboto Mono', monospace;
font-size: .9rem;
.cm-header-1 {
font-size: 1.5rem;
...
...
client/graph/admin/utilities/utilities-mutation-importv1-users.gql
0 → 100644
View file @
82ba7d0a
mutation
(
$mongoDbConnString
:
String
!,
$groupMode
:
SystemImportUsersGroupMode
!)
{
system
{
importUsersFromV1
(
mongoDbConnString
:
$mongoDbConnString
,
groupMode
:
$groupMode
)
{
responseResult
{
succeeded
errorCode
slug
message
}
usersCount
groupsCount
failed
{
provider
email
error
}
}
}
}
client/themes/default/scss/app.scss
View file @
82ba7d0a
...
...
@@ -196,7 +196,7 @@
// ---------------------------------
p
{
padding
:
1rem
24px
0
24px
;
padding
:
1rem
0
0
0
;
margin
:
0
;
text-align
:
justify
;
...
...
@@ -319,7 +319,7 @@
// ---------------------------------
ol
,
ul
{
padding
:
1rem
24px
0
24px
;
padding
:
1rem
0
0
0
;
list-style-position
:
inside
;
li
+
li
{
...
...
@@ -396,7 +396,7 @@
}
&
.grid-list
{
margin
:
1rem
24px
0
24px
;
margin
:
1rem
0
0
0
;
background-color
:
#FFF
;
border
:
1px
solid
mc
(
'grey'
,
'200'
);
padding
:
1px
;
...
...
@@ -476,7 +476,7 @@
box-shadow
:
initial
;
background-color
:
mc
(
'grey'
,
'900'
);
padding
:
1rem
1rem
1rem
3rem
;
margin
:
1rem
24px
;
margin
:
1rem
0
;
@at-root
.theme--dark
&
{
background-color
:
darken
(
mc
(
'grey'
,
'900'
)
,
5%
);
...
...
@@ -604,12 +604,12 @@
border
:
1px
solid
mc
(
'grey'
,
'400'
);
}
&
.uml-diagram
{
margin
:
1rem
;
margin
:
1rem
0
;
}
}
figure
.image
{
margin
:
1rem
24px
0
24px
;
margin
:
1rem
0
0
0
;
img
{
margin
:
0
auto
;
...
...
server/graph/resolvers/system.js
View file @
82ba7d0a
...
...
@@ -84,6 +84,56 @@ module.exports = {
}
catch
(
err
)
{
return
graphHelper
.
generateError
(
err
)
}
},
async
importUsersFromV1
(
obj
,
args
,
context
)
{
try
{
const
MongoClient
=
require
(
'mongodb'
).
MongoClient
if
(
args
.
mongoDbConnString
&&
args
.
mongoDbConnString
.
length
>
10
)
{
const
client
=
await
MongoClient
.
connect
(
args
.
mongoDbConnString
,
{
appname
:
`Wiki.js
${
WIKI
.
version
}
Migration Tool`
})
const
dbUsers
=
client
.
db
().
collection
(
'users'
)
const
userCursor
=
dbUsers
.
find
({
email
:
{
'$ne'
:
'guest'
}
})
let
failed
=
[]
let
usersCount
=
0
let
groupsCount
=
0
while
(
await
userCursor
.
hasNext
())
{
const
usr
=
await
userCursor
.
next
()
try
{
await
WIKI
.
models
.
users
.
createNewUser
({
providerKey
:
usr
.
provider
,
email
:
usr
.
email
,
name
:
usr
.
name
,
passwordRaw
:
usr
.
password
,
mustChangePassword
:
false
,
sendWelcomeEmail
:
false
})
usersCount
++
}
catch
(
err
)
{
failed
.
push
({
provider
:
usr
.
provider
,
email
:
usr
.
email
,
error
:
err
.
message
})
WIKI
.
logger
.
warn
(
`
${
usr
.
email
}
:
${
err
}
`
)
}
}
client
.
close
()
return
{
responseResult
:
graphHelper
.
generateSuccess
(
'Import completed.'
),
usersCount
:
usersCount
,
groupsCount
:
groupsCount
,
failed
:
failed
}
}
else
{
throw
new
Error
(
'MongoDB Connection String is missing or invalid.'
)
}
}
catch
(
err
)
{
return
graphHelper
.
generateError
(
err
)
}
}
},
SystemInfo
:
{
...
...
server/graph/schemas/system.graphql
View file @
82ba7d0a
...
...
@@ -35,6 +35,11 @@ type SystemMutation {
):
DefaultResponse
@
auth
(
requires
:
[
"
manage
:
system
"
])
performUpgrade
:
DefaultResponse
@
auth
(
requires
:
[
"
manage
:
system
"
])
importUsersFromV1
(
mongoDbConnString
:
String
!
groupMode
:
SystemImportUsersGroupMode
!
):
SystemImportUsersResponse
@
auth
(
requires
:
[
"
manage
:
system
"
])
}
# -----------------------------------------------
...
...
@@ -73,3 +78,22 @@ type SystemInfo {
usersTotal
:
Int
@
auth
(
requires
:
[
"
manage
:
system
"
,
"
manage
:
navigation
"
,
"
manage
:
groups
"
,
"
write
:
groups
"
,
"
manage
:
users
"
,
"
write
:
users
"
])
workingDirectory
:
String
@
auth
(
requires
:
[
"
manage
:
system
"
])
}
enum
SystemImportUsersGroupMode
{
MULTI
SINGLE
NONE
}
type
SystemImportUsersResponse
{
responseResult
:
ResponseStatus
usersCount
:
Int
groupsCount
:
Int
failed
:
[
SystemImportUsersResponseFailed
]
}
type
SystemImportUsersResponseFailed
{
provider
:
String
email
:
String
error
:
String
}
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