コード例 #1
0
ファイル: DBHelper.cs プロジェクト: milena23/iLoveRss
 public static void DeleteUserInfo(UserInfo ui)
 {
     using (ISession session = sessions.OpenSession())
     using (ITransaction tx = session.BeginTransaction())
     {
         session.Delete(ui);
         tx.Commit();
     }
 }
コード例 #2
0
ファイル: AdminHelper.cs プロジェクト: milena23/iLoveRss
 public void UpdateBase()
 {
     dbHelper.Configure();
     dbHelper.CreateTables();
     var user = new User
     {
         Login = "******",
         Password = "******",
         Email = null,
         Salt = lgHelper.CreateSalt(),
         IsActivated = 1,
         CreateData = DateTime.Now,
         EmailKey = null
     };
     var info = new Info { FirstName = null, LastName = null, Age = null };
     var ui = new UserInfo { User = user, Info = info };
     user.PasswordSaltHash = lgHelper.CreatePasswordHash(user.Password, user.Salt);
     DbHelper.InsertUser(user);
     DbHelper.InsertInfo(info);
     DbHelper.InsertUserInfo(ui);
 }
コード例 #3
0
ファイル: UsersController.cs プロジェクト: milena23/iLoveRss
 public ActionResult Login(LoginModel model)
 {
     try
     {
         if (ModelState.IsValid)
         {
             if (model.Password != model.ConfirmPassword)
             {
                 return Json(new {error_message = ValidationStrings.PasswordsMustMatch},
                             JsonRequestBehavior.AllowGet);
             }
             dbHelper.Configure();
             var findLogin =  DbHelper.FindContacts(model.Login);
             if (findLogin.Count != 0)
             {
                 return Json(new {error_message = ValidationStrings.LoginInDb},
                             JsonRequestBehavior.AllowGet);
             }
             var user = new User
                            {
                                Login = model.Login,
                                Password = model.Password,
                                Email = model.Email,
                                Salt = lgHelper.CreateSalt(),
                                IsActivated = 0,
                                CreateData = DateTime.Now,
                                EmailKey = lgHelper.GenerateKey()
                            };
             var info = new Info {FirstName = model.FirstName, LastName = model.LastName, Age = model.Age};
             var ui = new UserInfo {User = user, Info = info};
             user.PasswordSaltHash = lgHelper.CreatePasswordHash(user.Password, user.Salt);
             string activationLink = "http://localhost:2885/Users/Activate/" +
                                     user.Login + "/" + user.EmailKey;
             SendMail.SendEmail(activationLink, user.Email);
             DbHelper.InsertUser(user);
             DbHelper.InsertInfo(info);
             DbHelper.InsertUserInfo(ui);
             return Json(new {redirect = Url.Action("Welcome", "Home")});
         }
     }
     catch(Exception e)
     {
         ViewData["Error"] = e.Message;
     }
     return RenderAnswer();
 }