コード例 #1
0
ファイル: LoginVM.cs プロジェクト: Shadow85Pl/PaskiPlacowe
 private void LogInUserFunc()
 {
     try
     {
         Model.Uzytkownicy User = LoginBegin(true);
         if (User == null)
         {
             throw new Exception(Localization.Messages.MSG_USER_DONT_EXISTS);
         }
         using (var h = new SHA512Managed())
         {
             if ((this.Password != null && !this.Password.IsNullOrWhiteSpace() && User.HASLO != null && User.HASLO.SequenceEqual(this.Password.Process(h.ComputeHash))) ||
                 ((this.Password == null || this.Password.IsNullOrWhiteSpace()) && User.HASLO == null))
             {
                 LogIn(User.ID_UZYTKOWNIKA);
             }
             else
             {
                 throw new Exception(Localization.Messages.MSG_USER_CREDENTIALS_INCORECT);
             }
         }
     }
     catch (Exception Ex)
     {
         LoginErrMSG = Ex.Message;
     }
 }
コード例 #2
0
ファイル: LoginVM.cs プロジェクト: Shadow85Pl/PaskiPlacowe
 private void AddNewUserFunc()
 {
     try
     {
         if (LoginBegin(true) != null)
         {
             throw new Exception(Localization.Messages.MSG_USER_ALREADY_EXISTS);
         }
         using (var h = new SHA512Managed())
         {
             Model.Uzytkownicy NewUser = new Model.Uzytkownicy()
             {
                 NAZWA = this.Login,
                 LOGIN = this.Login,
                 HASLO = this.Password != null && !this.Password.IsNullOrWhiteSpace() ? this.Password.Process(h.ComputeHash) : null
             };
             DB.Uzytkownicy.Add(NewUser);
             DB.SaveChanges();
             LogIn(NewUser.ID_UZYTKOWNIKA);
         }
     }
     catch (Exception Ex)
     {
         LoginErrMSG = Ex.Message;
     }
 }