Skip to content

Conversation

@lianjin
Copy link
Contributor

@lianjin lianjin commented Sep 26, 2025


name: Pull Request
about: user login/logout
labels: ["new feature"]

变更内容 | Changes

add login/logout API

相关 Issue | Related Issue

KAN-17 Customer Login

变更类型 | Type of Change

  • 新功能 Feature
  • 修复 Bug Fix
  • 文档 Documentation
  • 样式优化 Style
  • 重构 Refactor
  • 性能优化 Performance
  • 测试 Test
  • 构建/CI Build/CI
  • 其他 Other

检查清单 | Checklist

  • 代码已通过本地测试(含主流浏览器/终端)| Code tested locally (including major browsers/terminals)
  • 相关文档已更新(如有)| Documentation updated if needed
  • 代码风格符合项目规范 | Code style follows project conventions
  • 变更不会影响现有功能 | Changes do not break existing features
  • 已自查无敏感信息泄露 | No sensitive info is leaked

变更影响 | Impact

none

测试说明 | Test Instructions

  1. login using email=testuser@u.nus.edu, password=123456
  2. verify the response, cookie should be set with key=auth-token
  3. request logout, cookie should be eliminated
  4. logout with login will cause 401

其他说明 | Additional Notes

Copilot AI review requested due to automatic review settings September 26, 2025 05:45
Copy link

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull Request Overview

This PR implements user login/logout functionality for the ceramicraft-user-mservice with JWT token-based authentication. The implementation includes login/logout API endpoints, password hashing with bcrypt, JWT token generation/validation, and authentication middleware.

  • Adds login service with password verification and JWT token generation
  • Implements logout endpoint that invalidates auth tokens via cookies
  • Introduces authentication middleware for protected routes

Reviewed Changes

Copilot reviewed 22 out of 25 changed files in this pull request and generated 6 comments.

Show a summary per file
File Description
server/service/login.go Core login service implementation with JWT token generation
server/service/encrypt.go Password hashing and verification using bcrypt
server/http/api/login.go HTTP handlers for login/logout endpoints
common/utils/jwt_token.go JWT token generation and validation utilities
common/middleware/user_auth.go Authentication middleware for protected routes
server/repository/model/user.go Increases password field length to accommodate hashed passwords
server/http/router/router.go Registers login/logout routes with authentication middleware

Tip: Customize your code reviews with copilot-instructions.md. Create the file or learn how to get started.

@lianjin lianjin force-pushed the KAN-17-Customer-Login branch 2 times, most recently from 836ed4c to 0ecdfff Compare September 26, 2025 06:09
Copilot AI review requested due to automatic review settings September 26, 2025 06:09
Copy link

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull Request Overview

Copilot reviewed 23 out of 26 changed files in this pull request and generated 5 comments.


Tip: Customize your code reviews with copilot-instructions.md. Create the file or learn how to get started.

@lianjin lianjin force-pushed the KAN-17-Customer-Login branch from 0ecdfff to 0f3a4b4 Compare September 26, 2025 07:04
Copilot AI review requested due to automatic review settings September 26, 2025 07:16
@lianjin lianjin force-pushed the KAN-17-Customer-Login branch from 0f3a4b4 to 6c44d6c Compare September 26, 2025 07:16
Copy link

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull Request Overview

Copilot reviewed 25 out of 29 changed files in this pull request and generated 1 comment.


Tip: Customize your code reviews with copilot-instructions.md. Create the file or learn how to get started.

@lianjin lianjin force-pushed the KAN-17-Customer-Login branch from 6c44d6c to fccbf4e Compare September 26, 2025 07:25
Copilot AI review requested due to automatic review settings September 26, 2025 07:30
@lianjin lianjin force-pushed the KAN-17-Customer-Login branch from fccbf4e to 17acc4d Compare September 26, 2025 07:30
Copy link

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull Request Overview

Copilot reviewed 25 out of 29 changed files in this pull request and generated 1 comment.


Tip: Customize your code reviews with copilot-instructions.md. Create the file or learn how to get started.

@lianjin lianjin force-pushed the KAN-17-Customer-Login branch from 17acc4d to 12d2d49 Compare September 26, 2025 07:35
Copilot AI review requested due to automatic review settings September 26, 2025 07:39
@lianjin lianjin force-pushed the KAN-17-Customer-Login branch from 12d2d49 to 0fe75b7 Compare September 26, 2025 07:39
Copy link

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull Request Overview

Copilot reviewed 25 out of 29 changed files in this pull request and generated 2 comments.


Tip: Customize your code reviews with copilot-instructions.md. Create the file or learn how to get started.

@lianjin lianjin force-pushed the KAN-17-Customer-Login branch from 0fe75b7 to eaa0179 Compare September 26, 2025 07:41
Copilot AI review requested due to automatic review settings September 26, 2025 07:42
@lianjin lianjin force-pushed the KAN-17-Customer-Login branch from eaa0179 to 8c453ef Compare September 26, 2025 07:42
Copy link

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull Request Overview

Copilot reviewed 25 out of 29 changed files in this pull request and generated 2 comments.


Tip: Customize your code reviews with copilot-instructions.md. Create the file or learn how to get started.

@lianjin lianjin force-pushed the KAN-17-Customer-Login branch from 8c453ef to 2477edf Compare September 26, 2025 07:47
Copilot AI review requested due to automatic review settings September 26, 2025 07:48
@lianjin lianjin force-pushed the KAN-17-Customer-Login branch from 2477edf to 74061c6 Compare September 26, 2025 07:48
Copy link

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull Request Overview

Copilot reviewed 25 out of 29 changed files in this pull request and generated 1 comment.


Tip: Customize your code reviews with copilot-instructions.md. Create the file or learn how to get started.

@lianjin lianjin force-pushed the KAN-17-Customer-Login branch 2 times, most recently from 6b0f083 to ef93d55 Compare September 26, 2025 08:30
Copilot AI review requested due to automatic review settings September 26, 2025 08:30
Copy link

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull Request Overview

Copilot reviewed 25 out of 29 changed files in this pull request and generated 2 comments.


Tip: Customize your code reviews with copilot-instructions.md. Create the file or learn how to get started.

@lianjin lianjin force-pushed the KAN-17-Customer-Login branch from ef93d55 to ec86386 Compare September 26, 2025 08:37
Copilot AI review requested due to automatic review settings September 26, 2025 08:51
@lianjin lianjin force-pushed the KAN-17-Customer-Login branch from ec86386 to 3a26740 Compare September 26, 2025 08:51
Copy link

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull Request Overview

Copilot reviewed 26 out of 30 changed files in this pull request and generated 4 comments.


Tip: Customize your code reviews with copilot-instructions.md. Create the file or learn how to get started.

@lianjin lianjin force-pushed the KAN-17-Customer-Login branch from 3a26740 to f22b919 Compare September 26, 2025 09:12
Copilot AI review requested due to automatic review settings September 26, 2025 09:29
@lianjin lianjin force-pushed the KAN-17-Customer-Login branch from f22b919 to 79e30be Compare September 26, 2025 09:29
Copy link

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull Request Overview

Copilot reviewed 25 out of 29 changed files in this pull request and generated 2 comments.


Tip: Customize your code reviews with copilot-instructions.md. Create the file or learn how to get started.

@lianjin lianjin force-pushed the KAN-17-Customer-Login branch from 79e30be to 259227c Compare September 26, 2025 09:32
Copilot AI review requested due to automatic review settings September 26, 2025 09:37
@lianjin lianjin force-pushed the KAN-17-Customer-Login branch from 259227c to be4130c Compare September 26, 2025 09:37
Copy link

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull Request Overview

Copilot reviewed 25 out of 29 changed files in this pull request and generated 1 comment.


Tip: Customize your code reviews with copilot-instructions.md. Create the file or learn how to get started.

@lianjin lianjin force-pushed the KAN-17-Customer-Login branch 2 times, most recently from 623423b to 1b898ff Compare September 26, 2025 09:46
Copilot AI review requested due to automatic review settings September 26, 2025 09:46
Copy link

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull Request Overview

Copilot reviewed 26 out of 30 changed files in this pull request and generated 1 comment.


Tip: Customize your code reviews with copilot-instructions.md. Create the file or learn how to get started.

@lianjin lianjin force-pushed the KAN-17-Customer-Login branch from 1b898ff to 5b11815 Compare September 26, 2025 09:51
Copilot AI review requested due to automatic review settings September 26, 2025 09:57
@lianjin lianjin force-pushed the KAN-17-Customer-Login branch from 5b11815 to 4c163c2 Compare September 26, 2025 09:57
Copy link

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull Request Overview

Copilot reviewed 26 out of 30 changed files in this pull request and generated 2 comments.


Tip: Customize your code reviews with copilot-instructions.md. Create the file or learn how to get started.

Comment on lines +24 to +27
err := os.Setenv("JWT_SECRET", "TEST_SECRET_KEY")
if err != nil {
panic(err)
}
Copy link

Copilot AI Sep 26, 2025

Choose a reason for hiding this comment

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

Using panic in tests is not recommended. Consider using t.Fatal() or t.Fatalf() to properly handle test failures instead of panic.

Copilot uses AI. Check for mistakes.
@lianjin lianjin force-pushed the KAN-17-Customer-Login branch 2 times, most recently from 4738ab2 to a265008 Compare September 26, 2025 10:18
Copilot AI review requested due to automatic review settings September 26, 2025 10:18
Copy link

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull Request Overview

Copilot reviewed 26 out of 30 changed files in this pull request and generated no new comments.


Tip: Customize your code reviews with copilot-instructions.md. Create the file or learn how to get started.

@lianjin lianjin force-pushed the KAN-17-Customer-Login branch from a265008 to 74f26a7 Compare September 26, 2025 10:21
@yzcgg yzcgg merged commit 2b7e0e5 into main Sep 26, 2025
10 checks passed
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.

3 participants