Skip to content

Feat/login api rework#61

Merged
kazetani-SE merged 17 commits into
mainfrom
feat/login-api-rework
May 24, 2026
Merged

Feat/login api rework#61
kazetani-SE merged 17 commits into
mainfrom
feat/login-api-rework

Conversation

@kazetani-SE

Copy link
Copy Markdown
Contributor

No description provided.

@kazetani-SE kazetani-SE linked an issue May 17, 2026 that may be closed by this pull request
@kazetani-SE
kazetani-SE requested review from akagiyuu and patohru May 17, 2026 10:11
Comment thread internal/http/auth.handler.go Outdated
@kazetani-SE
kazetani-SE requested a review from patohru May 18, 2026 12:05
Comment thread internal/auth/auth.service.go Outdated
Comment on lines +25 to +30
type LoginResult struct {
AccessToken string
Name string
Email string
Role string
}

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

define UserBasicProfile struct (with json tag) here, and rename LoginResult to

struct AuthResponse {
    AccessToken string `json.....
    UserProfile UserBasicProfile ....
}

also define the role enum again here instead of using string

we do this to prevent mapping between service type and dto type when not needed

Comment thread internal/http/user.dto.go Outdated
Comment on lines +1 to +7
package http

type UserBasicProfile struct {
Email string `json:"email"`
Name string `json:"name"`
Role string `json:"role"`
}

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

remove this

Comment thread internal/http/auth.dto.go Outdated
Comment on lines +24 to +28
type LoginResponse struct {
AccessToken string `json:"access_token"`
UserProfile UserBasicProfile `json:"user_basic_profile"`
}

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

remove this

Comment thread internal/http/auth.dto.go Outdated
Comment on lines +53 to +56
func (l *LoginResponse) OutTransform(ctx context.Context) error {
l.AccessToken = strings.TrimSpace(l.AccessToken)
return nil
}

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

the out transform to trim token is not needed since token cant contain space

@kazetani-SE
kazetani-SE requested a review from akagiyuu May 19, 2026 08:47
Comment thread internal/auth/token.service.go
Comment thread internal/auth/token.service.go Outdated
Comment on lines +16 to +18
type Claims struct {
jwt.RegisteredClaims
}

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

why not create the inner claims directly?

Comment thread internal/auth/auth.service.go Outdated
return nil
}

func (s *AuthService) Login(ctx context.Context, email string, password string) (AuthResponse, error) {

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

use *AuthResponse instead of AuthResponse to simplify code

Comment thread internal/http/auth.handler.go Outdated

func (s *Server) LoginHandler(
c fuego.ContextWithBody[LoginRequest],
) (auth.AuthResponse, error) {

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

use *auth.AuthResponse instead

Comment thread internal/http/auth.handler.go Outdated
return auth.AuthResponse{}, err
}

authResponse, err := s.auth.Login(

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

rename authResponse to response since we are in auth the auth prefix is redundant

Comment thread internal/auth/auth.service.go Outdated
return nil
}

func (s *AuthService) Login(ctx context.Context, email string, password string) (AuthResponse, error) {

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

use *AuthResponse instead of AuthResponse to simplify code

Comment thread internal/auth/token.service.go Outdated
Comment on lines +20 to +23
var (
ErrSigningMethod = errors.New("unexpected signing method")
ErrInvalidClaims = errors.New("invalid token claims")
)

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

what are these errors used for?

@kazetani-SE
kazetani-SE requested a review from akagiyuu May 20, 2026 08:49
@kazetani-SE
kazetani-SE merged commit e8e1128 into main May 24, 2026
3 checks passed
@kazetani-SE
kazetani-SE deleted the feat/login-api-rework branch May 24, 2026 04:08
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Implement login API

3 participants