So it should be possible to delete and edit details of accounts.
Changes Implemented:
Created myAccount.html: Displays user account information such as username, password, and bio with Thymeleaf expressions (ex. th:text="${user.username}",th:text="${user.bio}"), although password is now encrypted. There's also a form for changing these fields when the user clicks Edit. There's a section with Delete Account and Logout buttons.
deleteAccount button: Deletes the user's account. Activated by a button press. There's a prompt asking if the user is sure beforehand (Cancel, OK).
editAccount.js: Contains the functions for changing from editing and viewing account details, and delete. editField(), 'cancelEdit()', 'deleteUser()', 'saveChanges()'.
myAccount.css: A stylesheet for myAccount.html. myAccount.html does also use style.css, but this css file has some style for buttons, bio text field, and left text alignment.
Created (@GetMapping("/myaccount")) in ArchiveController.java to fetch user details from the database with @AuthenticationPrincipal SecurityUser user. It's updated every time the page is reloaded so new account changes should display.
Created a UserUpdateRequest class for accepting updates. Contains fields like getUsername(),getBio(), like the User class.
Changed the updateUser function in UserController. It now accepts a @RequestBody UserUpdateRequest request along with the ID. Example of setting username: user.setUsername(request.getUsername());
Notes:
Both the delete account and edit account forms have hidden CSRF tokens. Included when the JavaScript functions fetch and communicate with the database.
Todo:
Implement a proper way to change passwords. Right now editing it changes the encoding and breaks the login 🗡️ so I don't recommend
UI changes. At least, when the bio and username fields are at max length the site looks a bit strange.
So it should be possible to delete and edit details of accounts.
Changes Implemented:
th:text="${user.username}"
,th:text="${user.bio}"
), although password is now encrypted. There's also a form for changing these fields when the user clicks Edit. There's a section with Delete Account and Logout buttons.deleteAccount
button: Deletes the user's account. Activated by a button press. There's a prompt asking if the user is sure beforehand (Cancel, OK).editField()
, 'cancelEdit()', 'deleteUser()', 'saveChanges()'.(@GetMapping("/myaccount"))
inArchiveController.java
to fetch user details from the database with@AuthenticationPrincipal SecurityUser user
. It's updated every time the page is reloaded so new account changes should display.UserUpdateRequest
class for accepting updates. Contains fields likegetUsername()
,getBio()
, like theUser
class.updateUser
function inUserController
. It now accepts a@RequestBody UserUpdateRequest request
along with the ID. Example of setting username:user.setUsername(request.getUsername());
Notes:
Todo: