feat: complete register validation

* add password policy in frontend
This commit is contained in:
wancat committed 2023-11-01 21:02:01 +08:00
1 parent 1c9d69a8e0
commit fc6ac11c60
11 files changed
+57 -23

No files matched your search

+2
View File
@@ -6,6 +6,7 @@ COPY server/package.json ./server/package.json
COPY packages/file-graph/package.json ./packages/file-graph/package.json
COPY packages/utils/package.json ./packages/utils/package.json
COPY packages/models/package.json ./packages/models/package.json
COPY packages/constants/package.json ./packages/constants/package.json
RUN yarn install --frozen-lockfile --production
# Install docker cli
COPY --from=docker:dind /usr/local/bin/docker /usr/local/bin/
@@ -20,6 +21,7 @@ FROM build as prod
COPY packages/file-graph ./packages/file-graph
COPY packages/utils ./packages/utils
COPY packages/models ./packages/models
COPY packages/constants ./packages/constants
COPY ./server ./server
COPY quests ./quests
+1
View File
@@ -14,6 +14,7 @@
"@linux-odyssey/file-graph": "*",
"@linux-odyssey/models": "*",
"@linux-odyssey/utils": "*",
"@linux-odyssey/constants": "*",
"bcrypt": "^5.1.1",
"commander": "^11.0.0",
"connect-mongo": "^5.0.0",
+5 -10
View File
@@ -1,10 +1,11 @@
import { query } from 'express-validator'
import { check } from 'express-validator'
import { isValidUsername } from '@linux-odyssey/utils'
import { User } from '@linux-odyssey/models'
import { passwordPolicy } from '@linux-odyssey/constants'
export const checkUsername = () =>
query('username')
check('username')
.notEmpty()
.isString()
.custom((username) => {
@@ -23,7 +24,7 @@ export const checkNewUsername = () =>
return true
})
export const checkEmail = () => query('email').notEmpty().isEmail().trim()
export const checkEmail = () => check('email').notEmpty().isEmail().trim()
export const checkNewEmail = () =>
checkEmail().custom(async (email) => {
@@ -34,10 +35,4 @@ export const checkNewEmail = () =>
})
export const checkPassword = () =>
query('password').notEmpty().isStrongPassword({
minLength: 8,
minNumbers: 1,
minLowercase: 1,
minUppercase: 1,
minSymbols: 0,
})
check('password').notEmpty().isStrongPassword(passwordPolicy)
+4 -3
View File
@@ -1,4 +1,4 @@
import { get, genSecret } from './utils/env.js'
import { get } from './utils/env.js'
const config = {
host: get('HOST', 'localhost'),
@@ -23,10 +23,11 @@ const config = {
config.baseUrl = get('BASE_URL', `http://${config.host}:${config.port}`)
if (!config.secret) {
config.secret = genSecret()
console.warn(
'No SECRET_KEY found in .env! A temporary secret key has been generated. To set up a persistent key, please run the setup script.'
'No SECRET_KEY found in .env! To set up a persistent key, please run the setup script:'
)
console.warn('yarn setup')
process.exit(1)
}
export default config