public ActionResult LogOff() { GaptDbContext _context = new GaptDbContext(); var userId = User.Identity.GetUserId(); var unlocked = _context.Proposals.Where(m => m.IsInEdit == true && m.UserEditing == userId).ToList(); foreach (Proposal p in unlocked) { p.Unlock(); } _context.SaveChanges(); AuthenticationManager.SignOut(DefaultAuthenticationTypes.ApplicationCookie); return(RedirectToAction("Index", "Home")); }
public async Task <ActionResult> ExternalLoginConfirmation(ExternalLoginConfirmationViewModel model, string returnUrl) { if (User.Identity.IsAuthenticated) { return(RedirectToAction("Index", "Manage")); } GaptDbContext db = new GaptDbContext(); ApplicationDbContext adb = new ApplicationDbContext(); var whitelistRecord = db.Whitelists.SingleOrDefault(m => m.Email == model.Email); if (whitelistRecord == null) { return(RedirectToAction("Login")); } if (ModelState.IsValid) { // Get the information about the user from the external login provider var info = await AuthenticationManager.GetExternalLoginInfoAsync(); if (info == null) { return(View("ExternalLoginFailure")); } var user = new ApplicationUser { UserName = model.Email, Email = model.Email }; var result = await UserManager.CreateAsync(user); if (result.Succeeded) { result = await UserManager.AddLoginAsync(user.Id, info.Login); if (result.Succeeded) { adb.Database.ExecuteSqlCommand("Insert into dbo.AspNetUserRoles(UserId, RoleId) values({0}, {1})", user.Id, whitelistRecord.PrimaryRoleId); await SignInManager.SignInAsync(user, isPersistent : false, rememberBrowser : false); return(RedirectToLocal(returnUrl)); } } AddErrors(result); } ViewBag.ReturnUrl = returnUrl; return(View(model)); }
public async Task <ActionResult> ExternalLoginCallback(string returnUrl) { var loginInfo = await AuthenticationManager.GetExternalLoginInfoAsync(); if (loginInfo == null) { return(RedirectToAction("Login")); } if (!loginInfo.Email.EndsWith("@um.edu.mt") || !loginInfo.Login.LoginProvider.Equals("Google")) { //if the email is not a UoM account, go back to login return(RedirectToAction("Login")); } GaptDbContext db = new GaptDbContext(); var whitelistRecord = db.Whitelists.SingleOrDefault(m => m.Email == loginInfo.Email); if (whitelistRecord == null) { return(RedirectToAction("Login")); } // Sign in the user with this external login provider if the user already has a login var result = await SignInManager.ExternalSignInAsync(loginInfo, isPersistent : false); switch (result) { case SignInStatus.Success: return(RedirectToLocal(returnUrl)); case SignInStatus.LockedOut: return(View("Lockout")); case SignInStatus.RequiresVerification: return(RedirectToAction("SendCode", new { ReturnUrl = returnUrl, RememberMe = false })); case SignInStatus.Failure: default: // If the user does not have an account, then prompt the user to create an account ViewBag.ReturnUrl = returnUrl; ViewBag.LoginProvider = loginInfo.Login.LoginProvider; return(View("ExternalLoginConfirmation", new ExternalLoginConfirmationViewModel { Email = loginInfo.Email })); } }
public async Task <ActionResult> Register(RegisterViewModel model) { GaptDbContext db = new GaptDbContext(); ApplicationDbContext adb = new ApplicationDbContext(); var whitelistRecord = db.Whitelists.SingleOrDefault(m => m.Email == model.Email); if (whitelistRecord == null) { return(RedirectToAction("Login")); } if (model.Email.EndsWith("@um.edu.mt")) { //if the email is a UoM account, go back to login; since only external reviewer can register return(RedirectToAction("Login")); } if (ModelState.IsValid) { var user = new ApplicationUser { UserName = model.Email, Email = model.Email }; var result = await UserManager.CreateAsync(user, model.Password); if (result.Succeeded) { adb.Database.ExecuteSqlCommand("Insert into dbo.AspNetUserRoles(UserId, RoleId) values({0}, {1})", user.Id, whitelistRecord.PrimaryRoleId); await SignInManager.SignInAsync(user, isPersistent : false, rememberBrowser : false); // For more information on how to enable account confirmation and password reset please visit https://go.microsoft.com/fwlink/?LinkID=320771 // Send an email with this link // string code = await UserManager.GenerateEmailConfirmationTokenAsync(user.Id); // var callbackUrl = Url.Action("ConfirmEmail", "Account", new { userId = user.Id, code = code }, protocol: Request.Url.Scheme); // await UserManager.SendEmailAsync(user.Id, "Confirm your account", "Please confirm your account by clicking <a href=\"" + callbackUrl + "\">here</a>"); return(RedirectToAction("Index", "Home")); } AddErrors(result); } // If we got this far, something failed, redisplay form return(View(model)); }
public async Task <ActionResult> Login(LoginViewModel model, string returnUrl) { if (!ModelState.IsValid) { return(View(model)); } GaptDbContext db = new GaptDbContext(); var whitelistRecord = db.Whitelists.SingleOrDefault(m => m.Email == model.Email); if (whitelistRecord == null) { return(RedirectToAction("Login")); } // This doesn't count login failures towards account lockout // To enable password failures to trigger account lockout, change to shouldLockout: true var result = await SignInManager.PasswordSignInAsync(model.Email, model.Password, model.RememberMe, shouldLockout : false); switch (result) { case SignInStatus.Success: Session["userId"] = "abc"; return(RedirectToLocal(returnUrl)); case SignInStatus.LockedOut: return(View("Lockout")); case SignInStatus.RequiresVerification: return(RedirectToAction("SendCode", new { ReturnUrl = returnUrl, RememberMe = model.RememberMe })); case SignInStatus.Failure: default: ModelState.AddModelError("", "Invalid login attempt."); return(View(model)); } }
public SenateDecisionController() { _context = new GaptDbContext(); }
public RationaleController() { _context = new GaptDbContext(); }
public EndorsementCollabController() { _context = new GaptDbContext(); }
public UnitController() { _context = new GaptDbContext(); }
public ProposalController() { _context = new GaptDbContext(); }
public PvcApprovalController() { _context = new GaptDbContext(); }
public IncomeExpenditureController() { _context = new GaptDbContext(); }
public DemandController() { _context = new GaptDbContext(); }
public ProgrammeRationaleController() { _context = new GaptDbContext(); }
public CouncilDecisionController() { _context = new GaptDbContext(); }
public ExternalReviewController() { _context = new GaptDbContext(); }
public ProgrammeStudyController() { _context = new GaptDbContext(); }
public ReviewerController() { _context = new GaptDbContext(); }
public StatementServController() { _context = new GaptDbContext(); }
public TentativePsController() { _context = new GaptDbContext(); }
public RecommendationFicsController() { _context = new GaptDbContext(); }
public InPrincipleController() { _context = new GaptDbContext(); }
public YearController() { _context = new GaptDbContext(); }
public GeneralController() { _context = new GaptDbContext(); }
public CommentController() { _context = new GaptDbContext(); }