Project

General

Profile

« Previous | Next » 

Revision 47598

- Fixed duplicate dependncies
- Fixed an error in eligibility checking
- Fixed an error in account activation
- Organized imports

View differences:

UserManagerImpl.java
2 2

  
3 3

  
4 4
import eu.dnetlib.goldoa.domain.*;
5

  
6 5
import eu.dnetlib.goldoa.service.dao.UserDAO;
7 6
import eu.dnetlib.goldoa.service.utils.EmailUtils;
8 7
import org.apache.commons.codec.digest.DigestUtils;
9 8
import org.apache.commons.logging.Log;
10 9
import org.apache.commons.logging.LogFactory;
11
import org.hibernate.Hibernate;
12 10
import org.springframework.beans.factory.annotation.Autowired;
13 11
import org.springframework.stereotype.Service;
14 12
import org.springframework.transaction.annotation.Transactional;
......
143 141
	@Override
144 142
	public User login(String email, String password) throws PersonManagerException {
145 143

  
146
		if (userDAO.verifyLogin(email, password)) {
147
			User user = getByEmail(email);
148
			if (user.isActive())
149
				return user;
150
			else
151
				throw new PersonManagerException(PersonManagerException.ErrorCause.NOT_ACTIVATED);
152
		} else {
153
			throw new PersonManagerException(PersonManagerException.ErrorCause.WRONG_EMAIL_OR_PASSWORD);
144
		try {
145
			if (userDAO.verifyLogin(email, password)) {
146
				System.out.println("verified login");
147
				User user = getByEmail(email);
148
				if (user.isActive()) {
149
					System.out.println("user is active");
150
					return user;
151
				}
152
				else
153
					throw new PersonManagerException(PersonManagerException.ErrorCause.NOT_ACTIVATED);
154
			} else {
155
				throw new PersonManagerException(PersonManagerException.ErrorCause.WRONG_EMAIL_OR_PASSWORD);
156
			}
157
		} catch (PersonManagerException e) {
158
			throw e;
159
		} catch (Exception e) {
160
			log.error("Error logging in", e);
154 161
		}
162
		return null;
155 163
	}
156 164

  
157 165
	@Override

Also available in: Unified diff