mirror of
https://github.com/nagisa77/OpenIsle.git
synced 2026-05-11 21:27:31 +08:00
feat: update config
This commit is contained in:
3
.gitignore
vendored
Normal file
3
.gitignore
vendored
Normal file
@@ -0,0 +1,3 @@
|
|||||||
|
.idea
|
||||||
|
target
|
||||||
|
openisle.iml
|
||||||
@@ -17,6 +17,11 @@ public class AuthController {
|
|||||||
private final JwtService jwtService;
|
private final JwtService jwtService;
|
||||||
private final EmailService emailService;
|
private final EmailService emailService;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* curl -X POST http://localhost:8080/api/auth/login \
|
||||||
|
* -H "Content-Type: application/json" \
|
||||||
|
* -d '{"username":"test","password":"password"}'
|
||||||
|
*/
|
||||||
@PostMapping("/register")
|
@PostMapping("/register")
|
||||||
public ResponseEntity<?> register(@RequestBody RegisterRequest req) {
|
public ResponseEntity<?> register(@RequestBody RegisterRequest req) {
|
||||||
User user = userService.register(req.getUsername(), req.getEmail(), req.getPassword());
|
User user = userService.register(req.getUsername(), req.getEmail(), req.getPassword());
|
||||||
@@ -25,6 +30,11 @@ public class AuthController {
|
|||||||
return ResponseEntity.ok(new JwtResponse(token));
|
return ResponseEntity.ok(new JwtResponse(token));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* curl -X POST http://localhost:8080/api/auth/login \
|
||||||
|
* -H "Content-Type: application/json" \
|
||||||
|
* -d '{"username":"test","password":"password"}'
|
||||||
|
*/
|
||||||
@PostMapping("/login")
|
@PostMapping("/login")
|
||||||
public ResponseEntity<?> login(@RequestBody LoginRequest req) {
|
public ResponseEntity<?> login(@RequestBody LoginRequest req) {
|
||||||
return userService.authenticate(req.getUsername(), req.getPassword())
|
return userService.authenticate(req.getUsername(), req.getPassword())
|
||||||
|
|||||||
@@ -5,6 +5,10 @@ import org.springframework.web.bind.annotation.RestController;
|
|||||||
|
|
||||||
@RestController
|
@RestController
|
||||||
public class HelloController {
|
public class HelloController {
|
||||||
|
/**
|
||||||
|
* curl http://localhost:8080/api/hello \
|
||||||
|
* -H "Authorization: Bearer <jwt-token>"
|
||||||
|
*/
|
||||||
@GetMapping("/api/hello")
|
@GetMapping("/api/hello")
|
||||||
public String hello() {
|
public String hello() {
|
||||||
return "Hello, Authenticated User";
|
return "Hello, Authenticated User";
|
||||||
|
|||||||
@@ -30,7 +30,7 @@ public class EmailService {
|
|||||||
body.put("to", to);
|
body.put("to", to);
|
||||||
body.put("subject", subject);
|
body.put("subject", subject);
|
||||||
body.put("text", text);
|
body.put("text", text);
|
||||||
body.put("from", "demo@openisle.example");
|
body.put("from", "cjt807916@gmail.com"); // todo(tim): use config
|
||||||
|
|
||||||
HttpEntity<Map<String, String>> entity = new HttpEntity<>(body, headers);
|
HttpEntity<Map<String, String>> entity = new HttpEntity<>(body, headers);
|
||||||
restTemplate.exchange(url, HttpMethod.POST, entity, String.class);
|
restTemplate.exchange(url, HttpMethod.POST, entity, String.class);
|
||||||
|
|||||||
Reference in New Issue
Block a user