Skip to content

Commit c698713

Browse files
committed
Merge remote-tracking branch 'upstream/main' into lihlmise/b/textfield
# Conflicts: # shesha-reactjs/src/designer-components/textField/textField.tsx
2 parents 9a458bb + 0ec6c16 commit c698713

51 files changed

Lines changed: 733 additions & 1496 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

shesha-core/src/Shesha.Application/Authorization/TokenAuthController.cs

Lines changed: 30 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@
2626
using System.Linq;
2727
using System.Security.Claims;
2828
using System.Threading.Tasks;
29+
using System.Transactions;
2930

3031
namespace Shesha.Authorization
3132
{
@@ -41,13 +42,15 @@ public class TokenAuthController : SheshaControllerBase
4142
private readonly IRepository<ShaUserRegistration, Guid> _userRegistration;
4243
private readonly IExternalAuthConfiguration _externalAuthConfiguration;
4344
private readonly IExternalAuthManager _externalAuthManager;
44-
private readonly UserRegistrationManager _userRegistrationManager;
45+
private readonly IUserRegistrationManager _userRegistrationManager;
4546
private readonly IRepository<Person, Guid> _personRepository;
4647
private readonly IRepository<MobileDevice, Guid> _mobileDeviceRepository;
4748
private readonly ITokenBlacklistService _tokenBlacklistService;
4849
private readonly UserManager<User> _userManager;
4950
private readonly AbpUserClaimsPrincipalFactory<User, Role> _claimsPrincipalFactory;
5051
private readonly IConfiguration _appConfiguration;
52+
private readonly IRepository<User, long> _userRepository;
53+
5154

5255
public TokenAuthController(
5356
LogInManager logInManager,
@@ -56,14 +59,15 @@ public TokenAuthController(
5659
TokenAuthConfiguration configuration,
5760
IExternalAuthConfiguration externalAuthConfiguration,
5861
IExternalAuthManager externalAuthManager,
59-
UserRegistrationManager userRegistrationManager,
62+
IUserRegistrationManager userRegistrationManager,
6063
IRepository<Person, Guid> personRepository,
6164
IRepository<ShaUserRegistration, Guid> userRegistration,
6265
IRepository<MobileDevice, Guid> mobileDeviceRepository,
6366
ITokenBlacklistService tokenBlacklistService,
6467
UserManager<User> userManager,
6568
AbpUserClaimsPrincipalFactory<User, Role> claimsPrincipalFactory,
66-
IConfiguration appConfiguration)
69+
IConfiguration appConfiguration,
70+
IRepository<User, long> userRepository)
6771
{
6872
_logInManager = logInManager;
6973
_tenantCache = tenantCache;
@@ -79,6 +83,7 @@ public TokenAuthController(
7983
_userManager = userManager;
8084
_claimsPrincipalFactory = claimsPrincipalFactory;
8185
_appConfiguration = appConfiguration;
86+
_userRepository = userRepository;
8287
}
8388

8489
[HttpPost]
@@ -335,28 +340,33 @@ public async Task<ExternalAuthenticateResultModel> ExternalAuthenticateAsync([Fr
335340

336341
private async Task<User> RegisterExternalUserAsync(ExternalAuthUserInfo externalUser)
337342
{
338-
var user = await _userRegistrationManager.RegisterAsync(
339-
externalUser.Name,
340-
externalUser.Surname,
341-
externalUser.EmailAddress,
342-
externalUser.EmailAddress,
343-
Authorization.Users.User.CreateRandomPassword(),
344-
true
345-
);
346-
347-
user.Logins = new List<UserLogin>
343+
using (var uow = UnitOfWorkManager.Begin(TransactionScopeOption.RequiresNew))
348344
{
349-
new UserLogin
345+
var user = await _userRegistrationManager.RegisterAsync(
346+
externalUser.Name,
347+
externalUser.Surname,
348+
externalUser.EmailAddress,
349+
externalUser.EmailAddress,
350+
Authorization.Users.User.CreateRandomPassword(),
351+
true
352+
);
353+
354+
if (user.Logins == null)
355+
user.Logins = new List<UserLogin>();
356+
357+
user.Logins.Add(new UserLogin
350358
{
351359
LoginProvider = externalUser.Provider,
352360
ProviderKey = externalUser.ProviderKey,
353-
TenantId = user.TenantId
354-
}
355-
};
361+
TenantId = user.TenantId,
362+
UserId = user.Id
363+
});
356364

357-
await CurrentUnitOfWork.SaveChangesAsync();
365+
await _userRepository.UpdateAsync(user);
366+
await uow.CompleteAsync();
358367

359-
return user;
368+
return user;
369+
}
360370
}
361371

362372
private async Task<ExternalAuthUserInfo> GetExternalUserInfoAsync(ExternalAuthenticateModel model)
@@ -392,7 +402,7 @@ private async Task<ShaLoginResult<User>> GetLoginResultAsync(string usernameOrEm
392402
}
393403
}
394404

395-
private string CreateAccessToken(IEnumerable<Claim> claims)
405+
private string CreateAccessToken(IEnumerable<Claim> claims)
396406
{
397407
var validFrom = DateTime.UtcNow;
398408
var expiresOn = validFrom.Add(_configuration.Expiration);
Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
using System.Threading.Tasks;
2+
using Abp.Domain.Services;
3+
4+
namespace Shesha.Authorization.Users
5+
{
6+
/// <summary>
7+
/// Interface for user registration management
8+
/// </summary>
9+
public interface IUserRegistrationManager : IDomainService
10+
{
11+
/// <summary>
12+
/// Registers a new user
13+
/// </summary>
14+
Task<User> RegisterAsync(string name, string? surname, string emailAddress, string userName, string plainPassword, bool isEmailConfirmed);
15+
}
16+
}

shesha-core/src/Shesha.Framework/Authorization/Users/UserRegistrationManager.cs

Lines changed: 6 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -9,30 +9,27 @@
99
using Abp.UI;
1010
using Microsoft.AspNetCore.Identity;
1111
using Shesha.Authorization.Roles;
12-
using Shesha.Extensions;
12+
using Shesha.Extensions;
1313
using Shesha.MultiTenancy;
1414

1515
namespace Shesha.Authorization.Users
1616
{
17-
public class UserRegistrationManager : DomainService
17+
public class UserRegistrationManager : DomainService, IUserRegistrationManager
1818
{
19-
public IAbpSession AbpSession { get; set; } = NullAbpSession.Instance;
20-
19+
public IAbpSession AbpSession { get; set; } = NullAbpSession.Instance;
20+
2121
private readonly TenantManager _tenantManager;
2222
private readonly UserManager _userManager;
2323
private readonly RoleManager _roleManager;
24-
private readonly IPasswordHasher<User> _passwordHasher;
2524

2625
public UserRegistrationManager(
2726
TenantManager tenantManager,
2827
UserManager userManager,
29-
RoleManager roleManager,
30-
IPasswordHasher<User> passwordHasher)
28+
RoleManager roleManager)
3129
{
3230
_tenantManager = tenantManager;
3331
_userManager = userManager;
3432
_roleManager = roleManager;
35-
_passwordHasher = passwordHasher;
3633

3734
AbpSession = NullAbpSession.Instance;
3835
}
@@ -56,7 +53,7 @@ public async Task<User> RegisterAsync(string name, string? surname, string email
5653
};
5754

5855
user.SetNormalizedNames();
59-
56+
6057
foreach (var defaultRole in await _roleManager.Roles.Where(r => r.IsDefault).ToListAsync())
6158
{
6259
user.Roles.Add(new UserRole(tenant.Id, user.Id, defaultRole.Id));

shesha-core/src/Shesha.Framework/SheshaFrameworkModule.cs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77
using Microsoft.AspNetCore.Mvc.Filters;
88
using Microsoft.Extensions.Configuration;
99
using Shesha.Authorization;
10+
using Shesha.Authorization.Users;
1011
using Shesha.Configuration;
1112
using Shesha.Configuration.Email;
1213
using Shesha.Configuration.Runtime;
@@ -88,6 +89,7 @@ public override void Initialize()
8889

8990
IocManager.Register<StoredFileService, StoredFileService>(DependencyLifeStyle.Transient);
9091
IocManager.Register<AzureStoredFileService, AzureStoredFileService>(DependencyLifeStyle.Transient);
92+
IocManager.Register<IUserRegistrationManager, UserRegistrationManager>(DependencyLifeStyle.Transient);
9193
IocManager.IocContainer.Register(
9294
Component.For<IStoredFileService>().UsingFactoryMethod(f =>
9395
{

shesha-reactjs/src/components/chevron/index.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -65,7 +65,7 @@ export const ChevronControl: FC<IChevronControlProps> = (props) => {
6565
key={uuid}
6666
{...props}
6767
icon={showIcons === true ? props.icon : undefined}
68-
styleJson={{ ...newStyles, ...stylingBoxCSS, alignContent: fontStyles.textAlign, justifyContent: fontStyles.textAlign }}
68+
styleCss={{ ...newStyles, ...stylingBoxCSS, alignContent: fontStyles.textAlign, justifyContent: fontStyles.textAlign }}
6969
buttonType="text"
7070
label={props.item}
7171
/>

shesha-reactjs/src/components/formDesigner/components/styles.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@ export const useStyles = createStyles(({ css, cx, token }, model: IConfigurableF
2424
> .ant-form-item-label {
2525
${paddingStyles({ ...model.stylingBoxJson, paddingLeft: 0, paddingRight: 0, _type: 'styleBox' })}
2626
align-content: center;
27+
min-height: fit-content;
2728
${model.autoAlignLabel !== false
2829
? `
2930
/* A validation message grows the control column. With height: 100% the label

shesha-reactjs/src/components/formDesigner/formComponent/formComponentModelPreparer.tsx

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,7 @@ export const FormComponentModelPreparer: FC<FormComponentPrepareModelProps> = ({
5151
return sourceComponentModel;
5252

5353
// Default styles + Theme component styles
54-
const defStyle: IStyleValue = toolboxComponent?.getDefaultStyles?.() ?? { styleJson: {} };
54+
const defStyle: IStyleValue = toolboxComponent?.getDefaultStyles?.() ?? { styleCss: {} };
5555
const themeDefStyle: IStyleValue = isDefined(theme.components)
5656
? deepMergeValues(defStyle, theme.components[sourceComponentModel.type] as IStyleValue, deepMergeSkipUndefinedFunc)
5757
: defStyle;
@@ -89,7 +89,8 @@ export const FormComponentModelPreparer: FC<FormComponentPrepareModelProps> = ({
8989

9090
const { isInput = false, isOutput = false } = toolboxComponent ?? {};
9191

92-
const styleJson = useActualContextExecution(unwrappedModel.style, undefined, {}); // use default style if empty or error
92+
const styleCss = useActualContextExecution(unwrappedModel.style, undefined, unwrappedModel.styleCss ?? {}); // use default style if empty or error
93+
const wrapperStyleCss = useActualContextExecution(unwrappedModel.wrapperStyle, undefined, unwrappedModel.wrapperStyleCss ?? {}); // use default style if empty or error
9394

9495
const allowInherit = toolboxComponent?.allowInherit === true;
9596
const readOnly = useMemo(() =>
@@ -111,9 +112,9 @@ export const FormComponentModelPreparer: FC<FormComponentPrepareModelProps> = ({
111112

112113
const propertyName = isInput || isOutput ? unwrappedModel.propertyName : undefined;
113114

114-
const actualModel = useMemo(() => {
115-
return { ...unwrappedModel, styleJson, readOnly, disabled, hidden, propertyName };
116-
}, [hidden, propertyName, readOnly, disabled, styleJson, unwrappedModel]);
115+
const actualModel = useMemo((): UnwrapCodeEvaluators<IConfigurableFormComponent> => {
116+
return { ...unwrappedModel, styleCss, wrapperStyleCss, readOnly, disabled, hidden, propertyName };
117+
}, [hidden, propertyName, readOnly, disabled, styleCss, wrapperStyleCss, unwrappedModel]);
117118

118119
const actualApiModel = useDeepCompareMemo(() => deepMergeValues(actualModel, apiModel), [actualModel, apiModel]);
119120

@@ -145,7 +146,7 @@ export const FormComponentModelPreparer: FC<FormComponentPrepareModelProps> = ({
145146
};
146147
}, [modelMetadata, actualApiModel.propertyName]);
147148

148-
const componentModel = useDeepCompareMemo(() => {
149+
const componentModel = useDeepCompareMemo((): UnwrapCodeEvaluators<IConfigurableFormComponent> => {
149150
return toolboxComponent && propMetadata
150151
? updateComponentModelFromMetadata(toolboxComponent, actualApiModel, propMetadata) as UnwrapCodeEvaluators<IConfigurableFormComponent>
151152
: actualApiModel;

shesha-reactjs/src/components/formDesigner/utils/stylingUtils.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -76,7 +76,7 @@ export const getFullSizeWrapperStyle = (model: IStyleValue): IStyleValue => ({
7676
* This allows to keep the margins the same as in the "live" forms.
7777
* If the component's margin is less than the designer's padding,
7878
* then the padding - margin difference is applied so that the component always has a minimum padding in designer mode. */
79-
const getDesignerPadding = (value: string | number | undefined, designerValue: string | number | undefined): string | number | undefined => {
79+
export const getDesignerPadding = (value: string | number | undefined, designerValue: string | number | undefined): string | number | undefined => {
8080
const stringValue = isDefined(value) ? String(value) : undefined;
8181
const designerStringValue = isDefined(designerValue) ? String(designerValue) : undefined;
8282
if (isNullOrWhiteSpace(stringValue) || isNullOrWhiteSpace(designerStringValue)) return designerValue;

0 commit comments

Comments
 (0)