I am trying to figure out how to redirect members to different urls based on which member group a member has when logging in.
I have my LoginController where I want to do something like this:
public class LoginController : SurfaceController
{
public ActionResult Login(LoginModel model)
{
if (!ModelState.IsValid)
return CurrentUmbracoPage();
if (Members.Login(model.Email, model.Password))
{
var member = Members.GetCurrentMember();
if (member is part of group "Teacher")
return Redirect("/app");
if (member is part of group "Student")
return Redirect("/playground");
else
return Redirect("/");
}
ModelState.AddModelError("", "Invalid Login");
return CurrentUmbracoPage();
}
}
When I try to GetCurrentMember() it returns null and I can't find any recent posts about how to check if a member is part of a group.
var roles = Services.MemberService.GetAllRoles(member.Id);
if (roles.Contains("Teacher"))
return Redirect("/app");
if (roles.Contains("Student"))
return Redirect("/playground");
else
return Redirect("/");
Redirect members based on member group
Hi,
I am trying to figure out how to redirect members to different urls based on which member group a member has when logging in.
I have my LoginController where I want to do something like this:
When I try to GetCurrentMember() it returns null and I can't find any recent posts about how to check if a member is part of a group.
Thanks,
Jonathan
Hi Jonathan
It should work for you:
Thank you for quick answer! It works like a charm!
is working on a reply...