Skip to content

Commit

Permalink
Ignore password while serializaing json
Browse files Browse the repository at this point in the history
  • Loading branch information
bdmendes committed Nov 24, 2022
1 parent a335f95 commit f98fb20
Show file tree
Hide file tree
Showing 4 changed files with 6 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ import pt.up.fe.ni.website.backend.service.AuthService
@RestController
@RequestMapping("/auth")
class AuthController(val authService: AuthService) {
@PostMapping("/new_token")
@PostMapping("/new")
fun getNewToken(authentication: Authentication?): Map<String, String> {
if (authentication == null) {
throw ResponseStatusException(HttpStatus.BAD_REQUEST, "No credentials were provided")
Expand Down
2 changes: 2 additions & 0 deletions src/main/kotlin/pt/up/fe/ni/website/backend/model/Account.kt
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
package pt.up.fe.ni.website.backend.model

import com.fasterxml.jackson.annotation.JsonIgnore
import com.fasterxml.jackson.annotation.JsonProperty
import org.hibernate.validator.constraints.URL
import pt.up.fe.ni.website.backend.annotations.validation.NullOrNotBlank
Expand Down Expand Up @@ -30,6 +31,7 @@ class Account(
@field:Size(min = Constants.Name.minSize, max = Constants.Name.maxSize)
var name: String,

@JsonIgnore
@field:Size(min = Constants.Password.minSize, max = Constants.Password.maxSize)
var password: String,

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import java.util.Date
class AccountDto(
val email: String,
val password: String,
val name: String?,
val name: String,
val bio: String?,
val birthDate: Date?,
val photoPath: String?,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@ class AccountControllerTest @Autowired constructor(
val testAccount = Account(
"Test Account",
"test_account@test.com",
"test_password",
"This is a test account",
TestUtils.createDate(2001, Calendar.JULY, 28),
"https://test-photo.com",
Expand All @@ -56,6 +57,7 @@ class AccountControllerTest @Autowired constructor(
Account(
"Test Account 2",
"test_account2@test.com",
"test_password",
null,
null,
null,
Expand Down

0 comments on commit f98fb20

Please sign in to comment.