Base solution for your next web application
Open Closed

How to create a record in a user-defined table without logging in? #6066


User avatar
0
TimMackey created

I used the Power Tool to create an entity. I am able to add a record in my table using the GUI generated when I am logged in.

I have a new registration form, and I want to add a record in my table at registration time - before the user has logged in. In method 'public async Task<RegisterTenantOutput> RegisterTenant(RegisterTenantInput input)' I call the 'CreateOrEdit' method of 'IInstitutionsAppService', as follows:

                    await _institutionsAppService.CreateOrEdit(
                        new TtmDataModel.Dtos.CreateOrEditInstitutionDto()
                        {
                            DomainName = emailDomain,
                            InstitutionName = institutionName,
                            TenantId = tenant.Id,
                            IsSet_ = 0,
                            Id = null,
                        });

Invoking the method results in an Exception being thrown. Exception.message: "Current user did not login to the application!"

Can you direct me to the documentation that will explain how to create and edit my custom table records without the user being logged in? Or if there is no documentation, please explain how to accomplish this objective. Thank you.

Markdown is supported
Copy & paste or drag & drop images (max 30 MB per image)

1 Answer(s)
  • User Avatar
    0
    ismcagdas created
    Support Team

    Hi @timmackey

    If you don't want to authorize a specific app service method, you can add AbpAllowAnonymous attribute to that method.

    For more info, you can check https://aspnetboilerplate.com/Pages/Documents/Authorization

    Markdown is supported
    Copy & paste or drag & drop images (max 30 MB per image)