I am setting up a custom login section for a company here in town and they need their distributors to be able to login and see special data that is set aside for them. This is the only purpose of this site (partners.xxxx.com). I know I have to set up the member group as distributors and the member type as distributors and then set up the members. I know how to do all of this and how to create the login field and everything, the only thing that I am needing help on is the structuring.
I know the home page will have to be accessible to all as it will contain the login field so here is what I am thinking.
Content
--Index (contains login)
----Index for company A
------sub for company A
------sub for company A
------sub for company A
----Index for company B
------sub for company B
------sub for company B
------sub for company B
------sub for company B
so on and so forth. There are going to be around 5 distributors. Now by doing it this way I can reuse templates and most XLST. My only question is how can I set it up so that when customer A signs in they are directed to Index for Company A and can never access anything that is outside of company A and its sub pages?
add a property to the member which is content picker. for each member set there home page. Update your login code so that after successful log in it gets members redirect value then redirect.
[quote=imayat12]add a property to the member which is content picker. for each member set there home page. Update your login code so that after successful log in it gets members redirect value then redirect.
Regards
Ismial[/quote]
Great idea, how do I add a content picker to a member though? also care to walk me through a rough code example of how it gets the members redirect value and redirects them?
Under the member type section for your given member type (assuming its type distributors) add the property there just like you would for content type. with regards to getting the member if you take a look at the code for member controls on codeplex theres plenty there about accessing members.
Be aware though to check login credentials for all 'protected' pages, as you don't want to have a logged in distributor to be able to browse other distributor's pages... Might want to look into setting public access as well!
Be aware though to check login credentials for all 'protected' pages, as you don't want to have a logged in distributor to be able to browse other distributor's pages... Might want to look into setting public access as well!
Regards,
/Dirk
[/quote]
Yes that was my next adventure once I get this done is having only company a navigate inside their section and never be able to access company b. That will be my next step and I am sure my next bundle of questions o:)
Ok so I have it set up now like this:
content tree:
Home (login page)
--Contact Page (open to everyone)
--Company A (secure)
----Company A Documents (secure)
--Company B (secure)
----Company B Documents (secure)
I have set up my members section and I can log in and out fine, I have set up a redirect for the member type to redirect the logged in user to the correct section of the site, however I can not seem to figure out how to put it into the code when the user logs in. I am using this login code...
Welcome
I am not sure what to do with that code to redirect the user once the login in complete to the content picker that is set when the member is created. Any ideas would be greatly appreciated. I have looked through the codeplex and could not find anything that can help.
It's dead easy, just subscribe to the LoggedIn event of the asp:Login control, get the member using GetMemberFromLogin(Login1.Username) and redirect using NiceUrl(id). Id in this case is the value of the property on the member (of type content picker)
It's dead easy, just subscribe to the LoggedIn event of the asp:Login control, get the member using GetMemberFromLogin(Login1.Username) and redirect using NiceUrl(id). Id in this case is the value of the property on the member (of type content picker)
Cheers,
/Dirk
[/quote]
Ok I am using the loggedIn Control here:
Welcome
To get the user name and the logout link, to do the redirect do I have to use xslt and a macro or can I do it in the code? I know in theory I can use DestinationPageUrl=”link” (I think that is the correct syntax) but how do I get the value of the content picker?
EDIT:
I can not find anything on google that does this: GetMemberFromLogin(Login1.Username) I do not know how to use it. Also I understand the destinationpageurl but I dont know how to get it from the node(id), is there some inline xslt I can write or what?
Ok after more tinkering I am pretty sure that the redirect has to go in here:
now all I need to do is figure out how to get the name and how to get the id of the redirect. I have tried to find a way to do this:GetMemberFromLogin(Login1.Username) by searching google and it is not returning anything, possibly a syntax issue? If anyone can help me out it would be greatly appreciated
I am getting an error now with that code:
Compilation Error
Description: An error occurred during the compilation of a resource required to service this request. Please review the following specific error details and modify your source code appropriately.
Compiler Error Message: CS0246: The type or namespace name 'Member' could not be found (are you missing a using directive or an assembly reference?)
Still getting errors, both ways gives me an error:
Compilation Error
Description: An error occurred during the compilation of a resource required to service this request. Please review the following specific error details and modify your source code appropriately.
Compiler Error Message: CS0103: The name 'Member' does not exist in the current context
Source Error:
Line 21:
Line 22: private void Login1LoggedIn(object sender, EventArgs e) {
Line 23: umbraco.cms.businesslogic.member.Member member = Member.GetMemberFromLoginNameAndPassword(Login1.UserName, Login1.Password);
Line 24:
Line 25: if ((member != null) && (member.Id > 0)) {
and
Compilation Error
Description: An error occurred during the compilation of a resource required to service this request. Please review the following specific error details and modify your source code appropriately.
Compiler Error Message: CS1519: Invalid token 'using' in class, struct, or interface member declaration
OK I am debugging and have found where the error occurs...if I run this code and try to login I get thrown to notin.aspx which means that the if statment (if((member !=null) && (member.Id > 0)) ) is not getting infiltrated. Any ideas on why?
EDIT:
The problem lies in the fact that for some reason the member is coming through as null, thus not getting into the if statement. Why would this be happening? I am so close, please help if you understand.
However I am a bit curious about how you avoid that people from company a can see the site for company b.
I am working on a project, where the structure is similliar to yours. Currently all logged in members can access the sites of others. And that is of course not the intention :)
On my member-page I have a field, that gets the member id so I am thinking that I should just make a comparisson between the value from the field and the the member id.
[quote=Jasko]Glad to hear that you got it working :)
However I am a bit curious about how you avoid that people from company a can see the site for company b.
I am working on a project, where the structure is similliar to yours. Currently all logged in members can access the sites of others. And that is of course not the intention :)
On my member-page I have a field, that gets the member id so I am thinking that I should just make a comparisson between the value from the field and the the member id.
Do you have any suggestions about this?[/quote]
Yes that is a concern I have as well and I am not sure yet how I am going to concur it. If worse comes to worse I was thinking I could ditch the sitemap that way the users do not know that there are other sections of the site. Since mine is only about 5 distributors across the US, I think I may be able to get away with this but I am not sure. If anyone has any ideas on how to do this I would be very interested.
Public access should be able to cover this. If all members of site A are grouped into one group SiteA, then you could protect that site so only member of site A are able to see it, other's will get redirected to login/no access page based.
Alternatively, one could use http handlers to handle security.
Public access should be able to cover this. If all members of site A are grouped into one group SiteA, then you could protect that site so only member of site A are able to see it, other's will get redirected to login/no access page based.
Alternatively, one could use http handlers to handle security.
Regards,
/Dirk
[/quote]
Ahh so I could have a member type distributors, and member group split out between the distributors (company1, company2, company3) and then have the users be members of their company. Then the company page should be only accessible to members of that company. Is that right?
I can see the logic by handling the problem using public access in Evans case.
My case is a bit different since there are only one membertype, namely "Deltager". In my case it would not make sense, to make a new group for each member that is created.
However I am interestred in hearing more about the http handler approach?
Right now, in my project, if users are not logged in then they just get a login form.
[quote]I've done something similar by disabling access to another forum app if member was not logged on.[/quote]
Therefore I am wondering if you by this mean that your code sample does the same thing? Or does it make sure that logged in members only can access their own node and not other members nodes?
Member = GetCurrentMember()
Node = nodeFactory.Node.GetCurrent()
and check relation between the two. Of course, you'll need to set a property either on member or on node to refer to the other (or make it a bidirectional relation).
For the node being requested, check whether the current logged on member is the 'owner' (using a property) and if not, redirect to owner's home page.
Might want to contact me offline for a code sample... we'll sort it out and report in forum.
User login with a redirect
I am setting up a custom login section for a company here in town and they need their distributors to be able to login and see special data that is set aside for them. This is the only purpose of this site (partners.xxxx.com). I know I have to set up the member group as distributors and the member type as distributors and then set up the members. I know how to do all of this and how to create the login field and everything, the only thing that I am needing help on is the structuring.
I know the home page will have to be accessible to all as it will contain the login field so here is what I am thinking.
Content
--Index (contains login)
----Index for company A
------sub for company A
------sub for company A
------sub for company A
----Index for company B
------sub for company B
------sub for company B
------sub for company B
------sub for company B
so on and so forth. There are going to be around 5 distributors. Now by doing it this way I can reuse templates and most XLST. My only question is how can I set it up so that when customer A signs in they are directed to Index for Company A and can never access anything that is outside of company A and its sub pages?
add a property to the member which is content picker. for each member set there home page. Update your login code so that after successful log in it gets members redirect value then redirect.
Regards
Ismial
[quote=imayat12]add a property to the member which is content picker. for each member set there home page. Update your login code so that after successful log in it gets members redirect value then redirect.
Regards
Ismial[/quote]
Great idea, how do I add a content picker to a member though? also care to walk me through a rough code example of how it gets the members redirect value and redirects them?
Under the member type section for your given member type (assuming its type distributors) add the property there just like you would for content type. with regards to getting the member if you take a look at the code for member controls on codeplex theres plenty there about accessing members.
Regards
Ismail
Hi,
Be aware though to check login credentials for all 'protected' pages, as you don't want to have a logged in distributor to be able to browse other distributor's pages... Might want to look into setting public access as well!
Regards,
/Dirk
[quote=Dirk]Hi,
Be aware though to check login credentials for all 'protected' pages, as you don't want to have a logged in distributor to be able to browse other distributor's pages... Might want to look into setting public access as well!
Regards,
/Dirk
[/quote]
Yes that was my next adventure once I get this done is having only company a navigate inside their section and never be able to access company b. That will be my next step and I am sure my next bundle of questions o:)
Ok so I have it set up now like this:
content tree:
Home (login page)
--Contact Page (open to everyone)
--Company A (secure)
----Company A Documents (secure)
--Company B (secure)
----Company B Documents (secure)
I have set up my members section and I can log in and out fine, I have set up a redirect for the member type to redirect the logged in user to the correct section of the site, however I can not seem to figure out how to put it into the code when the user logs in. I am using this login code...
Welcome
I am not sure what to do with that code to redirect the user once the login in complete to the content picker that is set when the member is created. Any ideas would be greatly appreciated. I have looked through the codeplex and could not find anything that can help.
Hi,
It's dead easy, just subscribe to the LoggedIn event of the asp:Login control, get the member using GetMemberFromLogin(Login1.Username) and redirect using NiceUrl(id). Id in this case is the value of the property on the member (of type content picker)
Cheers,
/Dirk
[quote=Dirk]Hi,
It's dead easy, just subscribe to the LoggedIn event of the asp:Login control, get the member using GetMemberFromLogin(Login1.Username) and redirect using NiceUrl(id). Id in this case is the value of the property on the member (of type content picker)
Cheers,
/Dirk
[/quote]
Ok I am using the loggedIn Control here:
Welcome
To get the user name and the logout link, to do the redirect do I have to use xslt and a macro or can I do it in the code? I know in theory I can use DestinationPageUrl=”link” (I think that is the correct syntax) but how do I get the value of the content picker?
EDIT:
I can not find anything on google that does this: GetMemberFromLogin(Login1.Username) I do not know how to use it. Also I understand the destinationpageurl but I dont know how to get it from the node(id), is there some inline xslt I can write or what?
Ok after more tinkering I am pretty sure that the redirect has to go in here:
now all I need to do is figure out how to get the name and how to get the id of the redirect. I have tried to find a way to do this:GetMemberFromLogin(Login1.Username) by searching google and it is not returning anything, possibly a syntax issue? If anyone can help me out it would be greatly appreciated
Me again,
Of course you won't find anything on Login1.UserName as I was already using the Id of your control...
[code]private void Login1_LoggedIn(object sender, EventArgs e) {
Member member = Member.GetMemberFromLoginNameAndPassword(Login1.UserName, Login1.Password);
if ((member != null) && (member.Id > 0)) {
try {
int nodeId = int.Parse(member.getProperty("RedirectPropertyAlias").Value);
if (nodeId > 0)
Response.Redirect(umbraco.library.NiceUrl(nodeId), true);
} catch {
}
Response.Redirect("/");
}
}[/code]
I'll leave the rest as an exercise.
Regards,
/Dirk
[quote=Dirk]Me again,
Of course you won't find anything on Login1.UserName as I was already using the Id of your control...
[code]private void Login1_LoggedIn(object sender, EventArgs e) {
Member member = Member.GetMemberFromLoginNameAndPassword(Login1.UserName, Login1.Password);
if ((member != null) && (member.Id > 0)) {
try {
int nodeId = int.Parse(member.getProperty("RedirectPropertyAlias").Value);
if (nodeId > 0)
Response.Redirect(umbraco.library.NiceUrl(nodeId), true);
} catch {
}
Response.Redirect("/");
}
}[/code]
I'll leave the rest as an exercise.
Regards,
/Dirk[/quote]
excuse my ignorance but where do I put this code since I do not have a code behind or anything?
Hi,
If you're using those controls directly into the template, you'll need to add:
[code]
[/code]
Just as in Morten's excellent blog post (http://www.mortenbock.dk/thoughts-about-umbraco-as-a-modular-cms-121.htm)
Cheers,
/Dirk
[quote=Dirk]Hi,
If you're using those controls directly into the template, you'll need to add:
[code]
[/code]
Just as in Morten's excellent blog post (http://www.mortenbock.dk/thoughts-about-umbraco-as-a-modular-cms-121.htm)
Cheers,
/Dirk
[/quote]
Great, thanks so much for your help. I really appreciate it.
Evan
I am getting an error now with that code:
Compilation Error
Description: An error occurred during the compilation of a resource required to service this request. Please review the following specific error details and modify your source code appropriately.
Compiler Error Message: CS0246: The type or namespace name 'Member' could not be found (are you missing a using directive or an assembly reference?)
Source Error:
Line 20:
Hi,
In that case, fully qualify Member class as in:
[code]umbraco.cms.businesslogic.member.Member member = ...[/code]
or
[code]using umbraco.cms.businesslogic.member;
private void Login1_LoggedIn() {...}[/code]
Regards,
/Dirk
Still getting errors, both ways gives me an error:
Compilation Error
Description: An error occurred during the compilation of a resource required to service this request. Please review the following specific error details and modify your source code appropriately.
Compiler Error Message: CS0103: The name 'Member' does not exist in the current context
Source Error:
Line 21:
Line 22: private void Login1LoggedIn(object sender, EventArgs e) {
Line 23: umbraco.cms.businesslogic.member.Member member = Member.GetMemberFromLoginNameAndPassword(Login1.UserName, Login1.Password);
Line 24:
Line 25: if ((member != null) && (member.Id > 0)) {
and
Compilation Error
Description: An error occurred during the compilation of a resource required to service this request. Please review the following specific error details and modify your source code appropriately.
Compiler Error Message: CS1519: Invalid token 'using' in class, struct, or interface member declaration
Source Error:
Line 19:
Line 20:
Hi ewatkins,
Just replied to your mail. Let me know if it works out well.
Cheers,
/Dirk
Got further but I am now getting an error that Login1 does not exist in the current context. Here is my code.
<script runat="server"><br /> private void Login1_LoggedIn(object sender, EventArgs e) {<br /> umbraco.cms.businesslogic.member.Member member = Member.GetMemberFromLoginNameAndPassword(Login1.UserName, Login1.Password);<br /> <br /> if ((member != null) && (member.Id > 0)) {<br /> try {<br /> int nodeId = int.Parse(member.getProperty("redirect").Value);<br /> <br /> if (nodeId > 0)<br /> Response.Redirect(umbraco.library.NiceUrl(nodeId), true);<br /> <br /> } catch {<br /> }<br /> <br /> Response.Redirect("/");<br /> }<br /> }<br /> <br /> <br /> </script>Hi
I had some similar trouble yesterday.
What happens if you try to write the following?
[code]
Property p = member.getProperty("redirect");
string redirectString = Convert.ToString(p.value);
int nodeId = int.Parse(redirectString);
[/code]
It is somewhat working, the redirect is not going through correctly yet. Here is my code thus far (many thanks to Dirk):
<script runat="server"><br /> <br /> private void Login1_LoggedIn(object sender, EventArgs e) {<br /> Login ctrl = (Login) UmbracoLoginView.FindControl("Login1");<br /> Member member =<br /> Member.GetMemberFromLoginNameAndPassword(ctrl.UserName, ctrl.Password);<br /> <br /> if ((member != null) && (member.Id > 0)) {<br /> try {<br /> int nodeId =<br /> int.Parse(member.getProperty("redirect").Value.ToString());<br /> <br /> if (nodeId > 0)<br /> Response.Redirect(umbraco.library.NiceUrl(nodeId),<br /> true);<br /> <br /> } catch {<br /> }<br /> <br /> Response.Redirect("/");<br /> }<br /> }<br /> <br /> </script>OK I am debugging and have found where the error occurs...if I run this code and try to login I get thrown to notin.aspx which means that the if statment (if((member !=null) && (member.Id > 0)) ) is not getting infiltrated. Any ideas on why?
Code:
<script runat="server"><br /> <br /> private void Login1_LoggedIn(object sender, EventArgs e) {<br /> Login ctrl = (Login) UmbracoLoginView.FindControl("Login1");<br /> Member member = Member.GetMemberFromLoginNameAndPassword(ctrl.UserName, ctrl.Password);<br /> <br /> if ((member != null) && (member.Id > 0)) {<br /> <br /> try {<br /> int nodeId = int.Parse(member.getProperty("redirect").Value.ToString());<br /> if (nodeId > 0)<br /> Response.Redirect(umbraco.library.NiceUrl(nodeId), true);<br /> <br /> } <br /> catch {<br /> }<br /> <br /> Response.Redirect("/error.aspx");<br /> }Response.Redirect("/notin.aspx");<br /> }<br /> <br /> </script>EDIT:
The problem lies in the fact that for some reason the member is coming through as null, thus not getting into the if statement. Why would this be happening? I am so close, please help if you understand.
any ideas I am so close all I need is to get the member to not be null when it is passed through...
FIGURED IT OUT!!! with the help of Dirk we figured it out, here is the correct code:
<script runat="server"><br /> private void Login1_LoggedIn(object sender, EventArgs e) {<br /> Login ctrl = (Login) UmbracoLoginView.FindControl("Login1");<br /> Member member = Member.GetMemberFromLoginName(ctrl.UserName);<br /> <br /> if ((member != null) && (member.Id > 0)) {<br /> <br /> try {<br /> int nodeId = int.Parse(member.getProperty("redirect").Value.ToString());<br /> if (nodeId > 0)<br /> Response.Redirect(umbraco.library.NiceUrl(nodeId), true);<br /> <br /> } <br /> catch {<br /> }<br /> <br /> Response.Redirect("/error.aspx");<br /> }<br /> }<br /> </script>Glad to hear that you got it working :)
However I am a bit curious about how you avoid that people from company a can see the site for company b.
I am working on a project, where the structure is similliar to yours. Currently all logged in members can access the sites of others. And that is of course not the intention :)
On my member-page I have a field, that gets the member id so I am thinking that I should just make a comparisson between the value from the field and the the member id.
Do you have any suggestions about this?
[quote=Jasko]Glad to hear that you got it working :)
However I am a bit curious about how you avoid that people from company a can see the site for company b.
I am working on a project, where the structure is similliar to yours. Currently all logged in members can access the sites of others. And that is of course not the intention :)
On my member-page I have a field, that gets the member id so I am thinking that I should just make a comparisson between the value from the field and the the member id.
Do you have any suggestions about this?[/quote]
Yes that is a concern I have as well and I am not sure yet how I am going to concur it. If worse comes to worse I was thinking I could ditch the sitemap that way the users do not know that there are other sections of the site. Since mine is only about 5 distributors across the US, I think I may be able to get away with this but I am not sure. If anyone has any ideas on how to do this I would be very interested.
Hi guys,
Public access should be able to cover this. If all members of site A are grouped into one group SiteA, then you could protect that site so only member of site A are able to see it, other's will get redirected to login/no access page based.
Alternatively, one could use http handlers to handle security.
Regards,
/Dirk
[quote=Dirk]Hi guys,
Public access should be able to cover this. If all members of site A are grouped into one group SiteA, then you could protect that site so only member of site A are able to see it, other's will get redirected to login/no access page based.
Alternatively, one could use http handlers to handle security.
Regards,
/Dirk
[/quote]
Ahh so I could have a member type distributors, and member group split out between the distributors (company1, company2, company3) and then have the users be members of their company. Then the company page should be only accessible to members of that company. Is that right?
Absolutely. Public access will grant access based on roles for a specific member (Role = member group)
Cheers,
/Dirk
[quote=Dirk]Absolutely. Public access will grant access based on roles for a specific member (Role = member group)
Cheers,
/Dirk
[/quote]
Genius you are amazing!
Hi Dirk
I can see the logic by handling the problem using public access in Evans case.
My case is a bit different since there are only one membertype, namely "Deltager". In my case it would not make sense, to make a new group for each member that is created.
However I am interestred in hearing more about the http handler approach?
Hi Jan,
I've done something similar by disabling access to another forum app if member was not logged on.
Basic example:
[code]public class KickModule : IHttpModule {
#region IHttpModule Members
public void Dispose() {
}
public void Init(HttpApplication context) {
context.BeginRequest += delegate {
//Do whatever is required to check whether current member has access to current page requested
};
}
#endregion
}
[/code]
/Dirk
Hi Dirk
Just to make sure that I get it.
Right now, in my project, if users are not logged in then they just get a login form.
[quote]I've done something similar by disabling access to another forum app if member was not logged on.[/quote]
Therefore I am wondering if you by this mean that your code sample does the same thing? Or does it make sure that logged in members only can access their own node and not other members nodes?
I i for instance log in to http://mysite.dk/bruger/jan.aspx I am not supposed to be able to access http://mysite.dk/bruger/mark.aspx - but right now I can.
But that could be solved by using the sample of code you provided here?
Hi Jan,
I'm confident it's possible.
Member = GetCurrentMember()
Node = nodeFactory.Node.GetCurrent()
and check relation between the two. Of course, you'll need to set a property either on member or on node to refer to the other (or make it a bidirectional relation).
For the node being requested, check whether the current logged on member is the 'owner' (using a property) and if not, redirect to owner's home page.
Might want to contact me offline for a code sample... we'll sort it out and report in forum.
/Dirk
Hi Dirk
Sounds great. Just had to be sure that I understood your fist post :)
I'll contact you if I cannot figure it out by the code samples you have provided. However I might first be looking at the project again tomorrow.
I'll keep you posted and thanks for the help so far.
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.