This repository has been archived on 2024-10-12. You can view files and clone it, but cannot push or open issues or pull requests.
wikipedia-game-solver/apps/api/src/app/models/user.ts

56 lines
1.3 KiB
TypeScript
Raw Normal View History

2024-08-09 23:51:41 +02:00
import { DbAccessTokensProvider } from "@adonisjs/auth/access_tokens"
import { withAuthFinder } from "@adonisjs/auth/mixins/lucid"
import { compose } from "@adonisjs/core/helpers"
import hash from "@adonisjs/core/services/hash"
import { BaseModel, column } from "@adonisjs/lucid/orm"
import { DateTime } from "luxon"
const AuthFinder = withAuthFinder(
() => {
return hash.use("scrypt")
},
{
uids: ["email"],
passwordColumnName: "password",
},
)
export default class User extends compose(BaseModel, AuthFinder) {
protected tableName = "users"
2024-08-10 02:32:34 +02:00
@column({ columnName: "id", serializeAs: "id", isPrimary: true })
2024-08-09 23:51:41 +02:00
declare id: number
@column({
columnName: "full_name",
2024-08-10 02:32:34 +02:00
serializeAs: "fullName",
2024-08-09 23:51:41 +02:00
})
declare fullName: string | null
@column({
columnName: "email",
2024-08-10 02:32:34 +02:00
serializeAs: "email",
2024-08-09 23:51:41 +02:00
})
declare email: string
@column({ columnName: "password", serializeAs: null })
declare password: string
@column.dateTime({
columnName: "created_at",
2024-08-10 02:32:34 +02:00
serializeAs: "createdAt",
2024-08-09 23:51:41 +02:00
autoCreate: true,
})
declare createdAt: DateTime
@column.dateTime({
columnName: "updated_at",
2024-08-10 02:32:34 +02:00
serializeAs: "updatedAt",
2024-08-09 23:51:41 +02:00
autoCreate: true,
autoUpdate: true,
})
declare updatedAt: DateTime | null
static accessTokens = DbAccessTokensProvider.forModel(User)
}