soo im using spring boot with kotlin Entity ```@En...
# spring
n
soo im using spring boot with kotlin Entity
Copy code
@Entity
@Table(name="storypost")
class StoryPost(
        @Id @GeneratedValue(strategy = GenerationType.IDENTITY)
        @Column(name = "storypost_id")
        var id: Long,
        var body: String,
        var video_link: String,
        var image_link: String,
        var likes: Int,
        @ManyToOne(fetch = FetchType.EAGER)
        @JoinColumn(name = "userprofile_id")
        @JsonBackReference
        var userProfile: UserProfile?=null
)
Controller
Copy code
@RestController
class StoryPostController ( val repo : StoryPostRepositories){


    @GetMapping("/storypost")
    fun getAllStoryPosts() = repo.findAll().toList()

    @PostMapping("/storypost")
    fun addStoryPost(@RequestBody userPost : StoryPost) : ResponseEntity<StoryPost>{
        repo.save(userPost)
        return ResponseEntity<StoryPost>(userPost, HttpStatus.CREATED)
    }
}
how would I include the user id when making a storypost post request? should i just put another var
user_id: Long
and then have a
val repo2 : UserRepo
to find by id?
g
If I’m reading this properly. This seems to be less about Spring/Kotlin but generally how you’re doing authentication/authorization. In which case here are some articles that may be helpful. This uses Auth0 as your external provider though. https://auth0.com/blog/how-to-create-a-kotlin-app-and-secure-it-using-jwt/ https://auth0.com/blog/implementing-jwt-authentication-on-spring-boot/ You could also use Spring’s internal system also if you want that control yourself: https://spring.io/projects/spring-security-oauth