mirror of
https://github.com/Athou/commafeed.git
synced 2026-03-21 21:37:29 +00:00
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>
|
<div class="feedback alert alert-danger" ng-if="message">{{message}}</div>
|
||||||
<form ng-submit="login()">
|
<form ng-submit="login()">
|
||||||
<div class="form-group">
|
<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>
|
<input type="text" name="username" class="form-control" ng-model="model.name"></input>
|
||||||
</div>
|
</div>
|
||||||
<div class="form-group">
|
<div class="form-group">
|
||||||
|
|||||||
@@ -31,12 +31,15 @@ public class UserService {
|
|||||||
private final PasswordEncryptionService encryptionService;
|
private final PasswordEncryptionService encryptionService;
|
||||||
private final CommaFeedConfiguration config;
|
private final CommaFeedConfiguration config;
|
||||||
|
|
||||||
public Optional<User> login(String name, String password) {
|
public Optional<User> login(String nameOrEmail, String password) {
|
||||||
if (name == null || password == null) {
|
if (nameOrEmail == null || password == null) {
|
||||||
return Optional.absent();
|
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()) {
|
if (user != null && !user.isDisabled()) {
|
||||||
boolean authenticated = encryptionService.authenticate(password, user.getPassword(), user.getSalt());
|
boolean authenticated = encryptionService.authenticate(password, user.getPassword(), user.getSalt());
|
||||||
if (authenticated) {
|
if (authenticated) {
|
||||||
|
|||||||
Reference in New Issue
Block a user