After successfull login, I wanted to check the loggedin user, check if the user is of type 1 (1=admin, just as example here), and if yes, redirect him to a specific section, e.g. "settings". So I wrote a class as suggested in the thread I mentioned above, as follows:
public class CustomUsersMembershipProvider : umbraco.providers.UsersMembershipProvider { public override bool ValidateUser(string username, string password) { var success = base.ValidateUser(username, password);
if (success) { User u = User.GetAllByLoginName(username, false).FirstOrDefault();
if ((u.UserType.Id == 1)) { //redirect the user to the Custom Section string redirect = "http://" + HttpContext.Current.Request.Url.Authority + "/umbraco/umbraco.aspx#settings";
After you login, instead of arriving, as usual, to the "Content" Section, you will arrive to the "Settings" section. That would be fine for me, but our customer wants the users of a certain type to be automatically redirected to a specific section after login... so ideally this would be done in th code behind...
I also tried, instead of Response.Redirect, to use:
At that point in the code, your user isn't been authenticated in the back-office... they've had their username/password validated, but no cookies have been set (in Umbraco core code) yet.
With your previous thread, I thought you only wanted to set a Session object/value.
Another way you could tackle this... if you've got the time & energy to do it, is take a look at the source-code for my unreleased package: BackOffice Power Scripts:
By disecting the code, you'll find that I use a HttpModule to inject CSS/JavaScript directly into the back-office. There is also a way to inject user-controls too.
It might be useful, it might not... but worth exploring.
after backend login - redirect to a specific section instead of default "content"
Hi, please refear to this thread about subscribing to the backend login event.
After successfull login, I wanted to check the loggedin user, check if the user is of type 1 (1=admin, just as example here), and if yes, redirect him to a specific section, e.g. "settings". So I wrote a class as suggested in the thread I mentioned above, as follows:
But this doesn't work. Asap I login I'm redirected back to the login, so obveiously I'm doing something wrong.
To give you an idea of the result I'd like to achieve, try to login to umbraco by using this url:
After you login, instead of arriving, as usual, to the "Content" Section, you will arrive to the "Settings" section. That would be fine for me, but our customer wants the users of a certain type to be automatically redirected to a specific section after login... so ideally this would be done in th code behind...
I also tried, instead of Response.Redirect, to use:
But it didn't work (tried also to do a alert('hello world'); instead of window.location... but I didn't get any javascript alert window...
Any ideas on how to proceed? Would be appreciated...
cheers --firepol
Hi firepol,
At that point in the code, your user isn't been authenticated in the back-office... they've had their username/password validated, but no cookies have been set (in Umbraco core code) yet.
With your previous thread, I thought you only wanted to set a Session object/value.
Another way you could tackle this... if you've got the time & energy to do it, is take a look at the source-code for my unreleased package: BackOffice Power Scripts:
https://bitbucket.org/vertino/backoffice-power-scripts-for-umbraco/overview
By disecting the code, you'll find that I use a HttpModule to inject CSS/JavaScript directly into the back-office. There is also a way to inject user-controls too.
It might be useful, it might not... but worth exploring.
Cheers, Lee.
is working on a reply...
This forum is in read-only mode while we transition to the new forum.
You can continue this topic on the new forum by tapping the "Continue discussion" link below.