public LoginUserDTO AuthenticateUser(LoginUserDTO user) { LoginRepository loginRepository = new LoginRepository(); LoginUserDTO authenticatedUser = new LoginUserDTO(); HashEngine createHash = new HashEngine(); user.Password = createHash.GeneratePasswordHash(user.Password); authenticatedUser = loginRepository.AuthenticateUser(user); return(authenticatedUser); }
public bool RegisterUser(AppUserDTO appUser, byte[] profileImage) { RegistrationRepository registrationRepository = new RegistrationRepository(); HashEngine createHash = new HashEngine(); //Convert the profile image byte array to base 64 string string profileInBase64String = Convert.ToBase64String(profileImage, 0, profileImage.Length); //Insert base 64 image string to appUser DTO appUser.ProfilePicture = "data:image/jpeg;base64, " + profileInBase64String; //Generate user name for the user appUser.UserName = GenerateUserName(appUser.EmailAddress); //convert the password to password hash appUser.Password = createHash.GeneratePasswordHash(appUser.Password); return(registrationRepository.RegisterUser(appUser)); }