mirror of https://github.com/Requarks/wiki.git
14 changed files with 402 additions and 44 deletions
Unified View
Diff Options
-
160client/js/components/login.vue
-
18client/js/constants/graphql.js
-
23client/scss/components/login.scss
-
3server/app/data.yml
-
9server/extensions/authentication/local.js
-
30server/helpers/error.js
-
30server/helpers/security.js
-
1server/index.js
-
12server/master.js
-
110server/models/user.js
-
2server/modules/auth.js
-
11server/modules/localization.js
-
16server/schemas/resolvers-user.js
-
21server/schemas/types.graphql
@ -0,0 +1,30 @@ |
|||||
|
class BaseError extends Error { |
||||
|
constructor (message) { |
||||
|
super(message) |
||||
|
this.name = this.constructor.name |
||||
|
Error.captureStackTrace(this, this.constructor) |
||||
|
} |
||||
|
} |
||||
|
|
||||
|
class AuthGenericError extends BaseError { constructor (message = 'An unexpected error occured during login.') { super(message) } } |
||||
|
class AuthLoginFailed extends BaseError { constructor (message = 'Invalid email / username or password.') { super(message) } } |
||||
|
class AuthProviderInvalid extends BaseError { constructor (message = 'Invalid authentication provider.') { super(message) } } |
||||
|
class AuthTFAFailed extends BaseError { constructor (message = 'Incorrect TFA Security Code.') { super(message) } } |
||||
|
class AuthTFAInvalid extends BaseError { constructor (message = 'Invalid TFA Security Code or Login Token.') { super(message) } } |
||||
|
class BruteInstanceIsInvalid extends BaseError { constructor (message = 'Invalid Brute Force Instance.') { super(message) } } |
||||
|
class BruteTooManyAttempts extends BaseError { constructor (message = 'Too many attempts! Try again later.') { super(message) } } |
||||
|
class LocaleInvalidNamespace extends BaseError { constructor (message = 'Invalid locale or namespace.') { super(message) } } |
||||
|
class UserCreationFailed extends BaseError { constructor (message = 'An unexpected error occured during user creation.') { super(message) } } |
||||
|
|
||||
|
module.exports = { |
||||
|
BaseError, |
||||
|
AuthGenericError, |
||||
|
AuthLoginFailed, |
||||
|
AuthProviderInvalid, |
||||
|
AuthTFAFailed, |
||||
|
AuthTFAInvalid, |
||||
|
BruteInstanceIsInvalid, |
||||
|
BruteTooManyAttempts, |
||||
|
LocaleInvalidNamespace, |
||||
|
UserCreationFailed |
||||
|
} |
@ -1,15 +1,25 @@ |
|||||
'use strict' |
|
||||
|
|
||||
/* global appdata, appconfig */ |
|
||||
|
|
||||
const _ = require('lodash') |
|
||||
|
const Promise = require('bluebird') |
||||
|
const crypto = require('crypto') |
||||
|
|
||||
module.exports = { |
module.exports = { |
||||
sanitizeCommitUser (user) { |
sanitizeCommitUser (user) { |
||||
let wlist = new RegExp('[^a-zA-Z0-9-_.\',& ' + appdata.regex.cjk + appdata.regex.arabic + ']', 'g') |
|
||||
return { |
|
||||
name: _.chain(user.name).replace(wlist, '').trim().value(), |
|
||||
email: appconfig.git.showUserEmail ? user.email : appconfig.git.serverEmail |
|
||||
} |
|
||||
|
// let wlist = new RegExp('[^a-zA-Z0-9-_.\',& ' + appdata.regex.cjk + appdata.regex.arabic + ']', 'g')
|
||||
|
// return {
|
||||
|
// name: _.chain(user.name).replace(wlist, '').trim().value(),
|
||||
|
// email: appconfig.git.showUserEmail ? user.email : appconfig.git.serverEmail
|
||||
|
// }
|
||||
|
}, |
||||
|
/** |
||||
|
* Generate a random token |
||||
|
* |
||||
|
* @param {any} length |
||||
|
* @returns |
||||
|
*/ |
||||
|
async generateToken (length) { |
||||
|
return Promise.fromCallback(clb => { |
||||
|
crypto.randomBytes(length, clb) |
||||
|
}).then(buf => { |
||||
|
return buf.toString('hex') |
||||
|
}) |
||||
} |
} |
||||
} |
} |
Write
Preview
Loading…
Cancel
Save