/// <summary> /// Authorize User To Domains /// </summary> /// <param name="data">AuthenticateUserResponse</param> /// <param name="role">Role</param> /// <param name="returnUrl">Return Url</param> /// <returns>ActionResult</returns> protected virtual ActionResult AuthorizeUserToDomains(AuthenticateUserResponse data, string role, string returnUrl, bool rememberMe = true) { string userData = String.Empty; if (data.IsAuthenticated) { var domainRoles = UsersService.GetDomainRoleForUser(new GetDomainRoleForUserRequest { User = data.User }); userData = FlowTasksIdentity.SetUserData(data.User, new AuthorizeData { Domains = domainRoles.DomainRole.Domanis, Roles = domainRoles.DomainRole.Roles }); } AddAuthCookie(data.User, userData, rememberMe); // PG. Changes for New UI return(Json(true)); // END if (data.IsAuthenticated) { return(RedirectToReturnUrl(returnUrl)); } return(RedirectToAction("Index", "Home")); }
protected void Application_AuthenticateRequest(Object sender, EventArgs e) { HttpCookie authCookie = Request.Cookies[ FormsAuthentication.FormsCookieName]; if (authCookie != null) { //Extract the forms authentication cookie FormsAuthenticationTicket authTicket = FormsAuthentication.Decrypt(authCookie.Value); FlowTasksIdentity id = new FlowTasksIdentity(authTicket.Name, authTicket.UserData); FlowTasksPrincipal user = new FlowTasksPrincipal(id); Context.User = user; /* * When you are going to use the information later, you can access your custom principal as follows. * (CustomPrincipal)this.User * or * (CustomPrincipal)this.Context.User */ } }