develop #10
@ -33,7 +33,7 @@ namespace Serwer.Core.Domain
|
|||||||
{
|
{
|
||||||
if (string.IsNullOrWhiteSpace(email))
|
if (string.IsNullOrWhiteSpace(email))
|
||||||
{
|
{
|
||||||
throw new Exception("Email cannot be empty");
|
throw new Exception("Email nie może być pusty.");
|
||||||
}
|
}
|
||||||
if (Email == email)
|
if (Email == email)
|
||||||
{
|
{
|
||||||
@ -48,7 +48,7 @@ namespace Serwer.Core.Domain
|
|||||||
{
|
{
|
||||||
if (string.IsNullOrWhiteSpace(name))
|
if (string.IsNullOrWhiteSpace(name))
|
||||||
{
|
{
|
||||||
throw new Exception("Name cannot be empty");
|
throw new Exception("Imię nie może być puste.");
|
||||||
}
|
}
|
||||||
if (Name == name)
|
if (Name == name)
|
||||||
{
|
{
|
||||||
@ -63,7 +63,7 @@ namespace Serwer.Core.Domain
|
|||||||
{
|
{
|
||||||
if (string.IsNullOrWhiteSpace(surname))
|
if (string.IsNullOrWhiteSpace(surname))
|
||||||
{
|
{
|
||||||
throw new Exception("Surname cannot be empty");
|
throw new Exception("Nazwisko nie może być puste.");
|
||||||
}
|
}
|
||||||
if (Surname == surname)
|
if (Surname == surname)
|
||||||
{
|
{
|
||||||
@ -78,7 +78,7 @@ namespace Serwer.Core.Domain
|
|||||||
{
|
{
|
||||||
if (string.IsNullOrWhiteSpace(login))
|
if (string.IsNullOrWhiteSpace(login))
|
||||||
{
|
{
|
||||||
throw new Exception("Login cannot be empty");
|
throw new Exception("Login nie może być pusty.");
|
||||||
}
|
}
|
||||||
if (Login == login)
|
if (Login == login)
|
||||||
{
|
{
|
||||||
@ -93,7 +93,7 @@ namespace Serwer.Core.Domain
|
|||||||
{
|
{
|
||||||
if (string.IsNullOrWhiteSpace(password))
|
if (string.IsNullOrWhiteSpace(password))
|
||||||
{
|
{
|
||||||
throw new Exception("Password cannot be empty");
|
throw new Exception("Hasło nie może być puste.");
|
||||||
}
|
}
|
||||||
if (Password == password)
|
if (Password == password)
|
||||||
{
|
{
|
||||||
|
@ -29,7 +29,7 @@ namespace Serwer.Infrastructure.Services
|
|||||||
{
|
{
|
||||||
if(await _userRepository.GetAsync(login) != null)
|
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);
|
var user = new User(Guid.NewGuid(), email, name, surname, login, password);
|
||||||
await _userRepository.AddAsync(user);
|
await _userRepository.AddAsync(user);
|
||||||
@ -40,11 +40,11 @@ namespace Serwer.Infrastructure.Services
|
|||||||
var user = await _userRepository.GetAsync(login);
|
var user = await _userRepository.GetAsync(login);
|
||||||
if(user == null)
|
if(user == null)
|
||||||
{
|
{
|
||||||
throw new Exception("User not found.");
|
throw new Exception("Nie znaleziono użytkownika.");
|
||||||
}
|
}
|
||||||
if(user.Password != password)
|
if(user.Password != password)
|
||||||
{
|
{
|
||||||
throw new Exception("Incorrect password.");
|
throw new Exception("Hasło niepoprawne.");
|
||||||
}
|
}
|
||||||
|
|
||||||
var jwt = _jwtHandler.CreateToken(user.Id);
|
var jwt = _jwtHandler.CreateToken(user.Id);
|
||||||
@ -61,12 +61,12 @@ namespace Serwer.Infrastructure.Services
|
|||||||
var user = await _userRepository.GetAsync(userModel.Id);
|
var user = await _userRepository.GetAsync(userModel.Id);
|
||||||
if(user == null)
|
if(user == null)
|
||||||
{
|
{
|
||||||
throw new Exception("User not found.");
|
throw new Exception("Nie znaleziono użytkownika.");
|
||||||
}
|
}
|
||||||
var userLoginTaken = await _userRepository.GetAsync(userModel.Login);
|
var userLoginTaken = await _userRepository.GetAsync(userModel.Login);
|
||||||
if(userLoginTaken != null && userLoginTaken.Id != user.Id)
|
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);
|
var newUser = new User(user.Id, userModel.Email, userModel.Name, userModel.Surname, userModel.Login, user.Password);
|
||||||
|
Loading…
Reference in New Issue
Block a user