mirror of
https://github.com/jorgev259/soc_site-astro.git
synced 2025-06-29 07:57:41 +00:00
Add sequelize index file
This commit is contained in:
parent
6f00481c25
commit
d20b00532d
12 changed files with 77 additions and 50 deletions
|
|
@ -3,7 +3,14 @@ import { defineConfig } from 'auth-astro'
|
|||
import Credentials from "@auth/core/providers/credentials"
|
||||
import bcrypt from 'bcrypt'
|
||||
|
||||
import db from '@/sequelize'
|
||||
import User from '@/sequelize/models/user'
|
||||
|
||||
declare module "@auth/core" {
|
||||
interface Session {
|
||||
id: string
|
||||
username: string
|
||||
}
|
||||
}
|
||||
|
||||
class InvalidLoginError extends CredentialsSignin {
|
||||
code = "Invalid username/email or password"
|
||||
|
|
@ -19,7 +26,7 @@ export default defineConfig({
|
|||
async authorize(credentials) {
|
||||
if (!credentials?.username || !credentials.password) throw new InvalidLoginError()
|
||||
|
||||
const user = await db.models.user.findByPk(credentials.username)
|
||||
const user = await User.findByPk(credentials.username)
|
||||
if (!user) throw new InvalidLoginError()
|
||||
|
||||
// @ts-ignore
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue