Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(auth): add user profile and password changing #966

Merged
merged 1 commit into from
Sep 2, 2024

Conversation

qwqcode
Copy link
Member

@qwqcode qwqcode commented Sep 2, 2024

closes #922

related to #942 #840 #279

This PR includes the following:

  • Added user profile and password change dialog interfaces to the artalk-auth-plugin.
  • Added a POST /user/profile HTTP API, allowing logged-in users to edit their profiles, including username, email, and website (also known as a link).
    • The API includes validation checks for the fields.
    • When the username is changed, the system checks if a user with the same combination of email and username already exists; if so, an error is returned.
    • When the email is changed, the system checks if the new email is already in use; if so, an error is returned.
    • Changing the email requires an additional code parameter for verifying the new email (which must be obtained by first calling POST /auth/email/send to send a verification code to the email).
  • The password change feature reuses the POST /auth/email/register API, which includes the functionality for password change (also known as password reset or forgotten password).
    • If the combination of username and email exists, the user's password will be updated; otherwise, a new user will be registered.
    • Before calling this API and changing the user's email, you must first call POST /auth/email/send to send a verification code to the email.

20240902_152839
20240902_152933


zh-CN

  • artalk-auth-plugin 增加 个人资料和密码修改对话框界面
  • 增加 POST /user/profile 的 HTTP API,允许已登录的用户对个人资料进行编辑,包括 用户名、邮箱、链接(又名website)。
    • 该接口包含字段合法性检测
    • 当用户的名称发生改变时会检查是否存在 邮箱和名称 组合相同的用户,如果存在则返回错误
    • 当用户邮箱发生改变时会检查是否使用了已存在的邮箱,如果存在则返回错误
    • 修改邮箱需要额外传递 code 参数,用于验证修改后的邮箱(需预先调用 POST /auth/email/send 向邮箱发送验证码)
  • 密码修改功能复用了 POST /auth/email/register 接口,该接口包含用户密码修改功能(又称密码重置、忘记密码)
    • 当用户名和邮箱组合存在时,会修改该用户的密码,反之注册新用户
    • 调用该接口前和修改用户邮箱一样,需预先调用 POST /auth/email/send 向邮箱发送验证码

Copy link

codecov bot commented Sep 2, 2024

Codecov Report

Attention: Patch coverage is 0% with 48 lines in your changes missing coverage. Please review.

Project coverage is 31.33%. Comparing base (5dc2752) to head (1331b9a).
Report is 1 commits behind head on master.

Files with missing lines Patch % Lines
server/handler/user_info_update.go 0.00% 47 Missing ⚠️
server/server.go 0.00% 1 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##           master     #966      +/-   ##
==========================================
- Coverage   31.47%   31.33%   -0.14%     
==========================================
  Files         204      205       +1     
  Lines        8728     8776      +48     
==========================================
+ Hits         2747     2750       +3     
- Misses       5827     5872      +45     
  Partials      154      154              
Flag Coverage Δ
go 31.33% <0.00%> (-0.14%) ⬇️

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@qwqcode qwqcode merged commit 4b5ec39 into master Sep 2, 2024
10 of 12 checks passed
@qwqcode qwqcode deleted the feat/auth/profile branch September 2, 2024 07:56
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[建议]:增加修改个人信息功能
1 participant