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/app/models/user.ts
Théo LUDWIG 4add77856e
All checks were successful
Chromatic / chromatic (push) Successful in 2m58s
CI / ci (push) Successful in 4m43s
CI / commitlint (push) Successful in 15s
chore: try Adonis Tuyau
2024-08-16 01:50:11 +01:00

56 lines
1.3 KiB
TypeScript

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"
@column({ columnName: "id", serializeAs: "id", isPrimary: true })
declare id: number
@column({
columnName: "full_name",
serializeAs: "fullName",
})
declare fullName: string
@column({
columnName: "email",
serializeAs: "email",
})
declare email: string
@column({ columnName: "password", serializeAs: null })
declare password: string
@column.dateTime({
columnName: "created_at",
serializeAs: "createdAt",
autoCreate: true,
})
declare createdAt: DateTime
@column.dateTime({
columnName: "updated_at",
serializeAs: "updatedAt",
autoCreate: true,
autoUpdate: true,
})
declare updatedAt: DateTime
static accessTokens = DbAccessTokensProvider.forModel(User)
}