mirror of
https://github.com/linux-odyssey/linux-odyssey.git
synced 2026-11-07 19:10:12 +08:00
wip: replace packages with pure files
This commit is contained in:
1 parent
2d95ca382f
commit
87b8ca5d04
112 files changed
+740
-522
No files matched your search
@@ -0,0 +1,65 @@
|
||||
import { model, Schema } from 'mongoose'
|
||||
|
||||
export interface ISocialLogin {
|
||||
provider: string
|
||||
id: string
|
||||
displayName?: string
|
||||
}
|
||||
|
||||
const socialLoginSchema = new Schema<ISocialLogin>({
|
||||
provider: {
|
||||
type: String,
|
||||
required: true,
|
||||
},
|
||||
id: {
|
||||
type: String,
|
||||
required: true,
|
||||
},
|
||||
displayName: {
|
||||
type: String,
|
||||
required: false,
|
||||
},
|
||||
})
|
||||
|
||||
export interface IUser {
|
||||
username: string
|
||||
email: string
|
||||
hashedPassword: string
|
||||
socialLogins: Map<string, ISocialLogin>
|
||||
createdAt: Date
|
||||
updatedAt: Date
|
||||
isGuest: boolean
|
||||
}
|
||||
|
||||
export const User = model<IUser>(
|
||||
'User',
|
||||
new Schema<IUser>(
|
||||
{
|
||||
username: {
|
||||
type: String,
|
||||
unique: true,
|
||||
required: true,
|
||||
},
|
||||
email: {
|
||||
type: String,
|
||||
unique: true,
|
||||
required: true,
|
||||
},
|
||||
hashedPassword: String,
|
||||
socialLogins: {
|
||||
type: Map,
|
||||
of: socialLoginSchema,
|
||||
default: {},
|
||||
required: true,
|
||||
},
|
||||
isGuest: {
|
||||
type: Boolean,
|
||||
default: false,
|
||||
required: true,
|
||||
},
|
||||
},
|
||||
{
|
||||
timestamps: true,
|
||||
}
|
||||
)
|
||||
)
|
||||
Reference in new issue
Block a user