mirror of
https://github.com/snowykami/neo-blog.git
synced 2025-09-26 02:56:22 +00:00
feat: Closes #14 更新用户模型,确保用户名字段为非空;优化OIDC请求和用户信息处理逻辑;添加新的重写规则以支持HTTPS
All checks were successful
Push to Helm Chart Repository / build (push) Successful in 19s
All checks were successful
Push to Helm Chart Repository / build (push) Successful in 19s
This commit is contained in:
@ -2,7 +2,6 @@ package v1
|
||||
|
||||
import (
|
||||
"context"
|
||||
"fmt"
|
||||
"strconv"
|
||||
|
||||
"github.com/cloudwego/hertz/pkg/app"
|
||||
@ -92,7 +91,6 @@ func (u *UserController) OidcLogin(ctx context.Context, c *app.RequestContext) {
|
||||
if redirectUri == "" {
|
||||
redirectUri = "/"
|
||||
}
|
||||
fmt.Println("redirectBack:", redirectUri)
|
||||
oidcLoginReq := &dto.OidcLoginReq{
|
||||
Name: name,
|
||||
Code: code,
|
||||
|
@ -7,7 +7,7 @@ import (
|
||||
|
||||
type User struct {
|
||||
gorm.Model
|
||||
Username string `gorm:"uniqueIndex"` // 用户名,唯一
|
||||
Username string `gorm:"uniqueIndex;not null"` // 用户名,唯一
|
||||
Nickname string
|
||||
AvatarUrl string
|
||||
Email string `gorm:"uniqueIndex"`
|
||||
|
@ -275,8 +275,9 @@ func (s *UserService) OidcLogin(req *dto.OidcLoginReq) (*dto.OidcLoginResp, erro
|
||||
}
|
||||
return resp, nil
|
||||
} else {
|
||||
// 第一次登录,创建新用户时才获取头像
|
||||
user = &model.User{
|
||||
Username: userInfo.Name,
|
||||
Username: userInfo.PreferredUsername,
|
||||
Nickname: userInfo.Name,
|
||||
AvatarUrl: userInfo.Picture,
|
||||
Email: userInfo.Email,
|
||||
|
@ -64,5 +64,6 @@ type UserInfo struct {
|
||||
Name string `json:"name"`
|
||||
Email string `json:"email"`
|
||||
Picture string `json:"picture,omitempty"`
|
||||
PreferredUsername string `json:"preferred_username"`
|
||||
Groups []string `json:"groups,omitempty"` // 可选字段,OIDC提供的用户组信息
|
||||
}
|
||||
|
@ -18,6 +18,12 @@ const nextConfig: NextConfig = {
|
||||
port: '',
|
||||
pathname: '/**',
|
||||
},
|
||||
{
|
||||
protocol: 'https',
|
||||
hostname: 'pass.liteyuki.org',
|
||||
port: '',
|
||||
pathname: '/**',
|
||||
},
|
||||
],
|
||||
},
|
||||
async rewrites() {
|
||||
|
@ -166,7 +166,7 @@ export function CommentItem(
|
||||
<div className="flex-1 pl-2 fade-in-up">
|
||||
<div className="flex gap-2 md:gap-4 items-center">
|
||||
<div onClick={() => clickToUserProfile(commentState.user.username)} className="font-bold text-base text-slate-800 dark:text-slate-100 cursor-pointer fade-in-up">
|
||||
{commentState.user.nickname}
|
||||
{commentState.user.nickname || commentState.user.username}
|
||||
</div>
|
||||
<span className="text-xs">{formatDateTime({
|
||||
dateTimeString: commentState.createdAt,
|
||||
|
Reference in New Issue
Block a user