feat: admin general + verify account
This commit is contained in:
parent
2b98a5f27a
commit
fcee4c0945
@ -80,7 +80,7 @@ const graphQLLink = ApolloLink.from([
|
|||||||
})
|
})
|
||||||
}
|
}
|
||||||
}),
|
}),
|
||||||
createPersistedQueryLink(),
|
// createPersistedQueryLink(),
|
||||||
new BatchHttpLink({
|
new BatchHttpLink({
|
||||||
includeExtensions: true,
|
includeExtensions: true,
|
||||||
uri: graphQLEndpoint,
|
uri: graphQLEndpoint,
|
||||||
|
@ -22,11 +22,21 @@
|
|||||||
v-subheader General
|
v-subheader General
|
||||||
.px-3.pb-3
|
.px-3.pb-3
|
||||||
v-text-field(
|
v-text-field(
|
||||||
|
outline
|
||||||
|
label='Site URL'
|
||||||
|
required
|
||||||
|
:counter='255'
|
||||||
|
v-model='config.host'
|
||||||
|
prepend-icon='label_important'
|
||||||
|
hint='Full URL to your wiki, without the trailing slash. (e.g. https://wiki.example.com)'
|
||||||
|
persistent-hint
|
||||||
|
)
|
||||||
|
v-text-field.mt-2(
|
||||||
outline
|
outline
|
||||||
label='Site Title'
|
label='Site Title'
|
||||||
required
|
required
|
||||||
:counter='50'
|
:counter='50'
|
||||||
v-model='siteTitle'
|
v-model='config.title'
|
||||||
prepend-icon='public'
|
prepend-icon='public'
|
||||||
)
|
)
|
||||||
v-divider
|
v-divider
|
||||||
@ -36,22 +46,28 @@
|
|||||||
outline
|
outline
|
||||||
label='Site Description'
|
label='Site Description'
|
||||||
:counter='255'
|
:counter='255'
|
||||||
prepend-icon='public'
|
v-model='config.description'
|
||||||
|
prepend-icon='explore'
|
||||||
)
|
)
|
||||||
v-text-field(
|
v-text-field(
|
||||||
outline
|
outline
|
||||||
label='Site Keywords'
|
label='Site Keywords'
|
||||||
:counter='255'
|
:counter='255'
|
||||||
prepend-icon='public'
|
v-model='config.keywords'
|
||||||
|
prepend-icon='explore'
|
||||||
|
hint='Comma-separated list of keywords.'
|
||||||
|
persistent-hint
|
||||||
)
|
)
|
||||||
v-select(
|
v-select.mt-2(
|
||||||
outline
|
outline
|
||||||
label='Meta Robots'
|
label='Meta Robots'
|
||||||
chips
|
multiple
|
||||||
tags
|
|
||||||
:items='metaRobots'
|
:items='metaRobots'
|
||||||
v-model='metaRobotsSelection'
|
v-model='config.robots'
|
||||||
prepend-icon='public'
|
prepend-icon='explore'
|
||||||
|
:return-object='false'
|
||||||
|
hint='Default: Index, Follow'
|
||||||
|
persistent-hint
|
||||||
)
|
)
|
||||||
v-divider
|
v-divider
|
||||||
v-subheader Analytics
|
v-subheader Analytics
|
||||||
@ -60,30 +76,20 @@
|
|||||||
outline
|
outline
|
||||||
label='Google Analytics ID'
|
label='Google Analytics ID'
|
||||||
:counter='255'
|
:counter='255'
|
||||||
|
v-model='config.ga'
|
||||||
prepend-icon='timeline'
|
prepend-icon='timeline'
|
||||||
persistent-hint
|
persistent-hint
|
||||||
hint='Property tracking ID for Google Analytics.'
|
hint='Property tracking ID for Google Analytics. Leave empty to disable.'
|
||||||
)
|
|
||||||
v-divider
|
|
||||||
v-subheader Footer Copyright
|
|
||||||
.px-3.pb-3
|
|
||||||
v-text-field(
|
|
||||||
outline
|
|
||||||
label='Company / Organization Name'
|
|
||||||
v-model='company'
|
|
||||||
:counter='255'
|
|
||||||
prepend-icon='business'
|
|
||||||
persistent-hint
|
|
||||||
hint='Name to use when displaying copyright notice in the footer. Leave empty to hide.'
|
|
||||||
)
|
)
|
||||||
v-flex(lg6 xs12)
|
v-flex(lg6 xs12)
|
||||||
v-card.wiki-form
|
v-card.wiki-form
|
||||||
v-toolbar(color='primary', dark, dense, flat)
|
v-toolbar(color='primary', dark, dense, flat)
|
||||||
v-toolbar-title
|
v-toolbar-title
|
||||||
.subheading {{ $t('admin:general.siteBranding') }}
|
.subheading {{ $t('admin:general.siteBranding') }}
|
||||||
|
v-subheader Logo
|
||||||
v-card-text
|
v-card-text
|
||||||
v-layout.pa-3(row, align-center)
|
v-layout.px-3(row, align-center)
|
||||||
v-avatar(size='120', color='grey lighten-3', :tile='useSquareLogo')
|
v-avatar(size='120', color='grey lighten-3', :tile='config.logoIsSquare')
|
||||||
.ml-4
|
.ml-4
|
||||||
v-layout(row, align-center)
|
v-layout(row, align-center)
|
||||||
v-btn(color='teal', depressed, dark)
|
v-btn(color='teal', depressed, dark)
|
||||||
@ -95,19 +101,23 @@
|
|||||||
.caption.grey--text An image of 120x120 pixels is recommended for best results.
|
.caption.grey--text An image of 120x120 pixels is recommended for best results.
|
||||||
.caption.grey--text SVG, PNG or JPG files only.
|
.caption.grey--text SVG, PNG or JPG files only.
|
||||||
v-switch(
|
v-switch(
|
||||||
v-model='useSquareLogo'
|
v-model='config.logoIsSquare'
|
||||||
label='Use Square Logo Frame'
|
label='Use Square Logo Frame'
|
||||||
color='primary'
|
color='primary'
|
||||||
persistent-hint
|
persistent-hint
|
||||||
hint='Check this option if a round logo frame doesn\'t work with your logo.'
|
hint='Check this option if a round logo frame doesn\'t work with your logo.'
|
||||||
)
|
)
|
||||||
v-divider.mt-3
|
v-divider
|
||||||
v-switch(
|
v-subheader Footer Copyright
|
||||||
v-model='displayMascot'
|
.px-3.pb-3
|
||||||
label='Display Wiki.js Mascot'
|
v-text-field(
|
||||||
color='primary'
|
outline
|
||||||
|
label='Company / Organization Name'
|
||||||
|
v-model='config.company'
|
||||||
|
:counter='255'
|
||||||
|
prepend-icon='business'
|
||||||
persistent-hint
|
persistent-hint
|
||||||
hint='Uncheck this box if you don\'t want Henry, Wiki.js mascot, to be displayed on client-facing pages.'
|
hint='Name to use when displaying copyright notice in the footer. Leave empty to hide.'
|
||||||
)
|
)
|
||||||
|
|
||||||
v-card.wiki-form.mt-3
|
v-card.wiki-form.mt-3
|
||||||
@ -116,17 +126,25 @@
|
|||||||
.subheading Features
|
.subheading Features
|
||||||
v-card-text
|
v-card-text
|
||||||
v-switch(
|
v-switch(
|
||||||
v-model='featurePageRatings'
|
|
||||||
label='Page Ratings'
|
label='Page Ratings'
|
||||||
color='primary'
|
color='primary'
|
||||||
|
v-model='config.featurePageRatings'
|
||||||
persistent-hint
|
persistent-hint
|
||||||
hint='Allow users to rate pages.'
|
hint='Allow users to rate pages.'
|
||||||
)
|
)
|
||||||
v-divider.mt-3
|
v-divider.mt-3
|
||||||
v-switch(
|
v-switch(
|
||||||
v-model='featurePersonalWiki'
|
label='Page Comments'
|
||||||
|
color='primary'
|
||||||
|
v-model='config.featurePageComments'
|
||||||
|
persistent-hint
|
||||||
|
hint='Allow users to leave comments on pages.'
|
||||||
|
)
|
||||||
|
v-divider.mt-3
|
||||||
|
v-switch(
|
||||||
label='Personal Wikis'
|
label='Personal Wikis'
|
||||||
color='primary'
|
color='primary'
|
||||||
|
v-model='config.featurePersonalWikis'
|
||||||
persistent-hint
|
persistent-hint
|
||||||
hint='Allow users to have their own personal wiki.'
|
hint='Allow users to have their own personal wiki.'
|
||||||
)
|
)
|
||||||
@ -134,18 +152,34 @@
|
|||||||
</template>
|
</template>
|
||||||
|
|
||||||
<script>
|
<script>
|
||||||
|
import _ from 'lodash'
|
||||||
import { get, sync } from 'vuex-pathify'
|
import { get, sync } from 'vuex-pathify'
|
||||||
|
import siteConfigQuery from 'gql/admin/site/site-query-config.gql'
|
||||||
|
import siteUpdateConfigMutation from 'gql/admin/site/site-mutation-save-config.gql'
|
||||||
|
|
||||||
export default {
|
export default {
|
||||||
data() {
|
data() {
|
||||||
return {
|
return {
|
||||||
metaRobotsSelection: ['Index', 'Follow'],
|
metaRobots: [
|
||||||
metaRobots: ['Index', 'Follow', 'No Index', 'No Follow'],
|
{ text: 'Index', value: 'index' },
|
||||||
useSquareLogo: false,
|
{ text: 'Follow', value: 'follow' },
|
||||||
displayMascot: true,
|
{ text: 'No Index', value: 'noindex' },
|
||||||
featurePageRatings: true,
|
{ text: 'No Follow', value: 'nofollow' }
|
||||||
featurePersonalWiki: true
|
],
|
||||||
|
config: {
|
||||||
|
host: '',
|
||||||
|
title: '',
|
||||||
|
description: '',
|
||||||
|
keywords: '',
|
||||||
|
robots: [],
|
||||||
|
ga: '',
|
||||||
|
company: '',
|
||||||
|
hasLogo: false,
|
||||||
|
logoIsSquare: false,
|
||||||
|
featurePageRatings: false,
|
||||||
|
featurePageComments: false,
|
||||||
|
featurePersonalWikis: false
|
||||||
|
}
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
computed: {
|
computed: {
|
||||||
@ -155,11 +189,51 @@ export default {
|
|||||||
},
|
},
|
||||||
methods: {
|
methods: {
|
||||||
async save () {
|
async save () {
|
||||||
|
try {
|
||||||
|
await this.$apollo.mutate({
|
||||||
|
mutation: siteUpdateConfigMutation,
|
||||||
|
variables: {
|
||||||
|
host: this.config.host || '',
|
||||||
|
title: this.config.title || '',
|
||||||
|
description: this.config.description || '',
|
||||||
|
keywords: this.config.keywords || '',
|
||||||
|
robots: this.config.robots || [],
|
||||||
|
ga: this.config.ga || '',
|
||||||
|
company: this.config.company || '',
|
||||||
|
hasLogo: this.config.hasLogo || false,
|
||||||
|
logoIsSquare: this.config.logoIsSquare || false,
|
||||||
|
featurePageRatings: this.config.featurePageRatings || false,
|
||||||
|
featurePageComments: this.config.featurePageComments || false,
|
||||||
|
featurePersonalWikis: this.config.featurePersonalWikis || false
|
||||||
|
},
|
||||||
|
watchLoading (isLoading) {
|
||||||
|
this.$store.commit(`loading${isLoading ? 'Start' : 'Stop'}`, 'admin-site-update')
|
||||||
|
}
|
||||||
|
})
|
||||||
this.$store.commit('showNotification', {
|
this.$store.commit('showNotification', {
|
||||||
message: 'Configuration saved successfully.',
|
|
||||||
style: 'success',
|
style: 'success',
|
||||||
|
message: 'Configuration saved successfully.',
|
||||||
icon: 'check'
|
icon: 'check'
|
||||||
})
|
})
|
||||||
|
this.siteTitle = this.config.title
|
||||||
|
this.company = this.config.company
|
||||||
|
} catch (err) {
|
||||||
|
this.$store.commit('showNotification', {
|
||||||
|
style: 'red',
|
||||||
|
message: err.message,
|
||||||
|
icon: 'warning'
|
||||||
|
})
|
||||||
|
}
|
||||||
|
}
|
||||||
|
},
|
||||||
|
apollo: {
|
||||||
|
config: {
|
||||||
|
query: siteConfigQuery,
|
||||||
|
fetchPolicy: 'network-only',
|
||||||
|
update: (data) => _.cloneDeep(data.site.config),
|
||||||
|
watchLoading (isLoading) {
|
||||||
|
this.$store.commit(`loading${isLoading ? 'Start' : 'Stop'}`, 'admin-site-refresh')
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -82,6 +82,7 @@
|
|||||||
item-text='name'
|
item-text='name'
|
||||||
:label='$t("admin:locale.activeNamespaces.label")'
|
:label='$t("admin:locale.activeNamespaces.label")'
|
||||||
persistent-hint
|
persistent-hint
|
||||||
|
small-chips
|
||||||
:hint='$t("admin:locale.activeNamespaces.hint")'
|
:hint='$t("admin:locale.activeNamespaces.hint")'
|
||||||
)
|
)
|
||||||
template(slot='item', slot-scope='data')
|
template(slot='item', slot-scope='data')
|
||||||
|
@ -3,10 +3,12 @@
|
|||||||
v-card.loader-dialog.radius-7(:color='color', dark)
|
v-card.loader-dialog.radius-7(:color='color', dark)
|
||||||
v-card-text.text-xs-center.py-4
|
v-card-text.text-xs-center.py-4
|
||||||
atom-spinner.is-inline(
|
atom-spinner.is-inline(
|
||||||
|
v-if='mode === `loading`'
|
||||||
:animation-duration='1000'
|
:animation-duration='1000'
|
||||||
:size='60'
|
:size='60'
|
||||||
color='#FFF'
|
color='#FFF'
|
||||||
)
|
)
|
||||||
|
img(v-else-if='mode === `icon`', :src='`/svg/icon-` + icon + `.svg`', :alt='icon')
|
||||||
.subheading {{ title }}
|
.subheading {{ title }}
|
||||||
.caption {{ subtitle }}
|
.caption {{ subtitle }}
|
||||||
</template>
|
</template>
|
||||||
@ -34,6 +36,14 @@ export default {
|
|||||||
subtitle: {
|
subtitle: {
|
||||||
type: String,
|
type: String,
|
||||||
default: 'Please wait'
|
default: 'Please wait'
|
||||||
|
},
|
||||||
|
mode: {
|
||||||
|
type: String,
|
||||||
|
default: 'loading'
|
||||||
|
},
|
||||||
|
icon: {
|
||||||
|
type: String,
|
||||||
|
default: 'checkmark'
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -47,5 +57,9 @@ export default {
|
|||||||
.caption {
|
.caption {
|
||||||
color: rgba(255,255,255,.7);
|
color: rgba(255,255,255,.7);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
img {
|
||||||
|
width: 80px;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
</style>
|
</style>
|
||||||
|
@ -90,7 +90,7 @@
|
|||||||
a.caption(href='/login', place='link') {{ $t('auth:switchToLogin.link') }}
|
a.caption(href='/login', place='link') {{ $t('auth:switchToLogin.link') }}
|
||||||
v-spacer
|
v-spacer
|
||||||
|
|
||||||
loader(v-model='isLoading', :color='loaderColor', :title='loaderTitle', :subtitle='$t(`auth:pleaseWait`)')
|
loader(v-model='isLoading', :mode='loaderMode', :icon='loaderIcon', :color='loaderColor', :title='loaderTitle', :subtitle='loaderSubtitle')
|
||||||
nav-footer(color='grey darken-4', dark-color='grey darken-4')
|
nav-footer(color='grey darken-4', dark-color='grey darken-4')
|
||||||
</template>
|
</template>
|
||||||
|
|
||||||
@ -119,7 +119,10 @@ export default {
|
|||||||
isLoading: false,
|
isLoading: false,
|
||||||
isShown: false,
|
isShown: false,
|
||||||
loaderColor: 'grey darken-4',
|
loaderColor: 'grey darken-4',
|
||||||
loaderTitle: 'Working...'
|
loaderTitle: 'Working...',
|
||||||
|
loaderSubtitle: 'Please wait',
|
||||||
|
loaderMode: 'icon',
|
||||||
|
loaderIcon: 'checkmark'
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
computed: {
|
computed: {
|
||||||
@ -131,6 +134,7 @@ export default {
|
|||||||
this.isShown = true
|
this.isShown = true
|
||||||
this.$nextTick(() => {
|
this.$nextTick(() => {
|
||||||
this.$refs.iptEmail.focus()
|
this.$refs.iptEmail.focus()
|
||||||
|
|
||||||
})
|
})
|
||||||
},
|
},
|
||||||
methods: {
|
methods: {
|
||||||
@ -216,6 +220,8 @@ export default {
|
|||||||
} else {
|
} else {
|
||||||
this.loaderColor = 'grey darken-4'
|
this.loaderColor = 'grey darken-4'
|
||||||
this.loaderTitle = this.$t('auth:registering')
|
this.loaderTitle = this.$t('auth:registering')
|
||||||
|
this.loaderSubtitle = this.$t(`auth:pleaseWait`)
|
||||||
|
this.loaderMode = 'loading'
|
||||||
this.isLoading = true
|
this.isLoading = true
|
||||||
try {
|
try {
|
||||||
let resp = await this.$apollo.mutate({
|
let resp = await this.$apollo.mutate({
|
||||||
@ -229,12 +235,11 @@ export default {
|
|||||||
if (_.has(resp, 'data.authentication.register')) {
|
if (_.has(resp, 'data.authentication.register')) {
|
||||||
let respObj = _.get(resp, 'data.authentication.register', {})
|
let respObj = _.get(resp, 'data.authentication.register', {})
|
||||||
if (respObj.responseResult.succeeded === true) {
|
if (respObj.responseResult.succeeded === true) {
|
||||||
this.loaderColor = 'green'
|
this.loaderColor = 'grey darken-4'
|
||||||
this.loaderTitle = this.$t('auth:registerSuccess')
|
this.loaderTitle = this.$t('auth:registerSuccess')
|
||||||
Cookies.set('jwt', respObj.jwt, { expires: 365 })
|
this.loaderSubtitle = this.$t(`auth:registerCheckEmail`)
|
||||||
_.delay(() => {
|
this.loaderMode = 'icon'
|
||||||
window.location.replace('/')
|
this.isShown = false
|
||||||
}, 1000)
|
|
||||||
} else {
|
} else {
|
||||||
throw new Error(respObj.responseResult.message)
|
throw new Error(respObj.responseResult.message)
|
||||||
}
|
}
|
||||||
|
38
client/graph/admin/site/site-mutation-save-config.gql
Normal file
38
client/graph/admin/site/site-mutation-save-config.gql
Normal file
@ -0,0 +1,38 @@
|
|||||||
|
mutation (
|
||||||
|
$host: String!
|
||||||
|
$title: String!
|
||||||
|
$description: String!
|
||||||
|
$keywords: String!
|
||||||
|
$robots: [String]!
|
||||||
|
$ga: String!
|
||||||
|
$company: String!
|
||||||
|
$hasLogo: Boolean!
|
||||||
|
$logoIsSquare: Boolean!
|
||||||
|
$featurePageRatings: Boolean!
|
||||||
|
$featurePageComments: Boolean!
|
||||||
|
$featurePersonalWikis: Boolean!
|
||||||
|
) {
|
||||||
|
site {
|
||||||
|
updateConfig(
|
||||||
|
host: $host,
|
||||||
|
title: $title,
|
||||||
|
description: $description,
|
||||||
|
keywords: $keywords,
|
||||||
|
robots: $robots,
|
||||||
|
ga: $ga,
|
||||||
|
company: $company,
|
||||||
|
hasLogo: $hasLogo,
|
||||||
|
logoIsSquare: $logoIsSquare,
|
||||||
|
featurePageRatings: $featurePageRatings,
|
||||||
|
featurePageComments: $featurePageComments,
|
||||||
|
featurePersonalWikis: $featurePersonalWikis
|
||||||
|
) {
|
||||||
|
responseResult {
|
||||||
|
succeeded
|
||||||
|
errorCode
|
||||||
|
slug
|
||||||
|
message
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
18
client/graph/admin/site/site-query-config.gql
Normal file
18
client/graph/admin/site/site-query-config.gql
Normal file
@ -0,0 +1,18 @@
|
|||||||
|
{
|
||||||
|
site {
|
||||||
|
config {
|
||||||
|
host
|
||||||
|
title
|
||||||
|
description
|
||||||
|
keywords
|
||||||
|
robots
|
||||||
|
ga
|
||||||
|
company
|
||||||
|
hasLogo
|
||||||
|
logoIsSquare
|
||||||
|
featurePageRatings
|
||||||
|
featurePageComments
|
||||||
|
featurePersonalWikis
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
14
client/static/svg/icon-checkmark.svg
Normal file
14
client/static/svg/icon-checkmark.svg
Normal file
@ -0,0 +1,14 @@
|
|||||||
|
<?xml version="1.0" encoding="iso-8859-1"?>
|
||||||
|
<!-- Generator: Adobe Illustrator 20.1.0, SVG Export Plug-In . SVG Version: 6.00 Build 0) -->
|
||||||
|
<svg xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" version="1.1" id="Слой_1" x="0px" y="0px" viewBox="0 0 64 64" style="enable-background:new 0 0 64 64;" xml:space="preserve" width="64px" height="64px">
|
||||||
|
<linearGradient id="SVGID_1__48003" gradientUnits="userSpaceOnUse" x1="32" y1="12.6636" x2="32" y2="52.4219" spreadMethod="reflect">
|
||||||
|
<stop offset="0" style="stop-color:#1A6DFF"/>
|
||||||
|
<stop offset="1" style="stop-color:#C822FF"/>
|
||||||
|
</linearGradient>
|
||||||
|
<path style="fill:url(#SVGID_1__48003);" d="M24.982,51c-1.273,0-2.547-0.475-3.524-1.429L6.888,35.364C6.315,34.806,6,34.061,6,33.268 s0.315-1.538,0.889-2.097l2.82-2.75c1.166-1.137,3.063-1.137,4.228,0.001l10.259,10.003c0.395,0.385,1.058,0.38,1.446-0.012 l24.341-24.526c1.147-1.156,3.044-1.186,4.228-0.068l2.867,2.705c0.582,0.55,0.91,1.29,0.923,2.083 c0.013,0.793-0.291,1.542-0.854,2.109L28.565,49.514C27.584,50.504,26.283,51,24.982,51z M11.822,29.564 c-0.26,0-0.52,0.097-0.717,0.29l-2.82,2.75C8.101,32.783,8,33.018,8,33.268s0.102,0.485,0.285,0.664l14.569,14.208 c1.19,1.163,3.116,1.148,4.291-0.034l28.581-28.798c0.181-0.182,0.277-0.418,0.273-0.668c-0.004-0.25-0.109-0.485-0.296-0.661 l-2.867-2.705c-0.401-0.381-1.047-0.369-1.435,0.022L27.061,39.823c-1.166,1.173-3.079,1.189-4.263,0.034L12.54,29.853 C12.343,29.66,12.083,29.564,11.822,29.564z"/>
|
||||||
|
<linearGradient id="SVGID_2__48003" gradientUnits="userSpaceOnUse" x1="32.0125" y1="16.8302" x2="32.0125" y2="47.5263" spreadMethod="reflect">
|
||||||
|
<stop offset="0" style="stop-color:#6DC7FF"/>
|
||||||
|
<stop offset="1" style="stop-color:#E6ABFF"/>
|
||||||
|
</linearGradient>
|
||||||
|
<path style="fill:url(#SVGID_2__48003);" d="M24.977,46.609c-0.489,0-0.98-0.181-1.368-0.544L10.318,33.603l1.367-1.459l13.292,12.461 L52.293,17.29l1.414,1.414L26.391,46.019C26,46.411,25.489,46.609,24.977,46.609z"/>
|
||||||
|
</svg>
|
After Width: | Height: | Size: 1.9 KiB |
@ -113,6 +113,7 @@
|
|||||||
"mssql": "4.2.3",
|
"mssql": "4.2.3",
|
||||||
"multer": "1.4.1",
|
"multer": "1.4.1",
|
||||||
"mysql2": "1.6.4",
|
"mysql2": "1.6.4",
|
||||||
|
"nanoid": "2.0.0",
|
||||||
"node-2fa": "1.1.2",
|
"node-2fa": "1.1.2",
|
||||||
"node-cache": "4.2.0",
|
"node-cache": "4.2.0",
|
||||||
"nodemailer": "4.7.0",
|
"nodemailer": "4.7.0",
|
||||||
|
@ -2,6 +2,7 @@
|
|||||||
|
|
||||||
const express = require('express')
|
const express = require('express')
|
||||||
const router = express.Router()
|
const router = express.Router()
|
||||||
|
const moment = require('moment')
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Login form
|
* Login form
|
||||||
@ -30,6 +31,17 @@ router.get('/register', async (req, res, next) => {
|
|||||||
}
|
}
|
||||||
})
|
})
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Verify
|
||||||
|
*/
|
||||||
|
router.get('/verify/:token', async (req, res, next) => {
|
||||||
|
const usr = await WIKI.models.userKeys.validateToken({ kind: 'verify', token: req.params.token })
|
||||||
|
await WIKI.models.users.query().patch({ isVerified: true }).where('id', usr.id)
|
||||||
|
const result = await WIKI.models.users.refreshToken(usr)
|
||||||
|
res.cookie('jwt', result.token, { expires: moment().add(1, 'years').toDate() })
|
||||||
|
res.redirect('/')
|
||||||
|
})
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* JWT Public Endpoints
|
* JWT Public Endpoints
|
||||||
*/
|
*/
|
||||||
|
@ -48,14 +48,14 @@ module.exports = {
|
|||||||
}
|
}
|
||||||
await this.loadTemplate(opts.template)
|
await this.loadTemplate(opts.template)
|
||||||
return this.transport.sendMail({
|
return this.transport.sendMail({
|
||||||
from: 'noreply@requarks.io',
|
from: `"${WIKI.config.mail.senderName}" <${WIKI.config.mail.senderEmail}>`,
|
||||||
to: opts.to,
|
to: opts.to,
|
||||||
subject: `${opts.subject} - ${WIKI.config.title}`,
|
subject: `${opts.subject} - ${WIKI.config.title}`,
|
||||||
text: opts.text,
|
text: opts.text,
|
||||||
html: _.get(this.templates, opts.template)({
|
html: _.get(this.templates, opts.template)({
|
||||||
logo: '',
|
logo: '',
|
||||||
siteTitle: WIKI.config.title,
|
siteTitle: WIKI.config.title,
|
||||||
copyright: 'Powered by Wiki.js',
|
copyright: WIKI.config.company.length > 0 ? WIKI.config.company : 'Powered by Wiki.js',
|
||||||
...opts.data
|
...opts.data
|
||||||
})
|
})
|
||||||
})
|
})
|
||||||
|
@ -175,7 +175,7 @@ exports.up = knex => {
|
|||||||
table.charset('utf8mb4')
|
table.charset('utf8mb4')
|
||||||
table.increments('id').primary()
|
table.increments('id').primary()
|
||||||
table.string('kind').notNullable()
|
table.string('kind').notNullable()
|
||||||
table.string('key').notNullable()
|
table.string('token').notNullable()
|
||||||
table.string('createdAt').notNullable()
|
table.string('createdAt').notNullable()
|
||||||
table.string('validUntil').notNullable()
|
table.string('validUntil').notNullable()
|
||||||
})
|
})
|
||||||
|
@ -61,13 +61,7 @@ module.exports = {
|
|||||||
async register(obj, args, context) {
|
async register(obj, args, context) {
|
||||||
try {
|
try {
|
||||||
await WIKI.models.users.register(args, context)
|
await WIKI.models.users.register(args, context)
|
||||||
const authResult = await WIKI.models.users.login({
|
|
||||||
username: args.email,
|
|
||||||
password: args.password,
|
|
||||||
strategy: 'local'
|
|
||||||
}, context)
|
|
||||||
return {
|
return {
|
||||||
jwt: authResult.jwt,
|
|
||||||
responseResult: graphHelper.generateSuccess('Registration success')
|
responseResult: graphHelper.generateSuccess('Registration success')
|
||||||
}
|
}
|
||||||
} catch (err) {
|
} catch (err) {
|
||||||
|
56
server/graph/resolvers/site.js
Normal file
56
server/graph/resolvers/site.js
Normal file
@ -0,0 +1,56 @@
|
|||||||
|
const _ = require('lodash')
|
||||||
|
const graphHelper = require('../../helpers/graph')
|
||||||
|
|
||||||
|
/* global WIKI */
|
||||||
|
|
||||||
|
module.exports = {
|
||||||
|
Query: {
|
||||||
|
async site() { return {} }
|
||||||
|
},
|
||||||
|
Mutation: {
|
||||||
|
async site() { return {} }
|
||||||
|
},
|
||||||
|
SiteQuery: {
|
||||||
|
async config(obj, args, context, info) {
|
||||||
|
return {
|
||||||
|
host: WIKI.config.host,
|
||||||
|
title: WIKI.config.title,
|
||||||
|
company: WIKI.config.company,
|
||||||
|
...WIKI.config.seo,
|
||||||
|
...WIKI.config.logo,
|
||||||
|
...WIKI.config.features
|
||||||
|
}
|
||||||
|
}
|
||||||
|
},
|
||||||
|
SiteMutation: {
|
||||||
|
async updateConfig(obj, args, context) {
|
||||||
|
try {
|
||||||
|
WIKI.config.host = args.host
|
||||||
|
WIKI.config.title = args.title
|
||||||
|
WIKI.config.company = args.company
|
||||||
|
WIKI.config.seo = {
|
||||||
|
description: args.description,
|
||||||
|
keywords: args.keywords,
|
||||||
|
robots: args.robots,
|
||||||
|
ga: args.ga
|
||||||
|
}
|
||||||
|
WIKI.config.logo = {
|
||||||
|
hasLogo: args.hasLogo,
|
||||||
|
logoIsSquare: args.logoIsSquare
|
||||||
|
}
|
||||||
|
WIKI.config.features = {
|
||||||
|
featurePageRatings: args.featurePageRatings,
|
||||||
|
featurePageComments: args.featurePageComments,
|
||||||
|
featurePersonalWikis: args.featurePersonalWikis
|
||||||
|
}
|
||||||
|
await WIKI.configSvc.saveToDb(['host', 'title', 'company', 'seo', 'logo', 'features'])
|
||||||
|
|
||||||
|
return {
|
||||||
|
responseResult: graphHelper.generateSuccess('Site configuration updated successfully')
|
||||||
|
}
|
||||||
|
} catch (err) {
|
||||||
|
return graphHelper.generateError(err)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
59
server/graph/schemas/site.graphql
Normal file
59
server/graph/schemas/site.graphql
Normal file
@ -0,0 +1,59 @@
|
|||||||
|
# ===============================================
|
||||||
|
# SITE
|
||||||
|
# ===============================================
|
||||||
|
|
||||||
|
extend type Query {
|
||||||
|
site: SiteQuery
|
||||||
|
}
|
||||||
|
|
||||||
|
extend type Mutation {
|
||||||
|
site: SiteMutation
|
||||||
|
}
|
||||||
|
|
||||||
|
# -----------------------------------------------
|
||||||
|
# QUERIES
|
||||||
|
# -----------------------------------------------
|
||||||
|
|
||||||
|
type SiteQuery {
|
||||||
|
config: SiteConfig @auth(requires: ["manage:system"])
|
||||||
|
}
|
||||||
|
|
||||||
|
# -----------------------------------------------
|
||||||
|
# MUTATIONS
|
||||||
|
# -----------------------------------------------
|
||||||
|
|
||||||
|
type SiteMutation {
|
||||||
|
updateConfig(
|
||||||
|
host: String!
|
||||||
|
title: String!
|
||||||
|
description: String!
|
||||||
|
keywords: String!
|
||||||
|
robots: [String]!
|
||||||
|
ga: String!
|
||||||
|
company: String!
|
||||||
|
hasLogo: Boolean!
|
||||||
|
logoIsSquare: Boolean!
|
||||||
|
featurePageRatings: Boolean!
|
||||||
|
featurePageComments: Boolean!
|
||||||
|
featurePersonalWikis: Boolean!
|
||||||
|
): DefaultResponse @auth(requires: ["manage:system"])
|
||||||
|
}
|
||||||
|
|
||||||
|
# -----------------------------------------------
|
||||||
|
# TYPES
|
||||||
|
# -----------------------------------------------
|
||||||
|
|
||||||
|
type SiteConfig {
|
||||||
|
host: String!
|
||||||
|
title: String!
|
||||||
|
description: String!
|
||||||
|
keywords: String!
|
||||||
|
robots: [String]!
|
||||||
|
ga: String!
|
||||||
|
company: String!
|
||||||
|
hasLogo: Boolean!
|
||||||
|
logoIsSquare: Boolean!
|
||||||
|
featurePageRatings: Boolean!
|
||||||
|
featurePageComments: Boolean!
|
||||||
|
featurePersonalWikis: Boolean!
|
||||||
|
}
|
@ -41,6 +41,10 @@ module.exports = {
|
|||||||
message: 'Invalid TFA Security Code or Login Token.',
|
message: 'Invalid TFA Security Code or Login Token.',
|
||||||
code: 1006
|
code: 1006
|
||||||
}),
|
}),
|
||||||
|
AuthValidationTokenInvalid: CustomError('AuthValidationTokenInvalid', {
|
||||||
|
message: 'Invalid validation token.',
|
||||||
|
code: 1018
|
||||||
|
}),
|
||||||
BruteInstanceIsInvalid: CustomError('BruteInstanceIsInvalid', {
|
BruteInstanceIsInvalid: CustomError('BruteInstanceIsInvalid', {
|
||||||
message: 'Invalid Brute Force Instance.',
|
message: 'Invalid Brute Force Instance.',
|
||||||
code: 1007
|
code: 1007
|
||||||
|
@ -40,7 +40,7 @@ module.exports = class Authentication extends Model {
|
|||||||
...str,
|
...str,
|
||||||
domainWhitelist: _.get(str.domainWhitelist, 'v', []),
|
domainWhitelist: _.get(str.domainWhitelist, 'v', []),
|
||||||
autoEnrollGroups: _.get(str.autoEnrollGroups, 'v', [])
|
autoEnrollGroups: _.get(str.autoEnrollGroups, 'v', [])
|
||||||
})), ['title'])
|
})), ['key'])
|
||||||
}
|
}
|
||||||
|
|
||||||
static async refreshStrategiesFromDisk() {
|
static async refreshStrategiesFromDisk() {
|
||||||
|
@ -35,7 +35,7 @@ module.exports = class Setting extends Model {
|
|||||||
const settings = await WIKI.models.settings.query()
|
const settings = await WIKI.models.settings.query()
|
||||||
if (settings.length > 0) {
|
if (settings.length > 0) {
|
||||||
return _.reduce(settings, (res, val, key) => {
|
return _.reduce(settings, (res, val, key) => {
|
||||||
_.set(res, val.key, (val.value.v) ? val.value.v : val.value)
|
_.set(res, val.key, (_.has(val.value, 'v')) ? val.value.v : val.value)
|
||||||
return res
|
return res
|
||||||
}, {})
|
}, {})
|
||||||
} else {
|
} else {
|
||||||
|
74
server/models/userKeys.js
Normal file
74
server/models/userKeys.js
Normal file
@ -0,0 +1,74 @@
|
|||||||
|
/* global WIKI */
|
||||||
|
|
||||||
|
const _ = require('lodash')
|
||||||
|
const securityHelper = require('../helpers/security')
|
||||||
|
const Model = require('objection').Model
|
||||||
|
const moment = require('moment')
|
||||||
|
const nanoid = require('nanoid')
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Users model
|
||||||
|
*/
|
||||||
|
module.exports = class UserKey extends Model {
|
||||||
|
static get tableName() { return 'userKeys' }
|
||||||
|
|
||||||
|
static get jsonSchema () {
|
||||||
|
return {
|
||||||
|
type: 'object',
|
||||||
|
required: ['kind', 'token', 'validUntil'],
|
||||||
|
|
||||||
|
properties: {
|
||||||
|
id: {type: 'integer'},
|
||||||
|
kind: {type: 'string'},
|
||||||
|
token: {type: 'string'},
|
||||||
|
createdAt: {type: 'string'},
|
||||||
|
validUntil: {type: 'string'}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
static get relationMappings() {
|
||||||
|
return {
|
||||||
|
user: {
|
||||||
|
relation: Model.BelongsToOneRelation,
|
||||||
|
modelClass: require('./users'),
|
||||||
|
join: {
|
||||||
|
from: 'userKeys.userId',
|
||||||
|
to: 'users.id'
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
async $beforeInsert(context) {
|
||||||
|
await super.$beforeInsert(context)
|
||||||
|
|
||||||
|
this.createdAt = moment.utc().toISOString()
|
||||||
|
}
|
||||||
|
|
||||||
|
static async generateToken ({ userId, kind }, context) {
|
||||||
|
const token = await nanoid()
|
||||||
|
await WIKI.models.userKeys.query().insert({
|
||||||
|
kind,
|
||||||
|
token,
|
||||||
|
validUntil: moment.utc().add(1, 'days').toISOString(),
|
||||||
|
userId
|
||||||
|
})
|
||||||
|
return token
|
||||||
|
}
|
||||||
|
|
||||||
|
static async validateToken ({ kind, token }, context) {
|
||||||
|
const res = await WIKI.models.userKeys.query().findOne({ kind, token }).eager('user')
|
||||||
|
if (res) {
|
||||||
|
await WIKI.models.userKeys.query().deleteById(res.id)
|
||||||
|
if (moment.utc().isAfter(moment.utc(res.validUntil))) {
|
||||||
|
throw new WIKI.Error.AuthValidationTokenInvalid()
|
||||||
|
}
|
||||||
|
return res.user
|
||||||
|
} else {
|
||||||
|
throw new WIKI.Error.AuthValidationTokenInvalid()
|
||||||
|
}
|
||||||
|
|
||||||
|
return token
|
||||||
|
}
|
||||||
|
}
|
@ -345,7 +345,7 @@ module.exports = class User extends Model {
|
|||||||
const usr = await WIKI.models.users.query().findOne({ email, providerKey: 'local' })
|
const usr = await WIKI.models.users.query().findOne({ email, providerKey: 'local' })
|
||||||
if (!usr) {
|
if (!usr) {
|
||||||
// Create the account
|
// Create the account
|
||||||
await WIKI.models.users.query().insert({
|
const newUsr = await WIKI.models.users.query().insert({
|
||||||
provider: 'local',
|
provider: 'local',
|
||||||
email,
|
email,
|
||||||
name,
|
name,
|
||||||
@ -358,6 +358,12 @@ module.exports = class User extends Model {
|
|||||||
isVerified: false
|
isVerified: false
|
||||||
})
|
})
|
||||||
|
|
||||||
|
// Create verification token
|
||||||
|
const verificationToken = await WIKI.models.userKeys.generateToken({
|
||||||
|
kind: 'verify',
|
||||||
|
userId: newUsr.id
|
||||||
|
})
|
||||||
|
|
||||||
// Send verification email
|
// Send verification email
|
||||||
await WIKI.mail.send({
|
await WIKI.mail.send({
|
||||||
template: 'accountVerify',
|
template: 'accountVerify',
|
||||||
@ -367,10 +373,10 @@ module.exports = class User extends Model {
|
|||||||
preheadertext: 'Verify your account in order to gain access to the wiki.',
|
preheadertext: 'Verify your account in order to gain access to the wiki.',
|
||||||
title: 'Verify your account',
|
title: 'Verify your account',
|
||||||
content: 'Click the button below in order to verify your account and gain access to the wiki.',
|
content: 'Click the button below in order to verify your account and gain access to the wiki.',
|
||||||
buttonLink: 'http://www.google.com',
|
buttonLink: `${WIKI.config.host}/verify/${verificationToken}`,
|
||||||
buttonText: 'Verify'
|
buttonText: 'Verify'
|
||||||
},
|
},
|
||||||
text: `You must open the following link in your browser to verify your account and gain access to the wiki: http://www.google.com`
|
text: `You must open the following link in your browser to verify your account and gain access to the wiki: ${WIKI.config.host}/verify/${verificationToken}`
|
||||||
})
|
})
|
||||||
return true
|
return true
|
||||||
} else {
|
} else {
|
||||||
|
@ -98,18 +98,54 @@ module.exports = () => {
|
|||||||
await fs.ensureDir(path.join(dataPath, 'uploads'))
|
await fs.ensureDir(path.join(dataPath, 'uploads'))
|
||||||
|
|
||||||
// Set config
|
// Set config
|
||||||
|
_.set(WIKI.config, 'company', '')
|
||||||
_.set(WIKI.config, 'defaultEditor', 'markdown')
|
_.set(WIKI.config, 'defaultEditor', 'markdown')
|
||||||
|
_.set(WIKI.config, 'features', {
|
||||||
|
featurePageRatings: true,
|
||||||
|
featurePageComments: true,
|
||||||
|
featurePersonalWikis: true
|
||||||
|
})
|
||||||
_.set(WIKI.config, 'graphEndpoint', 'https://graph.requarks.io')
|
_.set(WIKI.config, 'graphEndpoint', 'https://graph.requarks.io')
|
||||||
_.set(WIKI.config, 'lang.code', 'en')
|
_.set(WIKI.config, 'host', 'http://')
|
||||||
_.set(WIKI.config, 'lang.autoUpdate', true)
|
_.set(WIKI.config, 'lang', {
|
||||||
_.set(WIKI.config, 'lang.namespacing', false)
|
code: 'en',
|
||||||
_.set(WIKI.config, 'lang.namespaces', [])
|
autoUpdate: true,
|
||||||
|
namespacing: false,
|
||||||
|
namespaces: []
|
||||||
|
})
|
||||||
|
_.set(WIKI.config, 'logo', {
|
||||||
|
hasLogo: false,
|
||||||
|
logoIsSquare: false
|
||||||
|
})
|
||||||
|
_.set(WIKI.config, 'mail', {
|
||||||
|
senderName: '',
|
||||||
|
senderEmail: '',
|
||||||
|
host: '',
|
||||||
|
port: 465,
|
||||||
|
secure: true,
|
||||||
|
user: '',
|
||||||
|
pass: '',
|
||||||
|
useDKIM: false,
|
||||||
|
dkimDomainName: '',
|
||||||
|
dkimKeySelector: '',
|
||||||
|
dkimPrivateKey: ''
|
||||||
|
})
|
||||||
_.set(WIKI.config, 'public', false)
|
_.set(WIKI.config, 'public', false)
|
||||||
|
_.set(WIKI.config, 'seo', {
|
||||||
|
description: '',
|
||||||
|
keywords: '',
|
||||||
|
robots: ['index', 'follow'],
|
||||||
|
ga: ''
|
||||||
|
})
|
||||||
_.set(WIKI.config, 'sessionSecret', (await crypto.randomBytesAsync(32)).toString('hex'))
|
_.set(WIKI.config, 'sessionSecret', (await crypto.randomBytesAsync(32)).toString('hex'))
|
||||||
_.set(WIKI.config, 'telemetry.isEnabled', req.body.telemetry === 'true')
|
_.set(WIKI.config, 'telemetry', {
|
||||||
_.set(WIKI.config, 'telemetry.clientId', WIKI.telemetry.cid)
|
isEnabled: req.body.telemetry === 'true',
|
||||||
_.set(WIKI.config, 'theming.theme', 'default')
|
clientId: WIKI.telemetry.cid
|
||||||
_.set(WIKI.config, 'theming.darkMode', false)
|
})
|
||||||
|
_.set(WIKI.config, 'theming', {
|
||||||
|
theme: 'default',
|
||||||
|
darkMode: false
|
||||||
|
})
|
||||||
_.set(WIKI.config, 'title', 'Wiki.js')
|
_.set(WIKI.config, 'title', 'Wiki.js')
|
||||||
|
|
||||||
// Generate certificates
|
// Generate certificates
|
||||||
@ -128,22 +164,30 @@ module.exports = () => {
|
|||||||
}
|
}
|
||||||
})
|
})
|
||||||
|
|
||||||
_.set(WIKI.config, 'certs.jwk', pem2jwk(certs.publicKey))
|
_.set(WIKI.config, 'certs', {
|
||||||
_.set(WIKI.config, 'certs.public', certs.publicKey)
|
jwk: pem2jwk(certs.publicKey),
|
||||||
_.set(WIKI.config, 'certs.private', certs.privateKey)
|
public: certs.publicKey,
|
||||||
|
private: certs.privateKey
|
||||||
|
})
|
||||||
|
|
||||||
// Save config to DB
|
// Save config to DB
|
||||||
WIKI.logger.info('Persisting config to DB...')
|
WIKI.logger.info('Persisting config to DB...')
|
||||||
await WIKI.configSvc.saveToDb([
|
await WIKI.configSvc.saveToDb([
|
||||||
|
'certs',
|
||||||
|
'company',
|
||||||
'defaultEditor',
|
'defaultEditor',
|
||||||
|
'features',
|
||||||
'graphEndpoint',
|
'graphEndpoint',
|
||||||
|
'host',
|
||||||
'lang',
|
'lang',
|
||||||
|
'logo',
|
||||||
|
'mail',
|
||||||
'public',
|
'public',
|
||||||
|
'seo',
|
||||||
'sessionSecret',
|
'sessionSecret',
|
||||||
'telemetry',
|
'telemetry',
|
||||||
'theming',
|
'theming',
|
||||||
'title',
|
'title'
|
||||||
'certs'
|
|
||||||
])
|
])
|
||||||
|
|
||||||
// Create default locale
|
// Create default locale
|
||||||
|
@ -233,7 +233,7 @@
|
|||||||
<!-- Email Header : BEGIN -->
|
<!-- Email Header : BEGIN -->
|
||||||
<tr>
|
<tr>
|
||||||
<td style="padding: 20px 0; text-align: center">
|
<td style="padding: 20px 0; text-align: center">
|
||||||
<img src="<%= logo %>" width="200" height="50" alt="<%= siteTitle %>" border="0" style="height: auto; background: #dddddd; font-family: sans-serif; font-size: 15px; line-height: 15px; color: #555555;">
|
<img src="<%= logo %>" height="50" alt="<%= siteTitle %>" border="0" style="width: auto; background: #dddddd; font-family: sans-serif; font-size: 15px; line-height: 15px; color: #555555;">
|
||||||
</td>
|
</td>
|
||||||
</tr>
|
</tr>
|
||||||
<!-- Email Header : END -->
|
<!-- Email Header : END -->
|
||||||
|
Loading…
Reference in New Issue
Block a user