fix register user
This commit is contained in:
parent
b8d56680a5
commit
2fc97f469c
@ -1,5 +1,8 @@
|
|||||||
|
using System.Linq;
|
||||||
using System.Threading.Tasks;
|
using System.Threading.Tasks;
|
||||||
using Abp.Configuration;
|
using Abp.Configuration;
|
||||||
|
using Abp.Domain.Repositories;
|
||||||
|
using Abp.UI;
|
||||||
using Abp.Zero.Configuration;
|
using Abp.Zero.Configuration;
|
||||||
using SystemKonkursow.Authorization.Accounts.Dto;
|
using SystemKonkursow.Authorization.Accounts.Dto;
|
||||||
using SystemKonkursow.Authorization.Users;
|
using SystemKonkursow.Authorization.Users;
|
||||||
@ -9,11 +12,14 @@ namespace SystemKonkursow.Authorization.Accounts
|
|||||||
public class AccountAppService : SystemKonkursowAppServiceBase, IAccountAppService
|
public class AccountAppService : SystemKonkursowAppServiceBase, IAccountAppService
|
||||||
{
|
{
|
||||||
private readonly UserRegistrationManager _userRegistrationManager;
|
private readonly UserRegistrationManager _userRegistrationManager;
|
||||||
|
private readonly IRepository<User, long> _userRepository;
|
||||||
|
|
||||||
public AccountAppService(
|
public AccountAppService(
|
||||||
UserRegistrationManager userRegistrationManager)
|
UserRegistrationManager userRegistrationManager,
|
||||||
|
IRepository<User, long> userRepository)
|
||||||
{
|
{
|
||||||
_userRegistrationManager = userRegistrationManager;
|
_userRegistrationManager = userRegistrationManager;
|
||||||
|
_userRepository = userRepository;
|
||||||
}
|
}
|
||||||
|
|
||||||
public async Task<IsTenantAvailableOutput> IsTenantAvailable(IsTenantAvailableInput input)
|
public async Task<IsTenantAvailableOutput> IsTenantAvailable(IsTenantAvailableInput input)
|
||||||
@ -34,6 +40,26 @@ namespace SystemKonkursow.Authorization.Accounts
|
|||||||
|
|
||||||
public async Task<RegisterOutput> Register(RegisterInput input)
|
public async Task<RegisterOutput> Register(RegisterInput input)
|
||||||
{
|
{
|
||||||
|
|
||||||
|
var checkUserEmail = _userRepository.GetAll().Where(t => t.EmailAddress == input.EmailAddress).FirstOrDefault();
|
||||||
|
|
||||||
|
var checkUserName = _userRepository.GetAll().Where(t => t.UserName == input.UserName).FirstOrDefault();
|
||||||
|
|
||||||
|
if (null != checkUserEmail && null != checkUserName)
|
||||||
|
{
|
||||||
|
throw new UserFriendlyException(L("RegisterFailed"), string.Format("U¿ytkownik o adresie email: {0} i nazwie u¿ytkownika: {1} ju¿ istnieje", input.EmailAddress, input.UserName));
|
||||||
|
}
|
||||||
|
|
||||||
|
if (null != checkUserEmail)
|
||||||
|
{
|
||||||
|
throw new UserFriendlyException(L("RegisterFailed"), string.Format("U¿ytkownik o adresie email: {0} ju¿ istnieje", input.EmailAddress));
|
||||||
|
}
|
||||||
|
|
||||||
|
if (null != checkUserName)
|
||||||
|
{
|
||||||
|
throw new UserFriendlyException(L("RegisterFailed"), string.Format("U¿ytkownik o nazwie u¿ytkownika: {0} ju¿ istnieje", input.UserName));
|
||||||
|
}
|
||||||
|
|
||||||
var user = await _userRegistrationManager.RegisterAsync(
|
var user = await _userRegistrationManager.RegisterAsync(
|
||||||
input.Name,
|
input.Name,
|
||||||
input.Surname,
|
input.Surname,
|
||||||
|
@ -34,6 +34,7 @@
|
|||||||
<text name="DefaultPasswordIs" value="Default password is {0}" />
|
<text name="DefaultPasswordIs" value="Default password is {0}" />
|
||||||
<text name="CanBeEmptyToLoginAsHost" value="Can be empty to login as host." />
|
<text name="CanBeEmptyToLoginAsHost" value="Can be empty to login as host." />
|
||||||
<text name="Register" value="Register" />
|
<text name="Register" value="Register" />
|
||||||
|
<text name="RegisterFailed" value="Błąd rejestracji!" />
|
||||||
<text name="OrLoginWith" value="Or login with" />
|
<text name="OrLoginWith" value="Or login with" />
|
||||||
<text name="WaitingForActivationMessage" value="Your account is waiting to be activated by system admin." />
|
<text name="WaitingForActivationMessage" value="Your account is waiting to be activated by system admin." />
|
||||||
<text name="TenantSelection" value="Tenant Selection" />
|
<text name="TenantSelection" value="Tenant Selection" />
|
||||||
|
Loading…
Reference in New Issue
Block a user