This commit is contained in:
s426226 2021-01-09 11:55:07 +01:00
parent 6586dc6170
commit c9de5656c3
2 changed files with 10 additions and 10 deletions

View File

@ -33,7 +33,7 @@ namespace Serwer.Core.Domain
{
if (string.IsNullOrWhiteSpace(email))
{
throw new Exception("Email cannot be empty");
throw new Exception("Email nie może być pusty.");
}
if (Email == email)
{
@ -48,7 +48,7 @@ namespace Serwer.Core.Domain
{
if (string.IsNullOrWhiteSpace(name))
{
throw new Exception("Name cannot be empty");
throw new Exception("Imię nie może być puste.");
}
if (Name == name)
{
@ -63,7 +63,7 @@ namespace Serwer.Core.Domain
{
if (string.IsNullOrWhiteSpace(surname))
{
throw new Exception("Surname cannot be empty");
throw new Exception("Nazwisko nie może być puste.");
}
if (Surname == surname)
{
@ -78,7 +78,7 @@ namespace Serwer.Core.Domain
{
if (string.IsNullOrWhiteSpace(login))
{
throw new Exception("Login cannot be empty");
throw new Exception("Login nie może być pusty.");
}
if (Login == login)
{
@ -93,7 +93,7 @@ namespace Serwer.Core.Domain
{
if (string.IsNullOrWhiteSpace(password))
{
throw new Exception("Password cannot be empty");
throw new Exception("Hasło nie może być puste.");
}
if (Password == password)
{

View File

@ -29,7 +29,7 @@ namespace Serwer.Infrastructure.Services
{
if(await _userRepository.GetAsync(login) != null)
{
throw new Exception($"User with login: {login} already exists.");
throw new Exception($"Użytkownik z loginem: {login} już istnieje.");
}
var user = new User(Guid.NewGuid(), email, name, surname, login, password);
await _userRepository.AddAsync(user);
@ -40,11 +40,11 @@ namespace Serwer.Infrastructure.Services
var user = await _userRepository.GetAsync(login);
if(user == null)
{
throw new Exception("User not found.");
throw new Exception("Nie znaleziono użytkownika.");
}
if(user.Password != password)
{
throw new Exception("Incorrect password.");
throw new Exception("Hasło niepoprawne.");
}
var jwt = _jwtHandler.CreateToken(user.Id);
@ -61,12 +61,12 @@ namespace Serwer.Infrastructure.Services
var user = await _userRepository.GetAsync(userModel.Id);
if(user == null)
{
throw new Exception("User not found.");
throw new Exception("Nie znaleziono użytkownika.");
}
var userLoginTaken = await _userRepository.GetAsync(userModel.Login);
if(userLoginTaken != null && userLoginTaken.Id != user.Id)
{
throw new Exception("User login taken.");
throw new Exception("Login jest już zajęty.");
}
var newUser = new User(user.Id, userModel.Email, userModel.Name, userModel.Surname, userModel.Login, user.Password);