I've followed the great article http://www.nibble.be/?p=66, as I would like to disable member logins until they've been approved. The member type has a check property with an alias of approved. The approach used in the article, does not appear to work in Umbraco versions of 4.0.2 or greater.
I'm using Umbraco version v
4.0.4.2 and the ASP.Net LoginContorls. And was wondering if and how I can achieve a similair thing?
... public class CustomMemberShipProvide :UmbracoMembershipProvider { public override bool ValidateUser(string username, string password) { string encodedPassword = EncodePassword(password); Member currentMember = Member.GetMemberFromLoginAndEncodedPassword(username, encodedPassword); if (currentMember == null) { return false; } else { try { if (currentMember.getProperty("approved").ToString() == "1") { return true; }else{ return false; } }catch{ return false; } } //also intellisense is stating this code is never reached??? return (currentMember != null); }
} ...
Any thoughts or ideas would be greatly appreciated
Thanks, tried the alternative method (http://our.umbraco.org/wiki/how-tos/membership-providers/check-if-user-is-active-before-logging-in/alternative-method-for-checking-active-membership).
Which works when the correct username and password are entered. When either the username or password is entered incorrectly i get a server application error - Object reference not set to an instance of an object.
Code from class:
using System; using System.Collections.Generic; using System.Linq; using System.Web; using System.Web.UI; using System.Web.UI.WebControls; using umbraco.cms.businesslogic.member;
namespace LoginForm { public partial class LoginForm : System.Web.UI.UserControl { protected void CheckMemberStatus(object sender, LoginCancelEventArgs e) { Member m = Member.GetMemberFromLoginNameAndPassword(login.UserName, login.Password); if (m.getProperty("memberStatus").Value.ToString() != "22") { e.Cancel = true; login.FailureText = "Your Member account is not yet active..."; } }
When entering an incorrect username or password, the member does not exist. So wrapping an if statement around the getProperty(...) seems to have done the trick.
... if (m != null) { if (m.getProperty("memberStatus").Value.ToString() != "22") { e.Cancel = true; login.FailureText = "Your Member account is not yet active..."; } } ...
Login only approved members
Hi All
I've followed the great article http://www.nibble.be/?p=66, as I would like to disable member logins until they've been approved. The member type has a check property with an alias of approved. The approach used in the article, does not appear to work in Umbraco versions of 4.0.2 or greater.
I'm using Umbraco version v 4.0.4.2 and the ASP.Net LoginContorls. And was wondering if and how I can achieve a similair thing?
Any thoughts or ideas would be greatly appreciated
Thanks
Eddie
Have you tried this? http://our.umbraco.org/wiki/how-tos/membership-providers/check-if-user-is-active-before-logging-in
Hi Slace
Thanks, tried the alternative method (http://our.umbraco.org/wiki/how-tos/membership-providers/check-if-user-is-active-before-logging-in/alternative-method-for-checking-active-membership).
Which works when the correct username and password are entered. When either the username or password is entered incorrectly i get a server application error - Object reference not set to an instance of an object.
Code from class:
Stack Trace:
Any thoughts
Thanks
Eddie
Make sure that there is a value in the property you're trying to check.
Hi Slace
When entering an incorrect username or password, the member does not exist. So wrapping an if statement around the getProperty(...) seems to have done the trick.
Thanks for your help
Eddie
I'd also check that m.getProperty(...).Value != null, unless you're unit tests ensure that you could never reach that state.
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.