Changeset 0f5aa27 for src/main/java/com/tourMate/config/UserSecurity.java
- Timestamp:
- 02/04/24 16:57:49 (10 months ago)
- Branches:
- master
- Children:
- efaa053
- Parents:
- 07f4e8b
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
src/main/java/com/tourMate/config/UserSecurity.java
r07f4e8b r0f5aa27 1 1 package com.tourMate.config; 2 2 3 import com.tourMate.config.oauth2.CustomOAuth2UserDetailService; 4 import com.tourMate.config.oauth2.OAuth2UserDetailsCustom; 3 5 import com.tourMate.entities.Hotels; 4 6 import com.tourMate.entities.User; … … 25 27 public boolean hasUserId(Authentication authentication, Long userId) { 26 28 System.out.println(userId); 27 User user = (User) authentication.getPrincipal(); 28 System.out.println(user.getUserID()); 29 System.out.println(authentication.getPrincipal()); 30 return userId == user.getUserID(); 29 Long id; 30 if(authentication.getPrincipal() instanceof OAuth2UserDetailsCustom oAuth2UserDetailsCustom) 31 { 32 id = oAuth2UserDetailsCustom.getId(); 33 } 34 else 35 { 36 User user = (User) authentication.getPrincipal(); 37 id = user.getUserID(); 38 } 39 return userId == id; 31 40 } 32 41
Note:
See TracChangeset
for help on using the changeset viewer.