Thursday, April 8, 2010

Only allow approved members to Login + Umbraco

This is how I go about not allowing Umbraco members to login whn they haven't been approved.

In my MemberType I have a True/False datatype called Active.

On my MemberLogin user control page my member login control looks like

<asp:Login ID="lgMember" OnLoggingIn="Login1_LoggedIn" CssClass="login" VisibleWhenLoggedIn="false" DestinationPageUrl="/Members.aspx"
LabelStyle-VerticalAlign="middle" LabelStyle-CssClass="LoginLabel" TextBoxStyle-Width="100px" UserNameLabelText="Login"
PasswordLabelText="Password" TitleText="" DisplayRememberMe="false" runat="server" />

In the codebehind my Login1_LoggedIn event looks like.

protected void Login1_LoggedIn(object sender, EventArgs e)
//get member
Member m = Member.GetMemberByName(((Login)sender).UserName.ToString(), false).First();

if (m.getProperty("Active").Value.ToString() != "1")


This will redirect the user to a page explaining their membership hasn't been enabled yet.

No comments: