I have a pretty simple code on csharp that should insert into table but with enabled RLS (insert for only authenticated policy), every time I try to insert, I receive violation of RLS, with it disabled, works fine. Maybe I am stupid...
Code:
[Table("cities")]
class City : BaseModel
{
[PrimaryKey("id", false)]
public int Id { get; set; }
[Column("name")]
public string Name { get; set; }
[Column("country_id")]
public int CountryId { get; set; }
}
.............................................................
Console.Write("Please enter your email: ");
email = Console.ReadLine();
Console.Write("Password: ");
password = ReadPassword();
if (string.IsNullOrWhiteSpace(email) || string.IsNullOrWhiteSpace(password))
{
Console.WriteLine("Email and password cannot be empty.");
return;
}
}
try
{
var url = ("projectlink");
var key = ("mykey");
var options = new SupabaseOptions
{
AutoConnectRealtime = true
};
var supabase = new Supabase.Client(url, key, options);
await supabase.InitializeAsync();
var session = await supabase.Auth.SignIn(email, password);
//Auth works fine, I checked.
if (session != null)
{
Console.WriteLine("Signed in!");
string systemGuid = SystemGuid.Value();
Console.WriteLine("Welcome back " + email + "!");
Console.WriteLine("Your Hardware Fingerprint: " + systemGuid);
var model = new City
{
Name = "The Shire",
CountryId = 554
};
await supabase.From<City>().Insert(model);
I assume that issue is - it doesn't include something like session or auth token in request, but I haven't found anything related to this in docs :(
Also, don't mark as duplicate, the issue persists only on c#, js and ts works ok!!!
Thanks!