Пример #1
0
 /// <summary>
 /// Creates a user profile, which is stored on disk. Password will be encrypted using machine key. Created profile will be set as active profile.
 /// </summary>
 /// <param name="email">Email of user</param>
 /// <param name="password">Password of user</param>
 public void CreateProfile(string email, string password)
 {
     Profile profile = new Profile();
     profile.Email = email.ToLower();
     //Encrypt password
     var passwordData = Encoding.UTF8.GetBytes(password);
     var encryptedData = MachineKey.Protect(passwordData);
     profile.Password = Convert.ToBase64String(encryptedData);
     profile.Save();
     _Cache.Remove(Constants.CACHE_PROFILEJSON);
     _CurrentProfile = profile;
     _Http = new HttpHelper(_CurrentProfile);
 }
Пример #2
0
 /// <summary>
 /// Loads a profile and sets it as active.
 /// </summary>
 /// <param name="email">Email of user</param>
 /// <returns>false if profile was not created</returns>
 public bool LoadProfile(string email)
 {
     var profile = Profile.Load(email);
     if (profile == null)
     {
         return false;
     }
     _Cache.Remove(Constants.CACHE_PROFILEJSON);
     _CurrentProfile = profile;
     _Http = new HttpHelper(_CurrentProfile);
     return true;
 }