I am using abpZero on Type 'ASP.NET CORE & Angular', Framework '.NET 7.0', and Version 'v12.1.0'.
I want to add some custom **abp.session ** so that I can use it inside the angular component.
How can I add an property as child of abp.session, where the data from table.
3 Answer(s)
-
0
Hi @asbbh
You can add this new property to
GetCurrentLoginInformationsOutput
on server side and return it viaISessionAppService
. Then, on the client side, you can setabp.session.newProperty
and use it in your app. -
0
HI,
- I have added a property StaffId in src/SchoolAut0mater.Application.Shared/Sessions/Dto/GetCurrentLoginInformationsOutput.cs.
- In src/SchoolAut0mater.Application/Sessions/SessionAppService.cs, I have initialize the value
output.Tenant.SubscriptionDateString = GetTenantSubscriptionDateString(output); output.Tenant.CreationTimeString = output.Tenant.CreationTime.ToString("d"); try { if (AbpSession.UserId.HasValue) { var emailAddress = $"{output.User.EmailAddress}".Trim(); var currentStaff = await _staffMasterRepo.FirstOrDefaultAsync(s => string.Equals(s.SchoolEmail, emailAddress)); if (currentStaff != null) { output.User.StaffId = currentStaff.Id; } } } catch { }
But on client side I am not able to see any data in
abp.
-
0
Hi,
You also need to set it here https://github.com/aspnetzero/aspnet-zero-core/blob/dev/angular/src/shared/common/session/app-session.service.ts#L85.
I suggest creating a new field in
app-session.service.ts
and use it in your app instead of defining a new field onabp.session
.