mirror of
https://github.com/linux-odyssey/linux-odyssey.git
synced 2026-11-06 03:20:13 +08:00
fix: remove default user
This commit is contained in:
1 parent
f1a50067c5
commit
6a64f75950
2 files changed
+2
-18
No files matched your search
@@ -15,7 +15,6 @@ import errorHandler from './middleware/error.js'
|
||||
import globalRateLimit from './middleware/globalRateLimit.js'
|
||||
import sessionMiddleware from './middleware/session.js'
|
||||
import expiryRemovalScheduler from './containers/expiryChecker.js'
|
||||
import { createTestUser } from './utils/auth.js'
|
||||
|
||||
async function main() {
|
||||
try {
|
||||
@@ -26,8 +25,6 @@ async function main() {
|
||||
process.exit(1)
|
||||
}
|
||||
|
||||
await createTestUser()
|
||||
|
||||
await loadAndUpdateQuests()
|
||||
expiryRemovalScheduler()
|
||||
|
||||
|
||||
@@ -1,5 +1,4 @@
|
||||
import jwt from 'jsonwebtoken'
|
||||
import { User } from '@linux-odyssey/models'
|
||||
import bcrypt from 'bcrypt'
|
||||
import config from '../config.js'
|
||||
|
||||
@@ -7,23 +6,11 @@ export function hashPassword(password) {
|
||||
return bcrypt.hash(password, 10)
|
||||
}
|
||||
|
||||
export async function createTestUser() {
|
||||
let user = await User.findOne({ username: 'alex' })
|
||||
if (!user) {
|
||||
user = new User({
|
||||
username: 'alex',
|
||||
email: 'alex@example.com',
|
||||
})
|
||||
user.hashedPassword = await hashPassword('123456')
|
||||
await user.save()
|
||||
}
|
||||
}
|
||||
|
||||
export function genJWT(payload) {
|
||||
return new Promise((resolve, reject) => {
|
||||
jwt.sign(
|
||||
payload,
|
||||
config.jwtSecret,
|
||||
config.secret,
|
||||
{ expiresIn: config.containerExpiry },
|
||||
(err, token) => {
|
||||
if (err) {
|
||||
@@ -38,7 +25,7 @@ export function genJWT(payload) {
|
||||
|
||||
export function verifyJWT(token) {
|
||||
return new Promise((resolve, reject) => {
|
||||
jwt.verify(token, config.jwtSecret, (err, decoded) => {
|
||||
jwt.verify(token, config.secret, (err, decoded) => {
|
||||
if (err) {
|
||||
reject(err)
|
||||
} else {
|
||||
|
||||
Reference in new issue
Block a user