public ActionResult SignUp(pengguna data)
 {
     if (!ModelState.IsValid)
     {
         return(View());
     }
     using (var db = new MainDBContext())
     {
         if (!db.dataPengguna.Where(x => x.username == data.username || x.email == data.email).Any())
         {
             data.password = HashString.hash(data.password);
             db.dataPengguna.Add(data);
             db.SaveChanges();
             return(RedirectToAction("Login", "Authentication"));
         }
         else
         {
             TempData["pesan"] = "username atau email telah terdaftar";
             return(View());
         }
     }
 }
 public ActionResult Login(pengguna data)
 {
     if (ModelState.IsValid)
     {
         using (var db = new MainDBContext())
         {
             if (db.dataPengguna.Where(x => x.username == data.username).Any())
             {
                 var    dataUser   = db.dataPengguna.First(x => x.username == data.username);
                 string passwordDB = dataUser.password;
                 if (HashString.hash(data.password) == passwordDB)
                 {
                     var identity = new ClaimsIdentity(new[]
                     {
                         new Claim("username", dataUser.username),
                         new Claim("email", dataUser.email)
                     },
                                                       "ApplicationCookie");
                     var ctx         = Request.GetOwinContext();
                     var authmanager = ctx.Authentication;
                     authmanager.SignIn(identity);
                     Session["username"] = dataUser.username;
                     return(RedirectToAction("Index", "Home"));
                 }
                 else
                 {
                     TempData["pesan"] = "password salah";
                 }
             }
             else
             {
                 TempData["pesan"] = "username tidak terdaftar";
             }
         }
     }
     return(View());
 }