Closed dakiesse closed 6 years ago
Hey @dakiesse ! 👋
I didn't really understand your question. Also, if it's not an issue in the framework, please ask this question in the forum/discord server.
Hey @RomainLanz ,
I meant How to use generating an api token for seeding (How to create token entity for user through seeding) but I have already found a solution for it:
const Config = use('Adonis/Src/Config')
const Auth = use('Adonis/Src/Auth')
class UserSeeder {
async run () {
await clearDatabase()
// main user
const user = await Factory.model('App/Models/User').create()
// make token
const auth = new Auth({}, Config)
const token = await auth.generate(user)
console.log('Main user token:', token)
// ... other code
}
}
Why would you want to make a JWT token while seeding?
I want to make API Token (no JWT). I have been doing because I create a mobile application and I want to test auth. For example, a case when a user is EXISTS and need to auth at mobile application.
Cool 👍
I believe we can close this issue since you found a solution. Feel free to comment again if you want me to reopen it!
@dakiesse how u find the file Adonis/Src/Auth
? You know if in the adonis 5 it's work?
Hey! How can I make API Token for User via Factories/Seed?