i want to make a form using spring tags such that user can login with his email or mobile number or user name and password.
<sf:form method="POST" modelAttribute="loginBean">
<label for="user_email">User Name/Email/Mobile:</label>
<sf:input path="email,mobile,username" value="${user.email}" />
<label for="user_password">Password:</label>
<sf:input path="password" />
<input type="submit" value="submit" />
</sf:form>
LoginBean
public class LoginBean {
private String email;
private String password;
private String mobile;
private String username;
//getter setter
}
I am stuck here to bind a single input tag with multiple bean attribute.
Please help me out.
There could be 2 approached:
String login
field in the LoginBean and one form field with login
path. On the server side you should somehow recognize what is entered and do 3 attempts to login depending on the recognized way.-
tryLoginWithEmail(loginBeanInstance.getLogin(), loginBeanInstance.getPassoword());
tryLoginWithMobile(loginBeanInstance.getLogin(), loginBeanInstance.getPassoword());
tryLoginWithUsername(loginBeanInstance.getLogin(), loginBeanInstance.getPassoword());
UPDATE:
like
select * from users
where
(name =:loginNameParam and password=:passwordParam)
OR
(email =:loginNameParam and password=:passwordParam)
OR
(mobile =:loginNameParam and password=:passwordParam)