From ad717ea56ed519764f474261f3c6bcd1cad5a344 Mon Sep 17 00:00:00 2001 From: lukeIam Date: Tue, 3 Dec 2013 20:11:08 +0100 Subject: [PATCH] Webserver: -fix: problems setting the password and login --- Vocaluxe/Base/Server/CVocaluxeServer.cs | 1 + VocaluxeLib/Profile/CProfile.cs | 14 ++++++++++---- 2 files changed, 11 insertions(+), 4 deletions(-) diff --git a/Vocaluxe/Base/Server/CVocaluxeServer.cs b/Vocaluxe/Base/Server/CVocaluxeServer.cs index eaf4f15e..f77acf4b 100644 --- a/Vocaluxe/Base/Server/CVocaluxeServer.cs +++ b/Vocaluxe/Base/Server/CVocaluxeServer.cs @@ -178,6 +178,7 @@ namespace Vocaluxe.Base.Server { newProfile = new CProfile { + ID = existingProfile.ID, Active = existingProfile.Active, AvatarFileName = existingProfile.AvatarFileName, Avatar = existingProfile.Avatar, diff --git a/VocaluxeLib/Profile/CProfile.cs b/VocaluxeLib/Profile/CProfile.cs index 48cc4bba..bae8a241 100644 --- a/VocaluxeLib/Profile/CProfile.cs +++ b/VocaluxeLib/Profile/CProfile.cs @@ -92,10 +92,10 @@ namespace VocaluxeLib.Profile xmlReader.TryGetEnumValue("//root/Info/Active", ref Active); string passwordHash; xmlReader.GetValue("//root/Info/PasswordHash", out passwordHash, ""); - PasswordHash = Encoding.UTF8.GetBytes(passwordHash); + PasswordHash = !string.IsNullOrEmpty(passwordHash) ? Convert.FromBase64String(passwordHash) : null; string passwordSalt; xmlReader.GetValue("//root/Info/PasswordHash", out passwordSalt, ""); - PasswordSalt = Encoding.UTF8.GetBytes(passwordSalt); + PasswordSalt = !string.IsNullOrEmpty(passwordSalt) ? Convert.FromBase64String(passwordSalt) : null; string userRoles; xmlReader.GetValue("//root/Info/UserRoles", out userRoles, "0"); Int32.TryParse(userRoles, out UserRoles); @@ -159,8 +159,14 @@ namespace VocaluxeLib.Profile writer.WriteElementString("Avatar", Path.GetFileName(Avatar.FileName)); writer.WriteElementString("GuestProfile", Enum.GetName(typeof(EOffOn), GuestProfile)); writer.WriteElementString("Active", Enum.GetName(typeof(EOffOn), Active)); - writer.WriteElementString("PasswordHash", Encoding.UTF8.GetString(PasswordHash)); - writer.WriteElementString("PasswordSalt", Encoding.UTF8.GetString(PasswordSalt)); + if (PasswordHash != null) + { + writer.WriteElementString("PasswordHash", Convert.ToBase64String(PasswordHash)); + } + if (PasswordSalt != null) + { + writer.WriteElementString("PasswordSalt", Convert.ToBase64String(PasswordSalt)); + } writer.WriteElementString("UserRoles", UserRoles.ToString()); writer.WriteEndElement();