System of Cookies with your Auth System should be in Controller or maybe Service?
Where i should put logic of Cookie System? Thanks in advance
19 Replies
⌛ This post has been reserved for your question.
Hey @L4yoos! Please useTIP: Narrow down your issue to simple and precise questions to maximize the chance that others will reply in here./closeor theClose Postbutton above when your problem is solved. Please remember to follow the help guidelines. This post will be automatically marked as dormant after 300 minutes of inactivity.
you probably want to handle authentication in some filter or similar
I have something like JwtAuthFilter, but I have moved the whole cookie system to CookieService but still call it in the controller to avoid flipping HttpServletRequest, HttpServletResponse between:
service -> service
only controller -> service
Smth like this
Services shouldn't depend on things like HTTP/requests
I see, so how can I improve the cookie system?
password checking, retrieving the user etc should be done in a service or with Spring security things
but if you need a login endpoint (which you might not need with Spring Security), you can do the HTTP stuff in the controller
i know it, but to me it's about the cookie system, you as an experienced senior (I think) as if you would go to such a thing as a cookie system?
Are you using Spring Security?
Yep
maybe i'm stupid and don't understand something hahah
What do you need from the request?
parameters I guess?
u asking about LoginRequest?
yes
so only email and password right now
Can you show
LoginRequest?
The setAuthCookies should be in the controller layer
okey so i shouldn't build a cookie service
and just build private methods in controller, yep?
you can still use a class for it if applicable
but not in the service layer because it's dependent on HTTP/cookies and not business logic
okey i get it
thanks!
If you are finished with your post, please close it.
If you are not, please ignore this message.
Note that you will not be able to send further messages here after this post have been closed but you will be able to create new posts.
Post Closed
This post has been closed by <@414343997562290177>.