2016-03-29 4 views
0

Ausführung Wenn ich ein falsches Passwort oder E-Mail in meinem modale Formular eingeben meine MVC Website tatsächlich meine viewbag funktioniert nicht im Controller in meinem Code einloggen:Unzureichende Stapel weiterhin das Programm sicher in modal

public ActionResult Login() 
    { 
     return PartialView(); 
    } 
    [HttpPost] 
    public ActionResult Login(LoginViewModel login) 
    { 
     if (ModelState.IsValid) 
     { 
      var Encode = Encryption.EncodePasswordMd5(login.Password); 
      var logined = db.Members.Where(s => s.EmailAddress == login.EmailAddress && s.Password == Encode).FirstOrDefault(); 
      if (logined != null) 
      {  //todo: redircet to admin panel 
       if (logined.Role==Role.admin) 
       { 
        FormsAuthentication.SetAuthCookie(logined.Id.ToString(), login.KeepMe); 
        return RedirectToAction("panel", "Admin"); 
       } 
        //todo: redircet to user panel 
        FormsAuthentication.SetAuthCookie(logined.Id.ToString(), login.KeepMe); 
        return RedirectToAction("Index", "Home"); 
      } 
      ViewBag.Error = "wrong email or password"; 
      return View(); 
     } 

     return View(login); 
    } 

Dies ist mein Bootstrap-modal in meinem Layout:

<div class="modal fade" id="myModal" tabindex="-1" role="dialog" aria-labelledby="myModalLabel"> 
<div class="modal-dialog" role="document"> 
    <div class="modal-content"> 
     <div class="modal-header"> 
      <button type="button" class="close" data-dismiss="modal" aria-label="Close"><span aria-hidden="true">&times;</span></button> 
     </div> 
     <div class="modal-body" id="bodymodal"> 
      @Html.Action("Login","Account") 
     </div> 
     <div class="modal-footer"> 
      <button type="button" class="btn btn-default" data-dismiss="modal">Close</button> 
     </div> 
    </div> 
</div> 

+0

MD5-Hashing für Verstauen Passwörter nicht die beste Wahl ist. –

+0

aber besser als speichern ohne Hashing! Mein Problem nicht das! –

+0

Ihr Problem * jetzt * ist nicht das - es wird später sein, wenn Sie vergessen haben, dass Sie das getan haben, und müssen die Tatsache vor einer Gruppe von Menschen verteidigen, die fragen, warum ihre Anmeldeinformationen gestohlen wurden. –

Antwort

1

Anmeldung Aktionsmethode kehrt eine Ansicht, die die Anmeldung Aktionsmethode ist inkl. Grundsätzlich rufst du dich immer wieder an.

Sie müssen wahrscheinlich nur mit einer anderen Aktionsmethode sein: @Html.Action("LoginForm","Account")

+0

es funktioniert nicht !!! Ich ändere die fistrt Methode mit Anthere Name –