-
Notifications
You must be signed in to change notification settings - Fork 8
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
moved the modules of user to a single place, added few members, added…
… uniqueness of email at the db level
- Loading branch information
Showing
31 changed files
with
294 additions
and
282 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
2 changes: 1 addition & 1 deletion
2
src/main/java/com/quiz/darkhold/challenge/entity/Challenge.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
6 changes: 3 additions & 3 deletions
6
...in/controller/RegistrationController.java → ...er/controller/RegistrationController.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
54 changes: 54 additions & 0 deletions
54
src/main/java/com/quiz/darkhold/user/controller/UserController.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,54 @@ | ||
package com.quiz.darkhold.user.controller; | ||
|
||
import com.quiz.darkhold.user.entity.User; | ||
import com.quiz.darkhold.user.service.UserService; | ||
import org.apache.logging.log4j.LogManager; | ||
import org.apache.logging.log4j.Logger; | ||
import org.springframework.stereotype.Controller; | ||
import org.springframework.ui.Model; | ||
import org.springframework.web.bind.annotation.GetMapping; | ||
import org.springframework.web.bind.annotation.PostMapping; | ||
import org.springframework.web.servlet.mvc.support.RedirectAttributes; | ||
|
||
@Controller | ||
public class UserController { | ||
private final Logger logger = LogManager.getLogger(UserController.class); | ||
private final UserService userService; | ||
|
||
public UserController(final UserService userService) { | ||
this.userService = userService; | ||
} | ||
|
||
/** | ||
* on to create challenge page. | ||
* | ||
* @return create challenge page | ||
*/ | ||
@GetMapping("/userManagement") | ||
public String manageUsers(final Model model) { | ||
logger.info("Into the manageUsers method"); | ||
var listUsers = userService.listAll(); | ||
model.addAttribute("listusers", listUsers); | ||
return "user/usermanagement"; | ||
} | ||
|
||
@GetMapping("/user/create") | ||
public String createUser(final Model model) { | ||
logger.info("Into the createUser method"); | ||
var roles = userService.listRoles(); | ||
var user = new User(); | ||
user.setEnabled(true); | ||
model.addAttribute("userForm", user); | ||
model.addAttribute("listRoles", roles); | ||
return "user/createuser"; | ||
} | ||
|
||
@PostMapping("/users/save") | ||
public String saveUser(final User user, final RedirectAttributes redirectAttributes) { | ||
logger.info("Into the saveUser method, user is {}", user); | ||
userService.save(user); | ||
redirectAttributes.addFlashAttribute("message", "The user has been saved successfully"); | ||
return "redirect:/userManagement"; | ||
} | ||
} | ||
|
20 changes: 20 additions & 0 deletions
20
src/main/java/com/quiz/darkhold/user/controller/UserRestController.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
package com.quiz.darkhold.user.controller; | ||
|
||
import com.quiz.darkhold.user.service.UserService; | ||
import org.springframework.data.repository.query.Param; | ||
import org.springframework.web.bind.annotation.PostMapping; | ||
import org.springframework.web.bind.annotation.RestController; | ||
|
||
@RestController | ||
public class UserRestController { | ||
private final UserService userService; | ||
|
||
public UserRestController(final UserService userService) { | ||
this.userService = userService; | ||
} | ||
|
||
@PostMapping("/users/check_email") | ||
public String checkDuplicateEmail(@Param("email") final String email) { | ||
return userService.isEmailUnique(email) ? "OK" : "DUPLICATED"; | ||
} | ||
} |
2 changes: 1 addition & 1 deletion
2
...old/login/entity/DarkholdUserDetails.java → ...hold/user/entity/DarkholdUserDetails.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
2 changes: 1 addition & 1 deletion
2
.../com/quiz/darkhold/login/entity/Role.java → ...a/com/quiz/darkhold/user/entity/Role.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
2 changes: 1 addition & 1 deletion
2
.../com/quiz/darkhold/login/entity/User.java → ...a/com/quiz/darkhold/user/entity/User.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
4 changes: 2 additions & 2 deletions
4
...hold/login/repository/RoleRepository.java → ...khold/user/repository/RoleRepository.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
4 changes: 2 additions & 2 deletions
4
...hold/login/repository/UserRepository.java → ...khold/user/repository/UserRepository.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
2 changes: 1 addition & 1 deletion
2
...rkhold/login/service/SecurityService.java → ...arkhold/user/service/SecurityService.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
2 changes: 1 addition & 1 deletion
2
...ld/login/service/SecurityServiceImpl.java → ...old/user/service/SecurityServiceImpl.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
6 changes: 3 additions & 3 deletions
6
...login/service/UserDetailsServiceImpl.java → .../user/service/UserDetailsServiceImpl.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
6 changes: 3 additions & 3 deletions
6
...rkhold/login/validator/UserValidator.java → ...arkhold/user/validator/UserValidator.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.