Add a cache system on the referential info
+ Add an identity service
This commit is contained in:
@@ -1,17 +1,17 @@
|
||||
using System.Security.Cryptography;
|
||||
using System.Text;
|
||||
using System.IO;
|
||||
using System;
|
||||
|
||||
using skydiveLogs_api.Domain;
|
||||
using skydiveLogs_api.DomainBusiness.Interfaces;
|
||||
using skydiveLogs_api.DomainService.Repositories;
|
||||
using skydiveLogs_api.Domain;
|
||||
|
||||
using System;
|
||||
using System.IO;
|
||||
using System.Security.Cryptography;
|
||||
using System.Text;
|
||||
|
||||
namespace skydiveLogs_api.DomainBusiness
|
||||
{
|
||||
public class UserService : IUserService
|
||||
{
|
||||
#region Public Constructors
|
||||
|
||||
public UserService(IUserRepository userRepository,
|
||||
IGearService gearService)
|
||||
{
|
||||
@@ -19,15 +19,9 @@ namespace skydiveLogs_api.DomainBusiness
|
||||
_gearService = gearService;
|
||||
}
|
||||
|
||||
public User GetById(int userId)
|
||||
{
|
||||
return _userRepository.GetById(userId);
|
||||
}
|
||||
#endregion Public Constructors
|
||||
|
||||
public User GetByLogin(string login, string password)
|
||||
{
|
||||
return _userRepository.GetByLogin(login, EncryptPassword(password));
|
||||
}
|
||||
#region Public Methods
|
||||
|
||||
public bool AddNewUser(User newUser, bool isAdmin = false)
|
||||
{
|
||||
@@ -51,9 +45,23 @@ namespace skydiveLogs_api.DomainBusiness
|
||||
return result;
|
||||
}
|
||||
|
||||
public User GetById(int userId)
|
||||
{
|
||||
return _userRepository.GetById(userId);
|
||||
}
|
||||
|
||||
public User GetByLogin(string login, string password)
|
||||
{
|
||||
return _userRepository.GetByLogin(login, EncryptPassword(password));
|
||||
}
|
||||
|
||||
#endregion Public Methods
|
||||
|
||||
#region Private Methods
|
||||
|
||||
private string EncryptPassword(string password)
|
||||
{
|
||||
var encryptionKey = "skydivelogsangular"; //we can change the code converstion key as per our requirement
|
||||
var encryptionKey = "skydivelogsangular"; //we can change the code converstion key as per our requirement
|
||||
byte[] clearBytes = Encoding.Unicode.GetBytes(password);
|
||||
var encryptedPassword = string.Empty;
|
||||
|
||||
@@ -78,8 +86,13 @@ namespace skydiveLogs_api.DomainBusiness
|
||||
return encryptedPassword;
|
||||
}
|
||||
|
||||
private readonly IUserRepository _userRepository;
|
||||
#endregion Private Methods
|
||||
|
||||
#region Private Fields
|
||||
|
||||
private readonly IGearService _gearService;
|
||||
private readonly IUserRepository _userRepository;
|
||||
|
||||
#endregion Private Fields
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user