Last active
February 28, 2019 12:39
-
-
Save tuesd4y/09987336b659919f792d2b309a255b2c to your computer and use it in GitHub Desktop.
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
package at.triply.backend.eventbackend.security | |
import at.triply.backend.eventbackend.data.entities.EventManager | |
import at.triply.backend.eventbackend.data.repositories.EventManagerRepository | |
import org.springframework.data.rest.webmvc.BasePathAwareController | |
import org.springframework.http.ResponseEntity | |
import org.springframework.security.crypto.password.PasswordEncoder | |
import org.springframework.web.bind.annotation.PostMapping | |
import org.springframework.web.bind.annotation.RequestBody | |
import org.springframework.web.bind.annotation.RequestMapping | |
import org.springframework.web.bind.annotation.ResponseBody | |
@BasePathAwareController | |
@RequestMapping("/users") | |
class EventManagerController(val eventManagerRepository: EventManagerRepository, | |
val passwordEncoder: PasswordEncoder) { | |
@PostMapping("/signup") | |
@ResponseBody | |
fun signUp(@RequestBody user: EventManager): ResponseEntity<User> { | |
val encodedPassword = passwordEncoder.encode(user.password) | |
return ResponseEntity.ok( | |
eventManagerRepository.save(user.copy(password = encodedPassword)) | |
) | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment