forked from Archives/Athou_commafeed
login by name or email
This commit is contained in:
@@ -22,7 +22,7 @@
|
||||
<div class="feedback alert alert-danger" ng-if="message">{{message}}</div>
|
||||
<form ng-submit="login()">
|
||||
<div class="form-group">
|
||||
<label for="username">User Name</label>
|
||||
<label for="username">User Name or E-mail</label>
|
||||
<input type="text" name="username" class="form-control" ng-model="model.name"></input>
|
||||
</div>
|
||||
<div class="form-group">
|
||||
|
||||
@@ -31,12 +31,15 @@ public class UserService {
|
||||
private final PasswordEncryptionService encryptionService;
|
||||
private final CommaFeedConfiguration config;
|
||||
|
||||
public Optional<User> login(String name, String password) {
|
||||
if (name == null || password == null) {
|
||||
public Optional<User> login(String nameOrEmail, String password) {
|
||||
if (nameOrEmail == null || password == null) {
|
||||
return Optional.absent();
|
||||
}
|
||||
|
||||
User user = userDAO.findByName(name);
|
||||
User user = userDAO.findByName(nameOrEmail);
|
||||
if (user == null) {
|
||||
user = userDAO.findByEmail(nameOrEmail);
|
||||
}
|
||||
if (user != null && !user.isDisabled()) {
|
||||
boolean authenticated = encryptionService.authenticate(password, user.getPassword(), user.getSalt());
|
||||
if (authenticated) {
|
||||
|
||||
Reference in New Issue
Block a user