コード例 #1
0
        private async Task<ActionResult> RedirectToLocal(string returnUrl, ApplicationUser user)
        {
            if (string.IsNullOrEmpty(returnUrl))
            {
                var isAdmin = await _membershipService.IsInRole(user, ApplicationRole.Admin);
                var isPatient = await _membershipService.IsInRole(user, ApplicationRole.Patient);

                if (isAdmin)
                    return RedirectToAction("Index", "Admin");

                if (isPatient)
                    return RedirectToAction("Dashboard", "PatientDashboard");

                var isSurgCoord = await _membershipService.IsInRole(user, ApplicationRole.SurgicalCoordinator);

                return isSurgCoord ? RedirectToAction("Index", "Patient") : RedirectToAction("Inbox", "Message");
            }

            if (Url.IsLocalUrl(returnUrl))
                return Redirect(returnUrl);
            
            return RedirectToAction("Login");
        }
コード例 #2
0
 private async Task SignInAsync(ApplicationUser user, bool isPersistent)
 {
     AuthenticationManager.SignOut(DefaultAuthenticationTypes.ExternalCookie);
     var identity = await _membershipService.CreateIdentityAsync(user, DefaultAuthenticationTypes.ApplicationCookie);
     AuthenticationManager.SignIn(new AuthenticationProperties() { IsPersistent = isPersistent }, identity);
 }