feat: add AuthResponseDTO for login and refresh token responses
This commit is contained in:
23
internal/dto/auth_response.go
Normal file
23
internal/dto/auth_response.go
Normal file
@@ -0,0 +1,23 @@
|
|||||||
|
package dto
|
||||||
|
|
||||||
|
import (
|
||||||
|
"goyco/internal/services"
|
||||||
|
)
|
||||||
|
|
||||||
|
type AuthResponseDTO struct {
|
||||||
|
AccessToken string `json:"access_token"`
|
||||||
|
RefreshToken string `json:"refresh_token"`
|
||||||
|
User UserDTO `json:"user"`
|
||||||
|
}
|
||||||
|
|
||||||
|
func ToAuthResponseDTO(result *services.AuthResult) AuthResponseDTO {
|
||||||
|
if result == nil {
|
||||||
|
return AuthResponseDTO{}
|
||||||
|
}
|
||||||
|
|
||||||
|
return AuthResponseDTO{
|
||||||
|
AccessToken: result.AccessToken,
|
||||||
|
RefreshToken: result.RefreshToken,
|
||||||
|
User: ToUserDTO(result.User),
|
||||||
|
}
|
||||||
|
}
|
||||||
Reference in New Issue
Block a user