access token excluded from refresh and logout
This commit is contained in:
parent
0dc93fcd16
commit
404a52473d
5 changed files with 27 additions and 28 deletions
|
|
@ -209,14 +209,15 @@ func (co *controller) login(c *gin.Context) {
|
|||
// @Failure 500 {object} responses.ErrorResponse500
|
||||
// @Router /user/logout [post]
|
||||
func (co *controller) logout(c *gin.Context) {
|
||||
userUuid, refreshUuid, err := co.utils.GetAllTokensFromContext(c)
|
||||
cookie, err := c.Request.Cookie("refresh_uuid")
|
||||
if err != nil {
|
||||
c.JSON(http.StatusBadRequest, responses.ErrorResponse400{Error: err.Error()})
|
||||
log.WithError(err).Error("User | Failed to get uuids from context on refresh")
|
||||
return
|
||||
log.WithError(err).Error("User | Failed to get refresh cookie")
|
||||
}
|
||||
|
||||
if err = co.service.logout(userUuid, refreshUuid); err != nil {
|
||||
refreshUuid := cookie.Value
|
||||
|
||||
if err = co.service.logout(refreshUuid); err != nil {
|
||||
c.JSON(http.StatusInternalServerError, responses.ErrorResponse500{Error: err.Error()})
|
||||
log.WithError(err).Error("User | Failed to logout")
|
||||
return
|
||||
|
|
@ -234,15 +235,15 @@ func (co *controller) logout(c *gin.Context) {
|
|||
// @Failure 500 {object} responses.ErrorResponse500
|
||||
// @Router /user/refresh [post]
|
||||
func (co *controller) refresh(c *gin.Context) {
|
||||
//токены будут помещены в контекст при срабатывании мидлвари авторизации
|
||||
userUuid, refreshUuid, err := co.utils.GetAllTokensFromContext(c)
|
||||
cookie, err := c.Request.Cookie("refresh_uuid")
|
||||
if err != nil {
|
||||
c.JSON(http.StatusBadRequest, responses.ErrorResponse400{Error: err.Error()})
|
||||
log.WithError(err).Error("User | Failed to get uuids from context on refresh")
|
||||
return
|
||||
log.WithError(err).Error("User | Failed to get refresh cookie")
|
||||
}
|
||||
|
||||
response, err := co.service.refresh(userUuid, refreshUuid)
|
||||
refreshUuid := cookie.Value
|
||||
|
||||
response, err := co.service.refresh(refreshUuid)
|
||||
if err != nil {
|
||||
c.JSON(http.StatusInternalServerError, responses.ErrorResponse500{Error: err.Error()})
|
||||
log.WithError(err).Error("User | Failed to refresh user info")
|
||||
|
|
|
|||
|
|
@ -120,10 +120,10 @@ func (s *service) login(login Login) (shared.AuthData, error) {
|
|||
return authData, nil
|
||||
}
|
||||
|
||||
func (s *service) logout(userUuid, refreshUuid string) error {
|
||||
return s.auth.Logout(userUuid, refreshUuid)
|
||||
func (s *service) logout(refreshUuid string) error {
|
||||
return s.auth.Logout(refreshUuid)
|
||||
}
|
||||
|
||||
func (s *service) refresh(userUuid, refreshUuid string) (shared.AuthData, error) {
|
||||
return s.auth.Refresh(userUuid, refreshUuid)
|
||||
func (s *service) refresh(refreshUuid string) (shared.AuthData, error) {
|
||||
return s.auth.Refresh(refreshUuid)
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue