Add checks on the login and creating of user
This commit is contained in:
@@ -8,6 +8,6 @@ namespace skydiveLogs_api.Business.Interface
|
||||
|
||||
User GetById(int userId);
|
||||
|
||||
void AddNewUser(User user);
|
||||
bool AddNewUser(User user);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -27,10 +27,19 @@ namespace skydiveLogs_api.Business
|
||||
return _userRepository.GetByLogin(login, EncryptPassword(password));
|
||||
}
|
||||
|
||||
public void AddNewUser(User newUser)
|
||||
public bool AddNewUser(User newUser)
|
||||
{
|
||||
newUser.Password = EncryptPassword(newUser.Password);
|
||||
_userRepository.Add(newUser);
|
||||
var foundUser = _userRepository.GetByLogin(newUser.Login, newUser.Password);
|
||||
var result = false;
|
||||
|
||||
if (foundUser == null)
|
||||
{
|
||||
_userRepository.Add(newUser);
|
||||
result = true;
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
private string EncryptPassword(string password)
|
||||
|
||||
Reference in New Issue
Block a user