简体   繁体   中英

elixir guardian get current user in model

I can't get current logged in user in my model. There are many things which I wanna do with that. eg when a user creates a blog post, I want to associate with that user. User has many blog posts. There are many scenarios in which I need current user. One solution I can think of is to add a virtual field to all of my schemas after authentication assign current user to that virtual field. But I dont wanna repeat to add that virtual field to all of my models.

Note: this question has been asked before and someone tried to send a conn object to model which is discourged. Thanks in advance

这里看一个简单的教程, 这个教程也很不错。

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM