mirror of
https://github.com/linux-odyssey/linux-odyssey.git
synced 2026-11-05 19:20:12 +08:00
47 lines
717 B
JavaScript
47 lines
717 B
JavaScript
import { model, Schema } from 'mongoose'
|
|
|
|
const socialLoginSchema = new Schema({
|
|
provider: {
|
|
type: String,
|
|
required: true,
|
|
},
|
|
id: {
|
|
type: String,
|
|
required: true,
|
|
},
|
|
displayName: {
|
|
type: String,
|
|
required: false,
|
|
},
|
|
})
|
|
|
|
const User = model(
|
|
'User',
|
|
new Schema(
|
|
{
|
|
username: {
|
|
type: String,
|
|
unique: true,
|
|
required: true,
|
|
},
|
|
email: {
|
|
type: String,
|
|
unique: true,
|
|
required: true,
|
|
},
|
|
hashedPassword: String,
|
|
socialLogins: {
|
|
type: Map,
|
|
of: socialLoginSchema,
|
|
default: {},
|
|
required: true,
|
|
},
|
|
},
|
|
{
|
|
timestamps: true,
|
|
}
|
|
)
|
|
)
|
|
|
|
export default User
|