Creates default admin user
This commit is contained in:
Binary file not shown.
@@ -2,6 +2,7 @@ package com.litoralregas.backend_gateway.auth;
|
||||
|
||||
import com.litoralregas.backend_gateway.auth.dto.LoginRequest;
|
||||
import com.litoralregas.backend_gateway.auth.dto.LoginResponse;
|
||||
import org.springframework.security.crypto.password.PasswordEncoder;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
|
||||
@RestController
|
||||
@@ -9,13 +10,19 @@ import org.springframework.web.bind.annotation.*;
|
||||
public class AuthController {
|
||||
|
||||
private final AuthService authService;
|
||||
private final PasswordEncoder passwordEncoder;
|
||||
|
||||
public AuthController(AuthService authService) {
|
||||
public AuthController(
|
||||
AuthService authService,
|
||||
PasswordEncoder passwordEncoder
|
||||
) {
|
||||
this.authService = authService;
|
||||
this.passwordEncoder = passwordEncoder;
|
||||
}
|
||||
|
||||
@PostMapping("/login")
|
||||
public LoginResponse login(@RequestBody LoginRequest request) {
|
||||
System.out.println(passwordEncoder.encode("admin123"));
|
||||
return authService.login(request);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,16 @@
|
||||
INSERT INTO clients (name, backend_base_url, enabled)
|
||||
SELECT 'dev-local', 'http://10.100.1.2:18450', 1
|
||||
WHERE NOT EXISTS (
|
||||
SELECT 1 FROM clients WHERE name = 'dev-local'
|
||||
);
|
||||
|
||||
INSERT INTO users (client_id, username, password_hash, role, enabled)
|
||||
SELECT
|
||||
(SELECT id FROM clients WHERE name = 'dev-local'),
|
||||
'admin',
|
||||
'$2a$10$it1vy5t1FXISQTWit2A39udaMR0N0yqJtJUnxMqF1Xz4SuNBaam6u',
|
||||
'ADMIN',
|
||||
1
|
||||
WHERE NOT EXISTS (
|
||||
SELECT 1 FROM users WHERE username = 'admin'
|
||||
);
|
||||
Reference in New Issue
Block a user