Subversion Repositories SmartDukaan

Rev

Rev 24389 | Rev 24492 | Go to most recent revision | Show entire file | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed

Rev 24389 Rev 24479
Line 11... Line 11...
11
 
11
 
12
import com.google.common.hash.Hashing;
12
import com.google.common.hash.Hashing;
13
import com.spice.profitmandi.common.exception.ProfitMandiBusinessException;
13
import com.spice.profitmandi.common.exception.ProfitMandiBusinessException;
14
import com.spice.profitmandi.common.util.Utils;
14
import com.spice.profitmandi.common.util.Utils;
15
import com.spice.profitmandi.dao.entity.auth.AuthUser;
15
import com.spice.profitmandi.dao.entity.auth.AuthUser;
-
 
16
import com.spice.profitmandi.dao.entity.dtr.User;
-
 
17
import com.spice.profitmandi.dao.entity.user.Promoter;
16
import com.spice.profitmandi.dao.repository.auth.AuthRepository;
18
import com.spice.profitmandi.dao.repository.auth.AuthRepository;
-
 
19
import com.spice.profitmandi.dao.repository.dtr.UserRepository;
-
 
20
import com.spice.profitmandi.dao.repository.user.PromoterRepository;
17
 
21
 
18
@Component
22
@Component
19
public class AuthServiceImpl implements AuthService {
23
public class AuthServiceImpl implements AuthService {
20
 
24
 
21
	// private static final String RESET_PASSWORD_BODY = "Dear %s, your password has
25
	// private static final String RESET_PASSWORD_BODY = "Dear %s, your password has
Line 29... Line 33...
29
	@Autowired
33
	@Autowired
30
	AuthRepository authRepository;
34
	AuthRepository authRepository;
31
 
35
 
32
	@Autowired
36
	@Autowired
33
	JavaMailSender mailSender;
37
	JavaMailSender mailSender;
-
 
38
	
-
 
39
	@Autowired
-
 
40
	PromoterRepository promoterRepository;
-
 
41
	
-
 
42
	@Autowired
-
 
43
	UserRepository userRepository;
34
 
44
 
35
	private String getHash256(String originalString) {
45
	private String getHash256(String originalString) {
36
		return Hashing.sha256().hashString(originalString, StandardCharsets.UTF_8).toString();
46
		return Hashing.sha256().hashString(originalString, StandardCharsets.UTF_8).toString();
37
	}
47
	}
38
 
48
 
Line 92... Line 102...
92
		boolean useNumbers = false;
102
		boolean useNumbers = false;
93
		String generatedString = RandomStringUtils.random(length, useLetters, useNumbers);
103
		String generatedString = RandomStringUtils.random(length, useLetters, useNumbers);
94
		return generatedString;
104
		return generatedString;
95
	}
105
	}
96
 
106
 
-
 
107
	@Override
-
 
108
	public String getNameByEmailId(String email) {
-
 
109
		AuthUser authUser = authRepository.selectByGmailId(email);
-
 
110
		String userName = null;
-
 
111
		
-
 
112
		if(authUser != null) {
-
 
113
			userName = authUser.getFirstName() + " " + authUser.getLastName();
-
 
114
		} else {
-
 
115
			if(promoterRepository.isExistByEmailId(email)) {
-
 
116
				Promoter promoter = promoterRepository.selectByEmailId(email);
-
 
117
				userName = promoter.getName();
-
 
118
				
-
 
119
			} else if(userRepository.isExistBySecondryEmailId(email)){
-
 
120
				try {
-
 
121
					User user = userRepository.selectBySecondryEmailId(email);
-
 
122
					userName = user.getFirstName() + " " + user.getLastName();
-
 
123
				} catch(Exception e) {
-
 
124
					e.printStackTrace();
-
 
125
				}
-
 
126
			}
-
 
127
		}
-
 
128
		return userName;
-
 
129
	}
-
 
130
 
-
 
131
 
97
}
132
}
98
133