Skip to content

Commit 1ef197d

Browse files
committed
feat: change auth
1 parent 3fd60d6 commit 1ef197d

File tree

5 files changed

+32
-25
lines changed

5 files changed

+32
-25
lines changed

backend/src/app/partner/dto/get-passports-pages-count.dto.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,8 @@ export class GetPassportsPagesCountDto {
44
@IsString()
55
token: string;
66

7-
@IsString()
8-
session_cookie: string;
7+
// @IsString()
8+
// session_cookie: string;
99

1010
@IsString()
1111
semester: string;

backend/src/app/partner/dto/get-requests-pages-count.dto.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,9 +3,9 @@ import { IsString } from "class-validator";
33
export class GetRequestsPagesCountDto {
44
@IsString()
55
token: string;
6-
7-
@IsString()
8-
session_cookie: string;
6+
//
7+
// @IsString()
8+
// session_cookie: string;
99

1010
@IsString()
1111
semester: string;

backend/src/app/partner/dto/parse-passport.dto.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,9 +6,9 @@ export class ParsePassportDto {
66
@IsString()
77
token: string;
88

9-
@ApiProperty()
10-
@IsString()
11-
session_cookie: string;
9+
// @ApiProperty()
10+
// @IsString()
11+
// session_cookie: string;
1212

1313
@ApiProperty()
1414
id?: number;

backend/src/app/partner/dto/parse-request.dto.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,8 @@ export class ParseRequestDto {
44
@IsString()
55
token: string;
66

7-
@IsString()
8-
session_cookie: string;
7+
// @IsString()
8+
// session_cookie: string;
99

1010
@IsNumber()
1111
id: number;

backend/src/app/partner/partner.service.ts

Lines changed: 22 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -67,13 +67,13 @@ export class PartnerService {
6767
await driver.findElement(By.id("kc-login")).click();
6868
await driver.sleep(5000);
6969
const key = await driver.manage().getCookie("key");
70-
const session = await driver.manage().getCookie("session-cookie");
70+
// const session = await driver.manage().getCookie("session-cookie");
7171
this.logger.log(`\ttoken: ${key.value}`);
72-
this.logger.log(`\tsession_cookie: ${session.value}`);
72+
// this.logger.log(`\tsession_cookie: ${session.value}`);
7373
this.logger.log(`}`);
7474
return {
7575
token: key.value,
76-
session_cookie: session.value,
76+
// session_cookie: session.value,
7777
};
7878
} catch (error) {
7979
console.error("Failed to open website:", error);
@@ -107,7 +107,8 @@ export class PartnerService {
107107
let tokens = await this.getTokens();
108108

109109
let myHeaders = new Headers();
110-
myHeaders.append("Cookie", `session-cookie=${tokens.session_cookie};key=${tokens.token}`);
110+
// myHeaders.append("Cookie", `session-cookie=${tokens.session_cookie};key=${tokens.token}`);
111+
myHeaders.append("Cookie", `key=${tokens.token}`);
111112

112113
let requestOptions: RequestInit = {
113114
method: "GET",
@@ -119,7 +120,7 @@ export class PartnerService {
119120
let period = await this.periodService.findOne(parseRequestsDto.period_id);
120121

121122
let count = await this.getRequestsPagesCount({
122-
session_cookie: tokens.session_cookie,
123+
// session_cookie: tokens.session_cookie ?? "",
123124
token: tokens.token,
124125
semester: period.year + "-" + (period.term - 1),
125126
});
@@ -150,7 +151,7 @@ export class PartnerService {
150151
this.logger.log(`${j}/${count.requestsCount} request`);
151152
this.logger.log("Parse request " + request.id + " {");
152153
let currentRequest = await this.parseRequest({
153-
session_cookie: tokens.session_cookie,
154+
// session_cookie: tokens.session_cookie,
154155
token: tokens.token,
155156
id: request.id,
156157
});
@@ -222,7 +223,8 @@ export class PartnerService {
222223
let tokens = await this.getTokens();
223224

224225
let myHeaders = new Headers();
225-
myHeaders.append("Cookie", "session-cookie=" + tokens.session_cookie + ";key=" + tokens.token);
226+
myHeaders.append("Cookie", "key=" + tokens.token);
227+
// myHeaders.append("Cookie", "session-cookie=" + tokens.session_cookie + ";key=" + tokens.token);
226228

227229
let requestOptions: RequestInit = {
228230
method: "GET",
@@ -235,7 +237,7 @@ export class PartnerService {
235237

236238
let { pagesCount, passportsCount } = await this.getPassportsPagesCount({
237239
token: tokens.token,
238-
session_cookie: tokens.session_cookie,
240+
// session_cookie: tokens.session_cookie,
239241
semester: period.year + "-" + (period.term - 1),
240242
});
241243

@@ -266,12 +268,12 @@ export class PartnerService {
266268
for (let passport of currentPassports.results) {
267269
let currentPassport = await this.parsePassport({
268270
token: tokens.token,
269-
session_cookie: tokens.session_cookie,
271+
// session_cookie: tokens.session_cookie,
270272
id: passport.id,
271273
});
272274
let currentRequest = await this.parseRequest({
273275
token: tokens.token,
274-
session_cookie: tokens.session_cookie,
276+
// session_cookie: tokens.session_cookie,
275277
id: currentPassport.source?.id || currentPassport.id,
276278
});
277279
this.logger.log(`${j}/${passportsCount} passports`);
@@ -355,7 +357,8 @@ export class PartnerService {
355357
let myHeaders = new Headers();
356358
myHeaders.append(
357359
"Cookie",
358-
"session-cookie=" + getRequestsPagesCountDto.session_cookie + ";key=" + getRequestsPagesCountDto.token,
360+
"key=" + getRequestsPagesCountDto.token,
361+
// "session-cookie=" + getRequestsPagesCountDto.session_cookie + ";key=" + getRequestsPagesCountDto.token,
359362
);
360363

361364
let requestOptions: RequestInit = {
@@ -388,7 +391,8 @@ export class PartnerService {
388391
let myHeaders = new Headers();
389392
myHeaders.append(
390393
"Cookie",
391-
"session-cookie=" + getPassportsPagesCountDto.session_cookie + ";key=" + getPassportsPagesCountDto.token,
394+
"key=" + getPassportsPagesCountDto.token,
395+
// "session-cookie=" + getPassportsPagesCountDto.session_cookie + ";key=" + getPassportsPagesCountDto.token,
392396
);
393397

394398
let requestOptions: RequestInit = {
@@ -419,7 +423,8 @@ export class PartnerService {
419423
let myHeaders = new Headers();
420424
myHeaders.append(
421425
"Cookie",
422-
"session-cookie=" + parsePassportDto.session_cookie + ";key=" + parsePassportDto.token,
426+
"key=" + parsePassportDto.token,
427+
// "session-cookie=" + parsePassportDto.session_cookie + ";key=" + parsePassportDto.token,
423428
);
424429

425430
let requestOptions: RequestInit = {
@@ -450,7 +455,8 @@ export class PartnerService {
450455
let myHeaders = new Headers();
451456
myHeaders.append(
452457
"Cookie",
453-
"session-cookie=" + parsePassportDto.session_cookie + ";key=" + parsePassportDto.token,
458+
"key=" + parsePassportDto.token,
459+
// "session-cookie=" + parsePassportDto.session_cookie + ";key=" + parsePassportDto.token,
454460
);
455461

456462
let requestOptions: RequestInit = {
@@ -516,7 +522,8 @@ export class PartnerService {
516522
let myHeaders = new Headers();
517523
myHeaders.append(
518524
"Cookie",
519-
"session-cookie=" + parseRequestDto.session_cookie + ";key=" + parseRequestDto.token,
525+
"key=" + parseRequestDto.token,
526+
// "session-cookie=" + parseRequestDto.session_cookie + ";key=" + parseRequestDto.token,
520527
);
521528

522529
let requestOptions: RequestInit = {

0 commit comments

Comments
 (0)