How to use api token in some enpoints #319
-
It's possiblem use api token in some requests? sample: // use api token in this request to create product |
Beta Was this translation helpful? Give feedback.
Answered by
kaplanelad
Jan 7, 2024
Replies: 1 comment
-
Hey, @enieber, yes, this is something that Loco provides already. go you your controller and add async fn products(
auth: auth::ApiToken<users::Model>,
State(_ctx): State<AppContext>,
) -> Result<Json<CurrentResponse>> {
...
} The It looks like we didn't document it at all. Nice catch! |
Beta Was this translation helpful? Give feedback.
0 replies
Answer selected by
enieber
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Hey, @enieber, yes, this is something that Loco provides already.
go you your controller and add
auth: auth::ApiToken<users::Model>
middleware into your controller.for example:
The
ApiToken
will check the user token.It looks like we didn't document it at all. Nice catch!
I have opened an issue for that #325