Press Ctrl / CMD + C to copy this to your clipboard.
This post will be reported to the moderators as potential spam to be looked at
Hi Our,
I have a little problem that i hope you can help with :)
I'm having an Custom Login Controller, which redirects to different pages if the user role list contains specific roles :)
BUT sometimes the Members.GetCurrentUserRoles is empty, and the Members.CurrentUserName is empty, like it's not getting the logged in user..
This is my code :)
if (ModelState.IsValid == false) { return CurrentUmbracoPage(); } if (Members.Login(model.Username, model.Password) == false) { //don't add a field level error, just model level ModelState.AddModelError("loginModel", "Invalid username or password"); return CurrentUmbracoPage(); } TempData["LoginSuccess"] = true; IEnumerable<string> userRolesIEnumerable = Members.GetCurrentUserRoles(); List<string> userRolesList = new List<string>(); userRolesList.AddRange(userRolesIEnumerable); if (userRolesList.Contains("DJ") && userRolesList.Contains("BNV")) { return RedirectToCurrentUmbracoPage("?allow-user-selection=1"); } else if (userRolesList.Contains("DJ") && !userRolesList.Contains("BNV")) { return RedirectToUmbracoPage(1078); } else if (!userRolesList.Contains("DJ") && userRolesList.Contains("BNV")) { return RedirectToUmbracoPage(1079); }
Hey,
You can use the static class Roles
Roles.GetRolesForUser(model.Username)
Or:
Services.MemberService.GetAllRoles(model.Username)
Members.GetUserRoles(model.Username)
is working on a reply...
Write your reply to:
Upload image
Image will be uploaded when post is submitted
Custom Login Controller - Members
Hi Our,
I have a little problem that i hope you can help with :)
I'm having an Custom Login Controller, which redirects to different pages if the user role list contains specific roles :)
BUT sometimes the Members.GetCurrentUserRoles is empty, and the Members.CurrentUserName is empty, like it's not getting the logged in user..
This is my code :)
Hey,
You can use the static class Roles
Or:
Or:
is working on a reply...