mirror of
https://github.com/linux-odyssey/linux-odyssey.git
synced 2026-11-06 03:20:13 +08:00
feat: add register-guest api
This commit is contained in:
1 parent
b5c601f4a9
commit
1d725d82ae
4 files changed
+63
-3
No files matched your search
@@ -1,4 +1,5 @@
|
||||
import { Express } from 'express'
|
||||
import { format } from 'date-fns'
|
||||
import { User, UserProfile } from '@linux-odyssey/models'
|
||||
import { hashPassword } from '../utils/auth.js'
|
||||
|
||||
@@ -31,6 +32,22 @@ export async function createUser(
|
||||
return user
|
||||
}
|
||||
|
||||
export async function createGuestUser() {
|
||||
const username = `guest_${format(new Date(), 'yyyyMMddHHmmss')}`
|
||||
const user = new User({
|
||||
username,
|
||||
email: `${username}@example.com`,
|
||||
})
|
||||
await user.save()
|
||||
|
||||
const profile = new UserProfile({
|
||||
user,
|
||||
})
|
||||
await profile.save()
|
||||
|
||||
return user
|
||||
}
|
||||
|
||||
export function leaderboard() {
|
||||
return UserProfile.aggregate([
|
||||
{
|
||||
|
||||
Reference in new issue
Block a user