|
|
@@ -1,6 +1,7 @@
|
|
|
package com.deliveryproject.easydelivery;
|
|
|
|
|
|
import com.deliveryproject.easydelivery.Configuration.Constants;
|
|
|
+import com.deliveryproject.easydelivery.Models.AppUser;
|
|
|
import com.deliveryproject.easydelivery.Models.KeycloakUser.User;
|
|
|
import com.deliveryproject.easydelivery.RequestBody.Token;
|
|
|
import com.deliveryproject.easydelivery.Roles.RoleInterface;
|
|
|
@@ -10,6 +11,7 @@ import com.mashape.unirest.http.HttpResponse;
|
|
|
import com.mashape.unirest.http.Unirest;
|
|
|
import com.mashape.unirest.http.exceptions.UnirestException;
|
|
|
import org.json.JSONObject;
|
|
|
+import org.springframework.beans.factory.annotation.Autowired;
|
|
|
import org.springframework.http.*;
|
|
|
import org.springframework.util.LinkedMultiValueMap;
|
|
|
import org.springframework.util.MultiValueMap;
|
|
|
@@ -26,6 +28,10 @@ import static com.deliveryproject.easydelivery.Utils.JWTUtils.decode;
|
|
|
|
|
|
@RestController
|
|
|
public class KeycloakController {
|
|
|
+ @Autowired
|
|
|
+ AppUserController appUserController;
|
|
|
+
|
|
|
+
|
|
|
@RequestMapping(value = "/keycloak/login")
|
|
|
@ResponseBody
|
|
|
@CrossOrigin(origins = "http://localhost:3000", maxAge = 3600)
|
|
|
@@ -156,7 +162,9 @@ public class KeycloakController {
|
|
|
String user_id = payload.getString("sub").toString();
|
|
|
|
|
|
assignRoleToUser(user_id, new com.deliveryproject.easydelivery.Roles.User());
|
|
|
-
|
|
|
+ AppUser newUser = new AppUser();
|
|
|
+ newUser.setName(user.username);
|
|
|
+ appUserController.createUser(newUser);
|
|
|
return new ResponseEntity<>(HttpStatus.OK);
|
|
|
} catch (Exception e) {
|
|
|
System.err.println(e);
|