Before_authenticate prevents me from creating a new user in devise_auth_token

before_authenticate is a callback method in Devise that is called before authenticating a user. By default, it checks if the user is already authenticated, and if not, it raises an UnauthenticatedError.

When you're trying to create a new user using devise_auth_token, it's likely that the before_authenticate callback is preventing the creation of a new user because it's trying to authenticate the user before creating it.

To fix this, you can override the before_authenticate callback in your User model to allow the creation of a new user. Here's an example:

class User < ApplicationRecord
  #...

  def before_authenticate(with_lock_time = false)
    # Allow creation of a new user
    return if new_record?
    super
  end
end

By adding this code, you're telling Devise to skip the authentication check if the user is new (i.e., new_record? returns true). This allows you to create a new user without being blocked by the before_authenticate callback.

Alternatively, you can also disable the before_authenticate callback altogether by adding the following code to your User model:

class User < ApplicationRecord
  #...

  def self.before_authenticate_with_lock_time
    # Disable the before_authenticate callback
    nil
  end
end

This will completely disable the before_authenticate callback, allowing you to create a new user without any issues.

Remember to restart your Rails server after making these changes to ensure they take effect.