adonisjs / auth

Official Authentication package for AdonisJS
https://docs.adonisjs.com/guides/auth/introduction
MIT License
191 stars 65 forks source link

Extending User from another model causes TypeError #146

Closed TurningTide closed 3 years ago

TurningTide commented 4 years ago

Package version

Core: 5.0.0-preview-rc-1.11 Auth: 4.3.1

Node.js and npm version

Node: 12.18.1 NPM: 6.14.5

Sample Code (to reproduce the issue)

App/Models/AbstractModel


import { DateTime } from 'luxon'
import {BaseModel, column} from '@ioc:Adonis/Lucid/Orm'

export default class AbstractModel extends BaseModel {

@column({ isPrimary: true }) public id: number

@column.dateTime({ autoCreate: true }) public createdAt: DateTime

@column.dateTime({ autoCreate: true, autoUpdate: true }) public updatedAt: DateTime

}


**App/Models/User**

import {column, beforeSave} from "@ioc:Adonis/Lucid/Orm"; import Hash from '@ioc:Adonis/Core/Hash' import AbstractModel from "App/Models/AbstractModel";

export default class User extends AbstractModel{ public static table = 'users';

@column() email:string

@column({serializeAs:null}) password:string

@column({serializeAs:null}) remember_me_token:string

@beforeSave() public static async hashPassword (user: User) { if(user.$dirty.password){ user.password = await Hash.make(user.password); } } }



I've got model called "App/Models/AbstractModel" that extends BaseModel and has only base fields (id and dates). I use it to define default fields for every other model.
Once i've installed Auth module and changed "User extends BaseModel" to "User extends AbstractModel" compiler started to crash with "TypeError: Class extends value undefined is not a constructor or null". IDE says nothing.
Every other model extending AbstractModel works as intended.
thetutlage commented 4 years ago

How about stopping the compiler and re-starting it. It the error still persists, then share a screenshot of it please

TurningTide commented 4 years ago

image

thetutlage commented 4 years ago

I just tried it and works fine for me. Can you please share a repo that helps reproducing the issue?

thetutlage commented 3 years ago

Closing since no response from the issue reporter and not actionable as well