Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- //
- // POST: /Account/Login
- [HttpPost]
- [AllowAnonymous]
- [ValidateAntiForgeryToken]
- public async Task<ActionResult> Login(LoginViewModel model, string returnUrl, string city)
- {
- if (ModelState.IsValid)
- {
- ICoreManager cm = new CoreManager();
- Platform p = cm.GetPlatformByName(city); //Het actieve platform ophalen
- int pId = p.PlatformID;
- if (model.Email.Equals("TreeCompany@JPP.be"))
- {
- pId = 1;
- }
- 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)
- if (user != null) //Er is een user gevonden
- {
- if (user.IsBlocked) //De gebruiker werd geblokkeerd
- {
- ModelState.AddModelError("", "Jouw account is geblokkeerd voor dit platform.");
- return View(model);
- }
- await SignInAsync(user, model.RememberMe);
- return RedirectToLocal(returnUrl);
- }
- else
- {
- ModelState.AddModelError("", "Combinatie van emailadres en paswoord niet correct voor dit platform.");
- }
- }
- return View(model);
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement