Ejemplo n.º 1
0
        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"));
        }
Ejemplo n.º 2
0
        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));
        }
Ejemplo n.º 3
0
        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
                }));
            }
        }
Ejemplo n.º 4
0
        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));
        }
Ejemplo n.º 5
0
        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));
            }
        }
Ejemplo n.º 6
0
 public SenateDecisionController()
 {
     _context = new GaptDbContext();
 }
Ejemplo n.º 7
0
 public RationaleController()
 {
     _context = new GaptDbContext();
 }
 public EndorsementCollabController()
 {
     _context = new GaptDbContext();
 }
Ejemplo n.º 9
0
 public UnitController()
 {
     _context = new GaptDbContext();
 }
Ejemplo n.º 10
0
 public ProposalController()
 {
     _context = new GaptDbContext();
 }
Ejemplo n.º 11
0
 public PvcApprovalController()
 {
     _context = new GaptDbContext();
 }
Ejemplo n.º 12
0
 public IncomeExpenditureController()
 {
     _context = new GaptDbContext();
 }
Ejemplo n.º 13
0
 public DemandController()
 {
     _context = new GaptDbContext();
 }
 public ProgrammeRationaleController()
 {
     _context = new GaptDbContext();
 }
Ejemplo n.º 15
0
 public CouncilDecisionController()
 {
     _context = new GaptDbContext();
 }
Ejemplo n.º 16
0
 public ExternalReviewController()
 {
     _context = new GaptDbContext();
 }
Ejemplo n.º 17
0
 public ProgrammeStudyController()
 {
     _context = new GaptDbContext();
 }
Ejemplo n.º 18
0
 public ReviewerController()
 {
     _context = new GaptDbContext();
 }
Ejemplo n.º 19
0
 public StatementServController()
 {
     _context = new GaptDbContext();
 }
Ejemplo n.º 20
0
 public TentativePsController()
 {
     _context = new GaptDbContext();
 }
 public RecommendationFicsController()
 {
     _context = new GaptDbContext();
 }
Ejemplo n.º 22
0
 public InPrincipleController()
 {
     _context = new GaptDbContext();
 }
Ejemplo n.º 23
0
 public YearController()
 {
     _context = new GaptDbContext();
 }
Ejemplo n.º 24
0
 public GeneralController()
 {
     _context = new GaptDbContext();
 }
Ejemplo n.º 25
0
 public CommentController()
 {
     _context = new GaptDbContext();
 }