error in user registration process of broadleaf commerce -
i configured broadleaf project tomcat , site module on running when go register new user says like--please enter valid password , submit button user added in user when go admin panel see same user registered can't login same user name , password provided while registration , give following errors--the e-mail address and/or password entered not match our records. please try again
this bug in broadleaf commerce application. stores hashed password in database, when login, matches "clean" password hashed one. therefore, getting "incorrect password".
edit
here exact steps make work.
note: i have used sha-256 algorithm salt username
- applicationcontext-security.xml: comment following tags
<sec:authentication-manager>...some stuff..</sec:authentication-manager>
- in same file, add following:
<bean id="blsaltsource" class="org.springframework.security.authentication.dao.reflectionsaltsource"> <property name="userpropertytouse" value="username" /> </bean> <bean id="mdpasswordencoder" class="org.springframework.security.authentication.encoding.shapasswordencoder"> <constructor-arg value="256"/> </bean> <sec:authentication-manager alias="blauthenticationmanager"> <sec:authentication-provider user-service-ref="bluserdetailsservice"> <sec:password-encoder hash="sha-256" ref="mdpasswordencoder"> <sec:salt-source ref="blsaltsource" /> </sec:password-encoder> </sec:authentication-provider> </sec:authentication-manager>
- create class provide object of sha 256 algorithm.
public class commonutils { private static final shapasswordencoder encoder = new shapasswordencoder(256); public static shapasswordencoder getcustomerpasswordencoder() { return encoder; } } - in core module, extend customerserviceimpl , override registercustomer method.
public class mdcustomerserviceimpl extends customerserviceimpl { public customer registercustomer(customer customer, string password, string passwordconfirm) { shapasswordencoder encoder = commonutils.getcustomerpasswordencoder(); password = encoder.encodepassword(password, customer.getusername()); passwordconfirm = encoder.encodepassword(passwordconfirm, customer.getusername()); return super.registercustomer(customer, password, passwordconfirm); } } in core module's applicationcontext.xml, register new service class.
<bean id="blcustomerservice" class="<path_to>mdcustomerserviceimpl" />
in registercontroller's processregister, add first line as:
string unencodedpassword = registercustomerform.getpassword();
- replace
loginservice.logincustomer(registercustomerform.getcustomer());
by
string codedpassword = registercustomerform.getcustomer().getpassword(); newcustomer.setunencodedpassword(unencodedpassword) loginservice.logincustomer(newcustomer); newcustomer.setunencodedpassword(codedpassword); newcustomer.setpassword(codedpassword); customerservice.savecustomer(newcustomer);
this should make go. :)
Comments
Post a Comment