Package se.bth.pulse.controller
Class SetupRestController
java.lang.Object
se.bth.pulse.controller.SetupRestController
This class is a rest controller that serves the setup page. The page is only accessible if the
setup is not done. It is used to configure the application. Specifically, it is used to: -
configure the settings - configure the admin account - configure the admin role - configure the
default role
-
Constructor Summary
ConstructorsConstructorDescriptionSetupRestController
(SettingRepository settingRepository, UserRepository userRepository, RoleRepository roleRepository, AuthorityRepository authorityRepository) Sets the repositories using dependency injection. -
Method Summary
Modifier and TypeMethodDescriptionorg.springframework.http.ResponseEntity<Object>
configureAdminAccount
(String email, String password) Configures the admin account and saves it to the database.Simple method to check if the setup is done.
-
Constructor Details
-
SetupRestController
public SetupRestController(SettingRepository settingRepository, UserRepository userRepository, RoleRepository roleRepository, AuthorityRepository authorityRepository) Sets the repositories using dependency injection. Spring automatically creates instances of the repositories then passes them to the constructor.- Parameters:
settingRepository
- - used to interact with the table Setting.userRepository
- - used to interact with the table User.roleRepository
- - used to interact with the table Role.
-
-
Method Details
-
configureSetting
Simple method to check if the setup is done.- Returns:
- Boolean - true if the setup is done, false otherwise.
-
configureAdminAccount
@PostMapping(value="/api/setup/configure_admin_account", produces="application/json") public org.springframework.http.ResponseEntity<Object> configureAdminAccount(@RequestParam("email") String email, @RequestParam("password") String password) Configures the admin account and saves it to the database. The admin account is used to log in to the application.- Parameters:
email
- - the email of the admin accountpassword
- - the password of the admin account- Returns:
- ResponseEntity - A response entity with the admin account if the account was created successfully, an error message otherwise. The response entity is used to return a JSON object.
-