feat: 添加用户注册登录功能,实现数据和配置的用户隔离
- 新增 users 和 user_settings 表,repositories/analyses/review_notes 添加 user_id 列 - 实现基于邮箱+密码的注册登录,密码使用 bcrypt 哈希 - 使用 gin-contrib/sessions cookie-based session 管理 - 所有仓库、分析记录、review notes 按用户隔离 - 用户设置(LLM 配置、review 参数、缓存配置)独立存储 - 新增登录/注册页面,导航栏显示用户邮箱和退出按钮 - 前端 fetch 请求统一添加 credentials: 'same-origin' - 支持 SESSION_SECRET 环境变量配置会话密钥
This commit is contained in:
@@ -668,7 +668,7 @@ const DiffViewer = {
|
||||
|
||||
try {
|
||||
const url = `/api/repos/${repoId}/diff?base=${encodeURIComponent(base)}&head=${encodeURIComponent(head)}`;
|
||||
const resp = await fetch(url);
|
||||
const resp = await fetch(url, { credentials: 'same-origin' });
|
||||
if (!resp.ok) throw new Error('Failed to load diff');
|
||||
|
||||
const data = await resp.json();
|
||||
@@ -690,7 +690,7 @@ const DiffViewer = {
|
||||
|
||||
try {
|
||||
const url = `/api/repos/${repoId}/diff?base=${encodeURIComponent(base)}&head=${encodeURIComponent(head)}&per_file=true`;
|
||||
const resp = await fetch(url);
|
||||
const resp = await fetch(url, { credentials: 'same-origin' });
|
||||
if (!resp.ok) throw new Error('Failed to load diff');
|
||||
|
||||
const files = await resp.json();
|
||||
|
||||
+1
-1
@@ -37,7 +37,7 @@ const GitGraph = {
|
||||
|
||||
async load() {
|
||||
try {
|
||||
const resp = await fetch(`/api/repos/${this.repoId}/graph`);
|
||||
const resp = await fetch(`/api/repos/${this.repoId}/graph`, { credentials: 'same-origin' });
|
||||
if (!resp.ok) throw new Error('Failed to load graph');
|
||||
const data = await resp.json();
|
||||
|
||||
|
||||
@@ -31,7 +31,7 @@ const NoteEditor = {
|
||||
if (!this.analysisId) return;
|
||||
|
||||
try {
|
||||
const resp = await fetch(`/api/repos/${this.repoId}/review/notes?analysis_id=${this.analysisId}`);
|
||||
const resp = await fetch(`/api/repos/${this.repoId}/review/notes?analysis_id=${this.analysisId}`, { credentials: 'same-origin' });
|
||||
if (!resp.ok) return;
|
||||
const notes = await resp.json();
|
||||
|
||||
@@ -67,6 +67,7 @@ const NoteEditor = {
|
||||
const resp = await fetch(`/api/repos/${this.repoId}/review/notes`, {
|
||||
method: 'POST',
|
||||
headers: { 'Content-Type': 'application/json' },
|
||||
credentials: 'same-origin',
|
||||
body: JSON.stringify({
|
||||
analysis_id: this.analysisId,
|
||||
scope: scope,
|
||||
@@ -166,6 +167,7 @@ const NoteEditor = {
|
||||
const resp = await fetch(`/api/repos/${this.repoId}/review/pdf`, {
|
||||
method: 'POST',
|
||||
headers: { 'Content-Type': 'application/json' },
|
||||
credentials: 'same-origin',
|
||||
body: JSON.stringify({
|
||||
analysis_id: this.analysisId,
|
||||
base: document.getElementById('base-ref')?.value || '',
|
||||
|
||||
@@ -20,6 +20,7 @@ const SSE = {
|
||||
const resp = await fetch(url, {
|
||||
method: 'POST',
|
||||
headers: { 'Content-Type': 'application/json' },
|
||||
credentials: 'same-origin',
|
||||
body: JSON.stringify(body),
|
||||
signal: controller.signal,
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user