Ignore:
Timestamp:
02/04/24 16:57:49 (10 months ago)
Author:
darsov2 <62809499+darsov2@…>
Branches:
master
Children:
efaa053
Parents:
07f4e8b
Message:

ouath, mailing impl

File:
1 edited

Legend:

Unmodified
Added
Removed
  • src/main/java/com/tourMate/config/UserSecurity.java

    r07f4e8b r0f5aa27  
    11package com.tourMate.config;
    22
     3import com.tourMate.config.oauth2.CustomOAuth2UserDetailService;
     4import com.tourMate.config.oauth2.OAuth2UserDetailsCustom;
    35import com.tourMate.entities.Hotels;
    46import com.tourMate.entities.User;
     
    2527    public boolean hasUserId(Authentication authentication, Long userId) {
    2628        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;
    3140    }
    3241
Note: See TracChangeset for help on using the changeset viewer.