misc: migrate to vuetify 2.0 (wip)

This commit is contained in:
NGPixel
2019-07-29 04:50:03 +00:00
parent e77037e161
commit eccf1a1b19
102 changed files with 1898 additions and 1882 deletions

View File

@@ -0,0 +1,13 @@
exports.up = knex => {
return knex.schema
.table('users', table => {
table.boolean('mustChangePwd').notNullable().defaultTo(false)
})
}
exports.down = knex => {
return knex.schema
.table('users', table => {
table.dropColumn('mustChangePwd')
})
}

View File

@@ -0,0 +1,13 @@
exports.up = knex => {
return knex.schema
.table('users', table => {
table.boolean('mustChangePwd').notNullable().defaultTo(false)
})
}
exports.down = knex => {
return knex.schema
.table('users', table => {
table.dropColumn('mustChangePwd')
})
}

View File

@@ -29,11 +29,7 @@ module.exports = {
},
UserMutation: {
create(obj, args) {
return WIKI.models.users.register({
...args,
verify: false,
bypassChecks: true
})
return WIKI.models.users.createNewUser(args)
},
delete(obj, args) {
return WIKI.models.users.query().deleteById(args.id)

View File

@@ -36,10 +36,12 @@ type UserQuery {
type UserMutation {
create(
email: String!
name: String
name: String!
passwordRaw: String
providerKey: String!
providerId: String
groups: [Int]!
mustChangePassword: Boolean
sendWelcomeEmail: Boolean
): UserResponse @auth(requires: ["write:users", "manage:users", "manage:system"])
update(

View File

@@ -360,6 +360,88 @@ module.exports = class User extends Model {
throw new WIKI.Error.AuthTFAInvalid()
}
static async createNewUser ({ providerKey, email, passwordRaw, name, groups, mustChangePassword, sendWelcomeEmail }) {
// Input sanitization
email = _.toLower(email)
// Input validation
const validation = validate({
email,
passwordRaw,
name
}, {
email: {
email: true,
length: {
maximum: 255
}
},
passwordRaw: {
presence: {
allowEmpty: false
},
length: {
minimum: 6
}
},
name: {
presence: {
allowEmpty: false
},
length: {
minimum: 2,
maximum: 255
}
}
}, { format: 'flat' })
if (validation && validation.length > 0) {
throw new WIKI.Error.InputInvalid(validation[0])
}
// Check if email already exists
const usr = await WIKI.models.users.query().findOne({ email, providerKey })
if (!usr) {
// Create the account
const newUsr = await WIKI.models.users.query().insert({
provider: providerKey,
email,
name,
password: passwordRaw,
locale: 'en',
defaultEditor: 'markdown',
tfaIsActive: false,
isSystem: false,
isActive: true,
isVerified: true,
mustChangePwd: (mustChangePassword === true)
})
// Assign to group(s)
if (groups.length > 0) {
await newUsr.$relatedQuery('groups').relate(groups)
}
if (sendWelcomeEmail) {
// Send welcome email
await WIKI.mail.send({
template: 'accountWelcome',
to: email,
subject: `Welcome to the wiki ${WIKI.config.title}`,
data: {
preheadertext: `You've been invited to the wiki ${WIKI.config.title}`,
title: `You've been invited to the wiki ${WIKI.config.title}`,
content: `Click the button below to access the wiki.`,
buttonLink: `${WIKI.config.host}/login`,
buttonText: 'Login'
},
text: `You've been invited to the wiki ${WIKI.config.title}: ${WIKI.config.host}/login`
})
}
} else {
throw new WIKI.Error.AuthAccountAlreadyExists()
}
}
static async register ({ email, password, name, verify = false, bypassChecks = false }, context) {
const localStrg = await WIKI.models.authentication.getStrategy('local')
// Check if self-registration is enabled

View File

@@ -28,13 +28,7 @@ html
link(rel='manifest', href='/manifest.json')
//- Icon Set
if config.theming.iconset === 'mdi'
link(
type='text/css'
rel='stylesheet'
href='https://cdn.materialdesignicons.com/3.7.95/css/materialdesignicons.min.css'
)
else if config.theming.iconset === 'fa'
if config.theming.iconset === 'fa'
link(
type='text/css'
rel='stylesheet'

View File

@@ -32,13 +32,7 @@ html
var siteConfig = !{JSON.stringify(siteConfig)}; var siteLangs = !{JSON.stringify(langs)}
//- Icon Set
if config.theming.iconset === 'mdi'
link(
type='text/css'
rel='stylesheet'
href='https://cdn.materialdesignicons.com/3.7.95/css/materialdesignicons.min.css'
)
else if config.theming.iconset === 'fa'
if config.theming.iconset === 'fa'
link(
type='text/css'
rel='stylesheet'

View File

@@ -25,12 +25,12 @@ block body
template(slot='sidebar')
each navItem in sidebar
if navItem.kind === 'link'
v-list-tile(
v-list-item(
href=navItem.target
)
v-list-tile-avatar
v-list-item-avatar
v-icon= navItem.icon
v-list-tile-title= navItem.label
v-list-item-title= navItem.label
else if navItem.kind === 'divider'
v-divider.my-2
else if navItem.kind === 'header'