ClaptrapBot/src/main/java/net/Broken/Api/Controllers/AuthController.java

29 lines
926 B
Java
Raw Normal View History

2022-05-19 01:08:47 +02:00
package net.Broken.Api.Controllers;
import net.Broken.Api.Data.Login;
import org.springframework.security.authentication.AuthenticationManager;
import org.springframework.security.authentication.UsernamePasswordAuthenticationToken;
import org.springframework.security.core.Authentication;
import org.springframework.web.bind.annotation.*;
@RestController
@RequestMapping("/api/v2")
public class AuthController {
private final AuthenticationManager authenticationManager;
public AuthController(AuthenticationManager authenticationManager) {
this.authenticationManager = authenticationManager;
}
@PostMapping("login/discord")
public String helloUser(@RequestBody Login login) {
Authentication authentication = authenticationManager.authenticate(
new UsernamePasswordAuthenticationToken(login.redirectUri(), login.code())
);
return "Hello User";
}
}