Пример #1
0
 public SaltedHash LoadCurrentSaltedHash(string login) {
     var result = new SaltedHash("", "");
     using (var eventStore = new FolderBlackBox(EventStorePath)) {
         var events = eventStore.Player.WithContext(login).Play();
         foreach (var recordedEvent in events) {
             DoCommandWithEvent(recordedEvent, result);
         }
     }
     return result;
 }
Пример #2
0
 private static void DoCommandWithEvent(IRecordedEvent recordedEvent, SaltedHash result) {
     switch (recordedEvent.Name) {
         case RegisteredEventName:
             var registerEvent = JsonConvert.DeserializeObject<RegisteredEvent>(recordedEvent.Data);
             result.Salt = registerEvent.Salt;
             result.Hash = registerEvent.Hash;
             break;
         case PasswordChangedEventName:
             var passwordChangeEvent = JsonConvert.DeserializeObject<PasswordChangedEvent>(recordedEvent.Data);
             result.Salt = passwordChangeEvent.Salt;
             result.Hash = passwordChangeEvent.Hash;
             break;
         case NameChangedEventName:
             var nameChangedEvent = JsonConvert.DeserializeObject<NameChangedEvent>(recordedEvent.Data);
             break;
     }
 }