adonisjs / auth

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

session cookie is being set even if request fails #179

Closed manumrtf closed 2 years ago

manumrtf commented 2 years ago

cookierequest

this is the code of my controller

 public async register(ctx: HttpContextContract) {
    await ctx.request.validate(RegisterUserValidator)
    const user = new User()
    user.email = ctx.request.input('email')
    user.username = ctx.request.input('username')
    user.password = ctx.request.input('password')
    user.rol = Rol.SUPERUSER
    const organization = new Organization()
    organization.name = ctx.request.input('organization')
    await user.save()
    await user.related('organization').associate(organization)
    await ctx.auth.use('web').login(user)
  }
thetutlage commented 2 years ago

Sessions and auth are two different things. You can use session without auth as well and hence the session cookie is created when your app is using the session module. https://docs.adonisjs.com/guides/session