Skip to content

Commit d94d517

Browse files
committed
fix: return admin status when token didn't expire (closes #78)
1 parent f21ec6b commit d94d517

File tree

2 files changed

+6
-13
lines changed

2 files changed

+6
-13
lines changed

README.md

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -79,9 +79,9 @@
7979
- `POST /api/sign_in` - 用户登录
8080

8181
### 评论接口
82-
- `POST /api/db/add` - 发布评论
83-
- `GET /api/db/query` - 分页获取课程下的评论
84-
- `POST /api/db/history` - 获取我的评论历史
82+
- `POST /api/comment/add` - 发布评论
83+
- `GET /api/comment/query` - 分页获取课程下的评论
84+
- `POST /api/comment/history` - 获取我的评论历史
8585

8686
### 搜索接口
8787
- `GET /api/search/recent` - 获取搜索历史
@@ -103,7 +103,7 @@
103103
- Redis
104104

105105
### 配置文件
106-
项目需要一个 `etc/db.yaml` 配置文件,包含以下内容:
106+
项目需要一个 `etc/config.yaml` 配置文件,包含以下内容:
107107
```yaml
108108
Name: meowpick.backend
109109
Host: 0.0.0.0

application/service/auth.go

Lines changed: 2 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -108,6 +108,7 @@ func (s *AuthService) SignIn(ctx context.Context, req *dto.SignInReq) (Resp *dto
108108
AccessToken: existingToken,
109109
ExpiresIn: int64(time.Until(claims.ExpiresAt.Time).Seconds()),
110110
UserID: oldUser.ID,
111+
IsAdmin: oldUser.Admin,
111112
Resp: dto.Success(),
112113
}, nil
113114
}
@@ -122,20 +123,12 @@ func (s *AuthService) SignIn(ctx context.Context, req *dto.SignInReq) (Resp *dto
122123
return nil, errorx.WrapByCode(err, errno.ErrAuthTokenGenerateFailed)
123124
}
124125

125-
// 查看当前用户是否为管理员
126-
admin, err := s.UserRepo.IsAdminByID(ctx, oldUser.ID)
127-
if err != nil {
128-
logs.CtxErrorf(ctx, "[AuthRepo] [IsAdminByID] error: %v", err)
129-
return nil, errorx.WrapByCode(err, errno.ErrUserFindFailed,
130-
errorx.KV("key", consts.ReqOpenID), errorx.KV("value", openId))
131-
}
132-
133126
return &dto.SignInResp{
134127
Resp: dto.Success(),
135128
AccessToken: tokenStr,
136129
ExpiresIn: config.GetConfig().Auth.AccessExpire,
137130
UserID: oldUser.ID,
138-
IsAdmin: admin,
131+
IsAdmin: oldUser.Admin,
139132
}, nil
140133
}
141134

0 commit comments

Comments
 (0)