Advertisement
Guest User

Untitled

a guest
May 29th, 2015
220
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 1.59 KB | None | 0 0
  1. //
  2.         // POST: /Account/Login
  3.         [HttpPost]
  4.         [AllowAnonymous]
  5.         [ValidateAntiForgeryToken]
  6.         public async Task<ActionResult> Login(LoginViewModel model, string returnUrl, string city)
  7.         {
  8.             if (ModelState.IsValid)
  9.             {
  10.                 ICoreManager cm = new CoreManager();
  11.                 Platform p = cm.GetPlatformByName(city); //Het actieve platform ophalen
  12.                 int pId = p.PlatformID;
  13.                 if (model.Email.Equals("TreeCompany@JPP.be"))
  14.                 {
  15.                     pId = 1;
  16.                 }
  17.                
  18.                 var user = await UserManager.FindAsync(model.Email+pId, model.Password); //User ophalen aan de hand van unieke UserName (combinatie email+platformId, email alleen is niet voldoende daar eenzelfde emailadres op verschillende platformen kan gebruikt worden)
  19.                 if (user != null) //Er is een user gevonden
  20.                 {            
  21.                     if (user.IsBlocked) //De gebruiker werd geblokkeerd
  22.                     {
  23.                         ModelState.AddModelError("", "Jouw account is geblokkeerd voor dit platform.");
  24.                         return View(model);
  25.                     }
  26.                     await SignInAsync(user, model.RememberMe);
  27.                     return RedirectToLocal(returnUrl);
  28.                 }
  29.                 else
  30.                 {
  31.                     ModelState.AddModelError("", "Combinatie van emailadres en paswoord niet correct voor dit platform.");
  32.                 }
  33.             }
  34.             return View(model);
  35.         }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement