| Line 1... |
Line 1... |
| 1 |
package com.spice.profitmandi.web.processor;
|
1 |
package com.spice.profitmandi.web.processor;
|
| 2 |
|
2 |
|
| 3 |
import java.io.IOException;
|
3 |
import java.io.IOException;
|
| 4 |
import java.time.LocalDateTime;
|
4 |
import java.time.LocalDateTime;
|
| 5 |
import java.util.HashMap;
|
5 |
import java.util.HashMap;
|
| - |
|
6 |
import java.util.HashSet;
|
| 6 |
import java.util.Iterator;
|
7 |
import java.util.Iterator;
|
| 7 |
import java.util.Map;
|
8 |
import java.util.Map;
|
| 8 |
import java.util.Set;
|
9 |
import java.util.Set;
|
| 9 |
|
10 |
|
| 10 |
import org.springframework.beans.factory.annotation.Autowired;
|
11 |
import org.springframework.beans.factory.annotation.Autowired;
|
| Line 81... |
Line 82... |
| 81 |
socialUser.setUpdateTimestamp(LocalDateTime.now());
|
82 |
socialUser.setUpdateTimestamp(LocalDateTime.now());
|
| 82 |
socialUserRepository.persist(socialUser);
|
83 |
socialUserRepository.persist(socialUser);
|
| 83 |
Map<String, Object> responseMap = new HashMap<>(2);
|
84 |
Map<String, Object> responseMap = new HashMap<>(2);
|
| 84 |
try{
|
85 |
try{
|
| 85 |
User user = userRepository.selectByEmailId(socialUser.getEmailId());
|
86 |
User user = userRepository.selectByEmailId(socialUser.getEmailId());
|
| 86 |
Set<Role> roles = user.getRoles();
|
87 |
//Set<Role> roles = user.getRoles();
|
| - |
|
88 |
Set<Role> roles = new HashSet<>();
|
| 87 |
String[] roleTypes = new String[roles.size()];
|
89 |
String[] roleNames = new String[roles.size()];
|
| 88 |
int index = 0;
|
90 |
int index = 0;
|
| 89 |
for(Role role : roles){
|
91 |
for(Role role : roles){
|
| 90 |
roleTypes[index++] = role.getType().toString();
|
92 |
roleNames[index++] = role.getName();
|
| 91 |
}
|
93 |
}
|
| 92 |
responseMap.put(ProfitMandiConstants.TOKEN, JWTUtil.create(user.getId(), roleTypes));
|
94 |
responseMap.put(ProfitMandiConstants.TOKEN, JWTUtil.create(user.getId(), roleNames));
|
| 93 |
responseMap.put(ProfitMandiConstants.REGISTERED, true);
|
95 |
responseMap.put(ProfitMandiConstants.REGISTERED, true);
|
| 94 |
}catch (ProfitMandiBusinessException pmbe) {
|
96 |
}catch (ProfitMandiBusinessException pmbe) {
|
| 95 |
responseMap.put(ProfitMandiConstants.TOKEN, JWTUtil.create());
|
97 |
responseMap.put(ProfitMandiConstants.TOKEN, JWTUtil.create());
|
| 96 |
responseMap.put(ProfitMandiConstants.REGISTERED, false);
|
98 |
responseMap.put(ProfitMandiConstants.REGISTERED, false);
|
| 97 |
}
|
99 |
}
|