提交 c0494124 authored 作者: Whispa's avatar Whispa

commit commit

上级 5ee8c47c
......@@ -71,26 +71,26 @@ public class AuthController extends Controller {
@PostMapping("/signin")
public Result authenticateUser(@RequestBody LoginRequest loginRequest) {
Optional<TbCfUserInfo> byAccount = userRepository.findByFirebaseUid(loginRequest.getAccount());
Optional<TbCfUserInfo> byAccount = userRepository.findFirstByAccount(loginRequest.getAccount());
Result<Object> notFound = new Result<>(ResultCodeEnum.VALIDATE_ERROR.getCode(), "User not found");
if (!byAccount.isPresent()) {
boolean b = userRepository.existsByAccount(loginRequest.getAccount());
if (b) {
Optional<TbCfUserInfo> firstByAccount = userRepository.findFirstByAccount(loginRequest.getAccount());
if (firstByAccount.isPresent()) {
TbCfUserInfo userInfo = firstByAccount.get();
userInfo.setFirebaseUid(loginRequest.getAccount());
fixCode(userInfo);
try {
userRepository.save(userInfo);
} catch (Exception e) {
return notFound;
}
byAccount = Optional.of(userInfo);
} else return notFound;
} else
//
// boolean b = userRepository.existsByAccount(loginRequest.getAccount());
//
// if (b) {
// Optional<TbCfUserInfo> firstByAccount = userRepository.findFirstByAccount(loginRequest.getAccount());
// if (firstByAccount.isPresent()) {
// TbCfUserInfo userInfo = firstByAccount.get();
// userInfo.setFirebaseUid(loginRequest.getAccount());
// fixCode(userInfo);
// try {
// userRepository.save(userInfo);
// } catch (Exception e) {
// return notFound;
// }
// byAccount = Optional.of(userInfo);
// } else return notFound;
// } else
return notFound;
}
......@@ -106,9 +106,9 @@ public class AuthController extends Controller {
String jwt = jwtUtils.generateJwtToken(authentication);
UserDetailsImpl userDetails = (UserDetailsImpl) authentication.getPrincipal();
List<String> roles = userDetails.getAuthorities().stream()
.map(GrantedAuthority::getAuthority)
.collect(Collectors.toList());
// List<String> roles = userDetails.getAuthorities().stream()
// .map(GrantedAuthority::getAuthority)
// .collect(Collectors.toList());
TbCfUserInfo userInfo = byAccount.get();
......@@ -118,10 +118,6 @@ public class AuthController extends Controller {
userInfo.setFcm(loginRequest.getFcm());
}
if (loginRequest.getVeryOldPassword() != null) {
userInfo.setPassword(loginRequest.getVeryOldPassword());
}
userInfo.setLastLoginTime(new Date());
userInfo.setUserType(UserTypeEnum.EMAIL.getCode());
......@@ -189,7 +185,7 @@ public class AuthController extends Controller {
}
signUpRequest.setFirebaseUid(email);
//signUpRequest.setFirebaseUid(email);
signUpRequest.setAccount(email);
signUpRequest.setUserId(IdUtil.createIdbyUUID());
......@@ -311,12 +307,6 @@ public class AuthController extends Controller {
}
// // generate token codes has been moved downwards from if condition of checking if user doesn't exist in database, because even if
// // user exist we have to generate token also
// if (user.getPassword() == null || gotFromOld) {
// user.setFirebaseUid(firebaseUid);// Assign user from database to the user we have to return back to request
// // user.setPassword(encoder.encode(firebaseUid));// Assign user from database to the user we have to return back to request
// }
fixCode(user);
......
......@@ -5,9 +5,7 @@ public class LoginRequest {
private String account;
private String password;
private String veryOldPassword;
private String fcm;
private boolean fromUser = false;
public LoginRequest(){
......@@ -19,13 +17,6 @@ public class LoginRequest {
this.password = password;
}
public void setFromUser(boolean fromUser) {
this.fromUser = fromUser;
}
public boolean isFromUser() {
return fromUser;
}
public LoginRequest(String account, String password, String fcm){
this.account = account;
......@@ -33,13 +24,6 @@ public class LoginRequest {
this.fcm = fcm;
}
public void setVeryOldPassword(String veryOldPassword) {
this.veryOldPassword = veryOldPassword;
}
public String getVeryOldPassword() {
return veryOldPassword;
}
public String getAccount() {
return account;
......
......@@ -20,7 +20,7 @@ public class UserDetailsServiceImpl implements UserDetailsService {
@Override
@Transactional
public UserDetails loadUserByUsername(String username) throws UsernameNotFoundException {
TbCfUserInfo user = userRepository.findByFirebaseUid(username)
TbCfUserInfo user = userRepository.findFirstByAccount(username)
.orElseThrow(() -> new UsernameNotFoundException("User Not Found with username: " + username));
return UserDetailsImpl.build(user);
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论