29 lines
926 B
Java
29 lines
926 B
Java
|
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";
|
||
|
}
|
||
|
|
||
|
|
||
|
}
|