Base solution for your next web application

Activities of "BobIngham"

Doh!!!! Thanks, Aaron.

Hmmm, the problem, Aaron, is that settingsRepository only return those settings for the current tenant, how do I read settings for all tenants to ensure the value is unique?

Thanks, Aaron, that did the trick. Sorry about the niaivety, I am still in the learning -phase.

Zero 5.0.2 - Aspnet Core, Angular I have an app written using Ionic. The user registers with the app using a username, password and voucher code. The voucher code is unique to a given tenant. The registration process injects the tenantId into a unit of work using statement, ABPSession.TenantId is set with AbpSession.Use(tenantId, null) for the uow and a new user is created for the tenant. The tenantId is returned to the app and saved in a local database. The app user is redirected to the login page to login. How do I pass the username, password and tenantId (from device storage) from the app to the server and have the server log the user into the correct tenant? Surely I do not have to set filters in unit of work and apply AbpSession.Use(tenantId, null) for every call my app makes to the server?

@ismcagdas, thanks for the consideration but I'm still not sure on best practise. I will add the tenant ref as a claim and then create the access token including this claim. That way the token can be read on every call to the server but I am still faced with the problem of having to create a unit of work and setting AbpSession.TenantId for the ouw for every call made to the server.

The question has to be: During the login and authentication processes how so I set AbpSession.TenantId so I do not have to create a unit of work and setting AbpSession.TenantId for the ouw for every call made to the server?

.Net Core, Angular 5.0.2 I am trying to return UserFriendlyException errors to app written using Ionic 3. I can sign up and find a tenant using a (unique) voucher code, return the tenantId to the app and add this to the sign in process which gives me the correct tenantId as a claim in the JWT. To return data to the app I have implemented the [DontWrapResult] attribute which works well. However, I can not find a way to return well formatted errors to the app using the UserFriendlyException constructor. For example, I am trying to implement UserFriendlyException to indicate that a username is already taken (as per the standard system). The error received at the app has a status of 0 and a statusText of "Unknown error". I have tried implementing [DontWrapResult(WrapOnError = false)] but I am still getting the same results. The question is: How to return UserFriendlyException to the app in a manner which can be read in the app?

It does not matter whether I use the WrapOnError qualifier or not, I am still getting the same result.

Yes, exactly the same result.

Hi Aaron, This was a bit sticky but I found the answer. First i will show you code when everything goes well. To register with the system an Ionic app sends a username, password and voucher code. The call from Ionic uses httpClient:

public onSignUp(AppRegisterModel): Observable<AppRegisterResultModel> {
    return this.httpClient.post("http://...//api/services/app/Account/RegisterFromApp", AppRegisterModel)
      .map(registerResultModel => registerResultModel)
      .catch(this.handleError);
  }

AppRegisterModel contains a voucher code unique to each tenant. On the server I find the tenant from the voucher code:

var tenantId = await GetTenantIdFromVoucherCodeAsync(model.VoucherCode);

and then I add the user in a unit of work using the SetTenantId filter and ensure AbpSession uses the same value:

using (_unitOfWorkManager.Current.SetTenantId(tenantId))
{
   AbpSession.Use(tenantId, null);

Successful registration returns a tenantId which is saved locally and added to the sign in process.
AppTokenAuthController is a direct copy of TokenAuthController with changes only to the input model and the first method:

[HttpPost]
public async Task<AuthenticateResultModel> AppAuthenticate([FromBody] AppAuthenticateModel model)
{
  var loginResult = await GetLoginResultAsync(
    model.UserNameOrEmailAddress,
    model.Password,
    await GetTenancyNameFromTenantId(model.TenantId)
  );

AppAuthenticateModel includes TenantId which is added to the JWT token and can now be used securely between an Ionic app and a Zero server. So far so good but if anything goes wrong it's not nice. At the moment my error message returned by a _UserFriendlyException_can be found here:

error.error.error.message;

Despite the fact it's not nice it works perfectly and we get a nice user friendly error message displayed on the Ionic app. I messed with the

[DontWrapResult(WrapOnError = true)]

with different values but the above configuration proved stable.

This also closes [https://forum.aspnetboilerplate.com/viewtopic.php?f=5&t=10636&p=26158#p26158]).

Thanks for your help.

Bob

See [https://forum.aspnetboilerplate.com/viewtopic.php?f=5&t=10657&p=26292#p26292]).

Showing 11 to 20 of 619 entries