@urga-panel/ur-panels-core 1.0.5 → 1.0.7
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/ServiceManager.js +4 -0
- package/dist/TestRun.d.ts +1 -1
- package/dist/TestRun.js +1 -1
- package/dist/commands/createDB.d.ts +2 -0
- package/dist/commands/createDB.js +47 -0
- package/dist/commands/createTS.d.ts +2 -0
- package/dist/commands/createTS.js +29 -0
- package/dist/services/abstract/authServices/AuthService.d.ts +1 -0
- package/dist/services/abstract/authServices/AuthService.js +20 -12
- package/package.json +6 -3
- package/src/ServiceManager.ts +4 -0
- package/src/TestRun.ts +1 -1
- package/src/commands/createDB.ts +59 -0
- package/src/commands/createTS.ts +35 -0
- package/src/services/abstract/authServices/AuthService.ts +34 -13
package/dist/ServiceManager.js
CHANGED
|
@@ -123,6 +123,7 @@ export class _ServiceManager {
|
|
|
123
123
|
// await _PageControllerService.start();
|
|
124
124
|
}
|
|
125
125
|
const createdServices = [];
|
|
126
|
+
const _this = this;
|
|
126
127
|
for (const serviceInfo of services) {
|
|
127
128
|
const { serviceName, service, tag, dynamicTag, isAbstract, requiredServices } = serviceInfo;
|
|
128
129
|
// Fill usedService according to requiredServices
|
|
@@ -145,6 +146,7 @@ export class _ServiceManager {
|
|
|
145
146
|
usedService,
|
|
146
147
|
tag: tag,
|
|
147
148
|
type: type,
|
|
149
|
+
ServiceManager: _this,
|
|
148
150
|
abilities: {
|
|
149
151
|
createChildService: (tag, PageCtor) => {
|
|
150
152
|
//console.log("createChildService called for ---", tag);
|
|
@@ -154,6 +156,8 @@ export class _ServiceManager {
|
|
|
154
156
|
usedService: {},
|
|
155
157
|
tag: tag,
|
|
156
158
|
type: type,
|
|
159
|
+
//@ts-ignore
|
|
160
|
+
ServiceManager: _this
|
|
157
161
|
}),
|
|
158
162
|
status: "waitSetup",
|
|
159
163
|
});
|
package/dist/TestRun.d.ts
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
|
|
1
|
+
declare function main(): Promise<void>;
|
package/dist/TestRun.js
CHANGED
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
import fs from 'fs';
|
|
3
|
+
import path from 'path';
|
|
4
|
+
import { MongoClient } from 'mongodb';
|
|
5
|
+
async function createMongoDB() {
|
|
6
|
+
const baseDir = process.cwd();
|
|
7
|
+
const databasePath = path.join(baseDir, 'src', 'project', 'database');
|
|
8
|
+
// MongoDB bağlantısı
|
|
9
|
+
const uri = 'mongodb://localhost:27017'; // kendi bağlantını yaz
|
|
10
|
+
const client = new MongoClient(uri);
|
|
11
|
+
await client.connect();
|
|
12
|
+
// Database klasörlerini al
|
|
13
|
+
const dbFolders = fs.readdirSync(databasePath, { withFileTypes: true })
|
|
14
|
+
.filter(f => f.isDirectory())
|
|
15
|
+
.map(f => f.name);
|
|
16
|
+
for (const dbName of dbFolders) {
|
|
17
|
+
//const db = client.db(dbName); // klasör adı database ismi
|
|
18
|
+
const entitiesPath = path.join(databasePath, dbName, 'Entities');
|
|
19
|
+
if (!fs.existsSync(entitiesPath))
|
|
20
|
+
continue;
|
|
21
|
+
// 1. Eğer varsa önceki veritabanını sil
|
|
22
|
+
const oldDb = client.db(dbName);
|
|
23
|
+
await oldDb.dropDatabase();
|
|
24
|
+
console.log(`🗑️ ${dbName} veritabanı silindi.`);
|
|
25
|
+
// 2. Aynı isimle yeni veritabanı oluştur
|
|
26
|
+
const newDb = client.db(dbName);
|
|
27
|
+
const files = fs.readdirSync(entitiesPath).filter(f => f.endsWith('.json'));
|
|
28
|
+
for (const file of files) {
|
|
29
|
+
const collectionName = file.replace('.json', '');
|
|
30
|
+
const collection = await newDb.createCollection(collectionName);
|
|
31
|
+
//JSON dosyasını oku
|
|
32
|
+
const data = JSON.parse(fs.readFileSync(path.join(entitiesPath, file), 'utf-8'));
|
|
33
|
+
// Tek obje veya array olabilir
|
|
34
|
+
/*
|
|
35
|
+
const docs = Array.isArray(data) ? data : [data];
|
|
36
|
+
|
|
37
|
+
// Collection’a ekle
|
|
38
|
+
if (docs.length > 0) {
|
|
39
|
+
await collection.insertMany(docs);
|
|
40
|
+
console.log(`Inserted ${docs.length} docs into ${dbName}.${collectionName}`);
|
|
41
|
+
}*/
|
|
42
|
+
}
|
|
43
|
+
}
|
|
44
|
+
await client.close();
|
|
45
|
+
console.log('All databases and collections created!');
|
|
46
|
+
}
|
|
47
|
+
createMongoDB().catch(console.error);
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
import fs from 'fs';
|
|
3
|
+
import path from 'path';
|
|
4
|
+
import { execSync } from 'child_process';
|
|
5
|
+
async function createInterfaces() {
|
|
6
|
+
const baseDir = process.cwd();
|
|
7
|
+
const databasePath = path.join(baseDir, 'src', 'project', 'database');
|
|
8
|
+
// Database içindeki tüm klasörleri al
|
|
9
|
+
const entityFolders = fs.readdirSync(databasePath, { withFileTypes: true })
|
|
10
|
+
.filter(f => f.isDirectory())
|
|
11
|
+
.map(f => f.name);
|
|
12
|
+
for (const folder of entityFolders) {
|
|
13
|
+
const entitiesPath = path.join(databasePath, folder, 'Entities');
|
|
14
|
+
const interfacePath = path.join(databasePath, folder, 'Interface');
|
|
15
|
+
if (!fs.existsSync(entitiesPath))
|
|
16
|
+
continue; // Entities klasörü yoksa atla
|
|
17
|
+
if (!fs.existsSync(interfacePath))
|
|
18
|
+
fs.mkdirSync(interfacePath, { recursive: true });
|
|
19
|
+
const files = fs.readdirSync(entitiesPath).filter(f => f.endsWith('.json'));
|
|
20
|
+
for (const file of files) {
|
|
21
|
+
const input = path.join(entitiesPath, file);
|
|
22
|
+
const output = path.join(interfacePath, file.replace('.json', '.d.ts'));
|
|
23
|
+
console.log(`Converting ${folder}/${file} -> ${folder}/Interface/${path.basename(output)}`);
|
|
24
|
+
execSync(`json2ts -i "${input}" -o "${output}"`, { stdio: 'inherit' });
|
|
25
|
+
}
|
|
26
|
+
}
|
|
27
|
+
console.log('All JSON files converted to TypeScript interfaces.');
|
|
28
|
+
}
|
|
29
|
+
createInterfaces().catch(console.error);
|
|
@@ -101,24 +101,29 @@ export class AuthService extends Service {
|
|
|
101
101
|
id: result.user.id,
|
|
102
102
|
username: result.user.username,
|
|
103
103
|
role: result.user.role,
|
|
104
|
-
databaseId: result.user.databaseId
|
|
104
|
+
databaseId: result.user.databaseId,
|
|
105
|
+
databases: result.user.databases // databaseId eklendi
|
|
105
106
|
}, JWT_SECRET, { expiresIn: '15m' });
|
|
106
107
|
// 5. Refresh Token üret
|
|
107
108
|
const refreshToken = jwt.sign({
|
|
108
109
|
id: result.user.id,
|
|
109
110
|
username: result.user.username,
|
|
110
111
|
role: result.user.role,
|
|
111
|
-
databaseId: result.user.databaseId
|
|
112
|
+
databaseId: result.user.databaseId,
|
|
113
|
+
databases: result.user.databases // databaseId eklendi
|
|
112
114
|
}, JWT_REFRESH_SECRET, { expiresIn: '7d' });
|
|
113
|
-
//
|
|
114
|
-
|
|
115
|
-
|
|
115
|
+
// --- ENVIRONMENT-BASED COOKIE SETTINGS ---
|
|
116
|
+
const isProd = process.env.NODE_ENV === 'production';
|
|
117
|
+
const domain = isProd ? '.urpanels.com' : '.local.test';
|
|
118
|
+
const secure = isProd ? 'Secure; ' : '';
|
|
119
|
+
const sameSite = isProd ? 'Strict' : 'Lax';
|
|
120
|
+
const headers = new Headers();
|
|
121
|
+
headers.append("Set-Cookie", `accessToken=${accessToken}; Path=/; Domain=${domain}; ${secure}HttpOnly; SameSite=${sameSite}; Max-Age=900`);
|
|
122
|
+
headers.append("Set-Cookie", `refreshToken=${refreshToken}; Path=/; Domain=${domain}; ${secure}HttpOnly; SameSite=${sameSite}; Max-Age=604800`);
|
|
123
|
+
headers.append("Content-Type", `application/json`);
|
|
116
124
|
return new Response(JSON.stringify({ status: "success", message: "valid credentials", data: { user: result.user } }), {
|
|
117
125
|
status: 200,
|
|
118
|
-
headers:
|
|
119
|
-
"Set-Cookie": `accessToken=${accessToken}; Path=/; HttpOnly; Secure; SameSite=Strict; Max-Age=900, refreshToken=${refreshToken}; Path=/; HttpOnly; Secure; SameSite=Strict; Max-Age=604800`,
|
|
120
|
-
'Content-Type': 'application/json'
|
|
121
|
-
}
|
|
126
|
+
headers: headers
|
|
122
127
|
});
|
|
123
128
|
}
|
|
124
129
|
return this.resposeHandler({ status: "fail", message: "Invalid credentials" });
|
|
@@ -190,13 +195,15 @@ export class AuthService extends Service {
|
|
|
190
195
|
id: decodedRefresh.id,
|
|
191
196
|
username: decodedRefresh.username,
|
|
192
197
|
role: decodedRefresh.role,
|
|
193
|
-
databaseId: decodedRefresh.databaseId // databaseId eklendi
|
|
198
|
+
databaseId: decodedRefresh.databaseId, // databaseId eklendi
|
|
199
|
+
databases: decodedRefresh.databases // databases eklendi
|
|
194
200
|
}, JWT_SECRET, { expiresIn: '15m' });
|
|
195
201
|
const newRefreshToken = jwt.sign({
|
|
196
202
|
id: decodedRefresh.id,
|
|
197
203
|
username: decodedRefresh.username,
|
|
198
204
|
role: decodedRefresh.role,
|
|
199
|
-
databaseId: decodedRefresh.databaseId // databaseId eklendi
|
|
205
|
+
databaseId: decodedRefresh.databaseId, // databaseId eklendi
|
|
206
|
+
databases: decodedRefresh.databases // databases eklendi
|
|
200
207
|
}, JWT_REFRESH_SECRET, { expiresIn: '7d' });
|
|
201
208
|
return { valid: true, newAccessToken, newRefreshToken, user: res.user };
|
|
202
209
|
}
|
|
@@ -242,7 +249,8 @@ export class AuthService extends Service {
|
|
|
242
249
|
id: user?.id || null,
|
|
243
250
|
username: user?.username || null,
|
|
244
251
|
role: user?.role || null,
|
|
245
|
-
databaseId: user?.databaseId || null // databaseId eklendi
|
|
252
|
+
databaseId: user?.databaseId || null, // databaseId eklendi
|
|
253
|
+
databases: user?.databases || null // databases eklendi
|
|
246
254
|
}
|
|
247
255
|
}
|
|
248
256
|
});
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@urga-panel/ur-panels-core",
|
|
3
|
-
"version": "1.0.
|
|
3
|
+
"version": "1.0.7",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"main": "dist/index.js",
|
|
6
6
|
"types": "dist/index.d.ts",
|
|
@@ -9,7 +9,7 @@
|
|
|
9
9
|
"test": "jest",
|
|
10
10
|
"lint": "eslint src --ext .ts",
|
|
11
11
|
"start": "npx cross-env MODE=DEBUG ts-node src/TestRun.ts",
|
|
12
|
-
"addServiceStatic": "npx ts-node src/
|
|
12
|
+
"addServiceStatic": "npx ts-node src/TestRun.ts"
|
|
13
13
|
},
|
|
14
14
|
"devDependencies": {
|
|
15
15
|
"@types/jest": "^29.0.0",
|
|
@@ -27,9 +27,12 @@
|
|
|
27
27
|
"bcryptjs": "^3.0.2",
|
|
28
28
|
"js-yaml": "^4.1.0",
|
|
29
29
|
"jsonwebtoken": "^9.0.2",
|
|
30
|
+
"mongodb": "^6.19.0",
|
|
30
31
|
"yargs": "^18.0.0"
|
|
31
32
|
},
|
|
32
33
|
"bin": {
|
|
33
|
-
"urga-core-cli": "dist/
|
|
34
|
+
"urga-core-cli": "dist/TestRun.js",
|
|
35
|
+
"createTS": "dist/commands/createTS.js",
|
|
36
|
+
"createDB": "dist/commands/createDB.js"
|
|
34
37
|
}
|
|
35
38
|
}
|
package/src/ServiceManager.ts
CHANGED
|
@@ -142,6 +142,7 @@ export class _ServiceManager {
|
|
|
142
142
|
// await _PageControllerService.start();
|
|
143
143
|
}
|
|
144
144
|
const createdServices: Service[] = [];
|
|
145
|
+
const _this = this;
|
|
145
146
|
for (const serviceInfo of services) {
|
|
146
147
|
const { serviceName, service, tag, dynamicTag, isAbstract, requiredServices } = serviceInfo;
|
|
147
148
|
// Fill usedService according to requiredServices
|
|
@@ -164,6 +165,7 @@ export class _ServiceManager {
|
|
|
164
165
|
usedService,
|
|
165
166
|
tag: tag,
|
|
166
167
|
type: type,
|
|
168
|
+
ServiceManager: _this,
|
|
167
169
|
abilities: {
|
|
168
170
|
createChildService: (tag: string, PageCtor?: ServiceConstructor<Service>) => {
|
|
169
171
|
//console.log("createChildService called for ---", tag);
|
|
@@ -173,6 +175,8 @@ export class _ServiceManager {
|
|
|
173
175
|
usedService: {},
|
|
174
176
|
tag: tag,
|
|
175
177
|
type: type,
|
|
178
|
+
//@ts-ignore
|
|
179
|
+
ServiceManager: _this
|
|
176
180
|
}),
|
|
177
181
|
status: "waitSetup",
|
|
178
182
|
});
|
package/src/TestRun.ts
CHANGED
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
import { ServiceManager } from './ServiceManager';
|
|
2
1
|
|
|
3
2
|
async function main() {
|
|
4
3
|
//const serviceManager = new ServiceManager();
|
|
@@ -12,6 +11,7 @@ async function main() {
|
|
|
12
11
|
// LayoutService: _service
|
|
13
12
|
// }
|
|
14
13
|
// );
|
|
14
|
+
console.log("Services initialized2222");
|
|
15
15
|
}
|
|
16
16
|
|
|
17
17
|
main().catch(console.error);
|
|
@@ -0,0 +1,59 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
import fs from 'fs';
|
|
3
|
+
import path from 'path';
|
|
4
|
+
import { MongoClient } from 'mongodb';
|
|
5
|
+
|
|
6
|
+
async function createMongoDB() {
|
|
7
|
+
const baseDir = process.cwd();
|
|
8
|
+
const databasePath = path.join(baseDir, 'src', 'project', 'database');
|
|
9
|
+
|
|
10
|
+
// MongoDB bağlantısı
|
|
11
|
+
const uri = 'mongodb://localhost:27017'; // kendi bağlantını yaz
|
|
12
|
+
const client = new MongoClient(uri);
|
|
13
|
+
await client.connect();
|
|
14
|
+
|
|
15
|
+
// Database klasörlerini al
|
|
16
|
+
const dbFolders = fs.readdirSync(databasePath, { withFileTypes: true })
|
|
17
|
+
.filter(f => f.isDirectory())
|
|
18
|
+
.map(f => f.name);
|
|
19
|
+
|
|
20
|
+
for (const dbName of dbFolders) {
|
|
21
|
+
//const db = client.db(dbName); // klasör adı database ismi
|
|
22
|
+
const entitiesPath = path.join(databasePath, dbName, 'Entities');
|
|
23
|
+
if (!fs.existsSync(entitiesPath)) continue;
|
|
24
|
+
|
|
25
|
+
|
|
26
|
+
// 1. Eğer varsa önceki veritabanını sil
|
|
27
|
+
const oldDb = client.db(dbName);
|
|
28
|
+
await oldDb.dropDatabase();
|
|
29
|
+
console.log(`🗑️ ${dbName} veritabanı silindi.`);
|
|
30
|
+
|
|
31
|
+
// 2. Aynı isimle yeni veritabanı oluştur
|
|
32
|
+
const newDb = client.db(dbName);
|
|
33
|
+
|
|
34
|
+
const files = fs.readdirSync(entitiesPath).filter(f => f.endsWith('.json'));
|
|
35
|
+
|
|
36
|
+
for (const file of files) {
|
|
37
|
+
const collectionName = file.replace('.json', '');
|
|
38
|
+
const collection = await newDb.createCollection(collectionName);
|
|
39
|
+
|
|
40
|
+
//JSON dosyasını oku
|
|
41
|
+
const data = JSON.parse(fs.readFileSync(path.join(entitiesPath, file), 'utf-8'));
|
|
42
|
+
|
|
43
|
+
// Tek obje veya array olabilir
|
|
44
|
+
/*
|
|
45
|
+
const docs = Array.isArray(data) ? data : [data];
|
|
46
|
+
|
|
47
|
+
// Collection’a ekle
|
|
48
|
+
if (docs.length > 0) {
|
|
49
|
+
await collection.insertMany(docs);
|
|
50
|
+
console.log(`Inserted ${docs.length} docs into ${dbName}.${collectionName}`);
|
|
51
|
+
}*/
|
|
52
|
+
}
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
await client.close();
|
|
56
|
+
console.log('All databases and collections created!');
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
createMongoDB().catch(console.error);
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
import fs from 'fs';
|
|
3
|
+
import path from 'path';
|
|
4
|
+
import { execSync } from 'child_process';
|
|
5
|
+
|
|
6
|
+
async function createInterfaces() {
|
|
7
|
+
const baseDir = process.cwd();
|
|
8
|
+
const databasePath = path.join(baseDir, 'src', 'project', 'database');
|
|
9
|
+
|
|
10
|
+
// Database içindeki tüm klasörleri al
|
|
11
|
+
const entityFolders = fs.readdirSync(databasePath, { withFileTypes: true })
|
|
12
|
+
.filter(f => f.isDirectory())
|
|
13
|
+
.map(f => f.name);
|
|
14
|
+
|
|
15
|
+
for (const folder of entityFolders) {
|
|
16
|
+
const entitiesPath = path.join(databasePath, folder, 'Entities');
|
|
17
|
+
const interfacePath = path.join(databasePath, folder, 'Interface');
|
|
18
|
+
|
|
19
|
+
if (!fs.existsSync(entitiesPath)) continue; // Entities klasörü yoksa atla
|
|
20
|
+
if (!fs.existsSync(interfacePath)) fs.mkdirSync(interfacePath, { recursive: true });
|
|
21
|
+
|
|
22
|
+
const files = fs.readdirSync(entitiesPath).filter(f => f.endsWith('.json'));
|
|
23
|
+
|
|
24
|
+
for (const file of files) {
|
|
25
|
+
const input = path.join(entitiesPath, file);
|
|
26
|
+
const output = path.join(interfacePath, file.replace('.json', '.d.ts'));
|
|
27
|
+
console.log(`Converting ${folder}/${file} -> ${folder}/Interface/${path.basename(output)}`);
|
|
28
|
+
execSync(`json2ts -i "${input}" -o "${output}"`, { stdio: 'inherit' });
|
|
29
|
+
}
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
console.log('All JSON files converted to TypeScript interfaces.');
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
createInterfaces().catch(console.error);
|
|
@@ -79,6 +79,7 @@ export abstract class AuthService extends Service {
|
|
|
79
79
|
password: string; // Optional password field for internal use
|
|
80
80
|
role?: string; // Optional role field
|
|
81
81
|
databaseId?: string; // Optional database ID field
|
|
82
|
+
databases?: string[]; // Optional databases field
|
|
82
83
|
};
|
|
83
84
|
}>;
|
|
84
85
|
|
|
@@ -153,7 +154,8 @@ export abstract class AuthService extends Service {
|
|
|
153
154
|
id: result.user.id,
|
|
154
155
|
username: result.user.username,
|
|
155
156
|
role: result.user.role,
|
|
156
|
-
databaseId: result.user.databaseId
|
|
157
|
+
databaseId: result.user.databaseId,
|
|
158
|
+
databases: result.user.databases // databaseId eklendi
|
|
157
159
|
},
|
|
158
160
|
JWT_SECRET,
|
|
159
161
|
{ expiresIn: '15m' }
|
|
@@ -165,24 +167,39 @@ export abstract class AuthService extends Service {
|
|
|
165
167
|
id: result.user.id,
|
|
166
168
|
username: result.user.username,
|
|
167
169
|
role: result.user.role,
|
|
168
|
-
databaseId: result.user.databaseId
|
|
170
|
+
databaseId: result.user.databaseId,
|
|
171
|
+
databases: result.user.databases // databaseId eklendi
|
|
169
172
|
},
|
|
170
173
|
JWT_REFRESH_SECRET,
|
|
171
174
|
{ expiresIn: '7d' }
|
|
172
175
|
);
|
|
173
176
|
|
|
174
|
-
//
|
|
175
|
-
|
|
176
|
-
|
|
177
|
+
// --- ENVIRONMENT-BASED COOKIE SETTINGS ---
|
|
178
|
+
const isProd = process.env.NODE_ENV === 'production';
|
|
179
|
+
const domain = isProd ? '.urpanels.com' : '.local.test';
|
|
180
|
+
const secure = isProd ? 'Secure; ' : '';
|
|
181
|
+
const sameSite = isProd ? 'Strict' : 'Lax';
|
|
182
|
+
|
|
183
|
+
const headers = new Headers();
|
|
184
|
+
|
|
185
|
+
headers.append(
|
|
186
|
+
"Set-Cookie",
|
|
187
|
+
`accessToken=${accessToken}; Path=/; Domain=${domain}; ${secure}HttpOnly; SameSite=${sameSite}; Max-Age=900`
|
|
188
|
+
);
|
|
189
|
+
|
|
190
|
+
headers.append(
|
|
191
|
+
"Set-Cookie",
|
|
192
|
+
`refreshToken=${refreshToken}; Path=/; Domain=${domain}; ${secure}HttpOnly; SameSite=${sameSite}; Max-Age=604800`
|
|
193
|
+
);
|
|
194
|
+
headers.append(
|
|
195
|
+
"Content-Type",
|
|
196
|
+
`application/json`
|
|
197
|
+
);
|
|
177
198
|
return new Response(
|
|
178
199
|
JSON.stringify({ status: "success", message: "valid credentials", data: { user: result.user } }),
|
|
179
200
|
{
|
|
180
201
|
status: 200,
|
|
181
|
-
headers:
|
|
182
|
-
"Set-Cookie":
|
|
183
|
-
`accessToken=${accessToken}; Path=/; HttpOnly; Secure; SameSite=Strict; Max-Age=900, refreshToken=${refreshToken}; Path=/; HttpOnly; Secure; SameSite=Strict; Max-Age=604800`,
|
|
184
|
-
'Content-Type': 'application/json'
|
|
185
|
-
}
|
|
202
|
+
headers: headers
|
|
186
203
|
}
|
|
187
204
|
);
|
|
188
205
|
}
|
|
@@ -241,6 +258,7 @@ export abstract class AuthService extends Service {
|
|
|
241
258
|
username: string;
|
|
242
259
|
role: string; // Refresh token'da rol bilgisi varsa
|
|
243
260
|
databaseId?: string;
|
|
261
|
+
databases?: string[];
|
|
244
262
|
} = jwt.verify(refreshToken, JWT_REFRESH_SECRET) as unknown as any;
|
|
245
263
|
//debugger;
|
|
246
264
|
|
|
@@ -270,7 +288,8 @@ export abstract class AuthService extends Service {
|
|
|
270
288
|
id: decodedRefresh.id,
|
|
271
289
|
username: decodedRefresh.username,
|
|
272
290
|
role: decodedRefresh.role,
|
|
273
|
-
databaseId: decodedRefresh.databaseId // databaseId eklendi
|
|
291
|
+
databaseId: decodedRefresh.databaseId, // databaseId eklendi
|
|
292
|
+
databases: decodedRefresh.databases // databases eklendi
|
|
274
293
|
},
|
|
275
294
|
JWT_SECRET,
|
|
276
295
|
{ expiresIn: '15m' }
|
|
@@ -280,7 +299,8 @@ export abstract class AuthService extends Service {
|
|
|
280
299
|
id: decodedRefresh.id,
|
|
281
300
|
username: decodedRefresh.username,
|
|
282
301
|
role: decodedRefresh.role,
|
|
283
|
-
databaseId: decodedRefresh.databaseId // databaseId eklendi
|
|
302
|
+
databaseId: decodedRefresh.databaseId, // databaseId eklendi
|
|
303
|
+
databases: decodedRefresh.databases // databases eklendi
|
|
284
304
|
},
|
|
285
305
|
JWT_REFRESH_SECRET,
|
|
286
306
|
{ expiresIn: '7d' }
|
|
@@ -332,7 +352,8 @@ export abstract class AuthService extends Service {
|
|
|
332
352
|
id: user?.id || null,
|
|
333
353
|
username: user?.username || null,
|
|
334
354
|
role: user?.role || null,
|
|
335
|
-
databaseId: user?.databaseId || null // databaseId eklendi
|
|
355
|
+
databaseId: user?.databaseId || null, // databaseId eklendi
|
|
356
|
+
databases: user?.databases || null // databases eklendi
|
|
336
357
|
}
|
|
337
358
|
}
|
|
338
359
|
});
|