Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update azure-pipeline branch #246

Merged
merged 8 commits into from
May 21, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 0 additions & 16 deletions delete-bin-obj-folders.bat

This file was deleted.

21 changes: 21 additions & 0 deletions delete-temp-directories.bat
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
@echo off
cls

set directories= bin, obj, logs, node_modules
set /a count = 0

echo Deleting all following directories:
for %%d in (%directories%) do echo %%d
echo.

for /d /r . %%d in (%directories%) do if exist "%%d" (
echo. Deleting: %%d
rd /s/q "%%d"
set /a count += 1
)

echo.
echo The specified directories were successfully scanned.
echo Number of deleted directories: %count%
echo Press any key to exit.
pause > nul
Original file line number Diff line number Diff line change
@@ -1,8 +1,11 @@
using System.Threading.Tasks;
using System.Linq;
using System.Threading.Tasks;
using EShopOnAbp.IdentityService.ETOs;
using Microsoft.AspNetCore.Identity;
using Microsoft.Extensions.Logging;
using Volo.Abp;
using Volo.Abp.DependencyInjection;
using Volo.Abp.Domain.Repositories;
using Volo.Abp.EventBus.Distributed;
using Volo.Abp.Identity;
using Volo.Abp.Uow;
Expand All @@ -13,16 +16,22 @@ public class UserLoggedInEventHandler : IDistributedEventHandler<UserLoggedInEto
{
private readonly IdentityUserManager _userManager;
private readonly ILogger<UserLoggedInEventHandler> _logger;
private readonly IIdentityUserRepository _identityUserRepository;
private readonly ILookupNormalizer _lookupNormalizer;

public UserLoggedInEventHandler(IdentityUserManager userManager, ILogger<UserLoggedInEventHandler> logger)
public UserLoggedInEventHandler(IdentityUserManager userManager,
ILogger<UserLoggedInEventHandler> logger,
IIdentityUserRepository identityUserRepository,
ILookupNormalizer lookupNormalizer)
{
_userManager = userManager;
_logger = logger;
_identityUserRepository = identityUserRepository;
_lookupNormalizer = lookupNormalizer;
}



[UnitOfWork]
public async virtual Task HandleEventAsync(UserLoggedInEto eventData)
public virtual async Task HandleEventAsync(UserLoggedInEto eventData)
{
if (eventData == null)
{
Expand Down Expand Up @@ -59,8 +68,15 @@ protected virtual async Task CreateCurrentUserAsync(UserLoggedInEto userInfo)
// This should run once to sync the admin userIds that seeded by IdentityModule and the Keycloak admin
if (userInfo.UserName == "admin")
{
var adminUser = await _userManager.FindByNameAsync("admin");
await _userManager.DeleteAsync(adminUser);
var normalizedName = _lookupNormalizer.NormalizeName(userInfo.UserName);
var adminUser = await _identityUserRepository.FindByNormalizedUserNameAsync(normalizedName);
foreach (var role in adminUser.Roles.ToList())
{
user.AddRole(role.RoleId);
}

// Hard delete the admin-user
await _identityUserRepository.HardDeleteAsync(adminUser, true);
}

var result = await _userManager.CreateAsync(user);
Expand Down
Loading