// Path: src/main/java/org/nextrtc/examples/videochat_with_rest/auth/AuthUtils.java
// @Service
// public class AuthUtils {
// 
//     @Autowired
//     private UserRepository userRepository;
// 
//     public User getAuthenticatedUser(Principal userPrincipal) {
//         String name = userPrincipal.getName();
//         Optional<User> byUsername = userRepository.findByUsername(name);
//         if (!byUsername.isPresent()) {
//             byUsername = userRepository.findByAuthProviderId(name);
// 
//         }
//         return byUsername.orElseThrow(() -> new RuntimeException("User isn't authenticated!"));
//     }
// }


import org.nextrtc.examples.videochat_with_rest.auth.AuthUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RestController;
import java.security.Principal;
package org.nextrtc.examples.videochat_with_rest.controller;



@RestController
@RequestMapping("/action/check")
public class CheckMyName {

    @Autowired
// Path: src/main/java/org/nextrtc/examples/videochat_with_rest/auth/AuthUtils.java
// @Service
// public class AuthUtils {
// 
//     @Autowired
//     private UserRepository userRepository;
// 
//     public User getAuthenticatedUser(Principal userPrincipal) {
//         String name = userPrincipal.getName();
//         Optional<User> byUsername = userRepository.findByUsername(name);
//         if (!byUsername.isPresent()) {
//             byUsername = userRepository.findByAuthProviderId(name);
// 
//         }
//         return byUsername.orElseThrow(() -> new RuntimeException("User isn't authenticated!"));
//     }
// }


// Path: src/main/java/org/nextrtc/examples/videochat_with_rest/controller/CheckMyName.java
import org.nextrtc.examples.videochat_with_rest.auth.AuthUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RestController;
import java.security.Principal;

package org.nextrtc.examples.videochat_with_rest.controller;



@RestController
@RequestMapping("/action/check")
public class CheckMyName {

    @Autowired
    private AuthUtils authUtils;