màj srcs
This commit is contained in:
@@ -1,6 +0,0 @@
|
||||
import { AppService } from './app.service';
|
||||
export declare class AppController {
|
||||
private readonly appService;
|
||||
constructor(appService: AppService);
|
||||
getHello(): string;
|
||||
}
|
||||
@@ -1,34 +0,0 @@
|
||||
"use strict";
|
||||
var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
|
||||
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
||||
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
||||
else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
||||
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
||||
};
|
||||
var __metadata = (this && this.__metadata) || function (k, v) {
|
||||
if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
|
||||
};
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
exports.AppController = void 0;
|
||||
const common_1 = require("@nestjs/common");
|
||||
const app_service_1 = require("./app.service");
|
||||
let AppController = class AppController {
|
||||
constructor(appService) {
|
||||
this.appService = appService;
|
||||
}
|
||||
getHello() {
|
||||
return this.appService.getHello();
|
||||
}
|
||||
};
|
||||
__decorate([
|
||||
(0, common_1.Get)(),
|
||||
__metadata("design:type", Function),
|
||||
__metadata("design:paramtypes", []),
|
||||
__metadata("design:returntype", String)
|
||||
], AppController.prototype, "getHello", null);
|
||||
AppController = __decorate([
|
||||
(0, common_1.Controller)(),
|
||||
__metadata("design:paramtypes", [app_service_1.AppService])
|
||||
], AppController);
|
||||
exports.AppController = AppController;
|
||||
//# sourceMappingURL=app.controller.js.map
|
||||
@@ -1 +0,0 @@
|
||||
{"version":3,"file":"app.controller.js","sourceRoot":"","sources":["../src/app.controller.ts"],"names":[],"mappings":";;;;;;;;;;;;AAAA,2CAAiD;AACjD,+CAA2C;AAGpC,IAAM,aAAa,GAAnB,MAAM,aAAa;IACxB,YAA6B,UAAsB;QAAtB,eAAU,GAAV,UAAU,CAAY;IAAG,CAAC;IAGvD,QAAQ;QACN,OAAO,IAAI,CAAC,UAAU,CAAC,QAAQ,EAAE,CAAC;IACpC,CAAC;CACF,CAAA;AAJC;IAAC,IAAA,YAAG,GAAE;;;;6CAGL;AANU,aAAa;IADzB,IAAA,mBAAU,GAAE;qCAE8B,wBAAU;GADxC,aAAa,CAOzB;AAPY,sCAAa"}
|
||||
@@ -1,2 +0,0 @@
|
||||
export declare class AppModule {
|
||||
}
|
||||
@@ -1,44 +0,0 @@
|
||||
"use strict";
|
||||
var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
|
||||
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
||||
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
||||
else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
||||
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
||||
};
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
exports.AppModule = void 0;
|
||||
const common_1 = require("@nestjs/common");
|
||||
const app_controller_1 = require("./app.controller");
|
||||
const app_service_1 = require("./app.service");
|
||||
const users_module_1 = require("./users/users.module");
|
||||
const typeorm_1 = require("@nestjs/typeorm");
|
||||
const config_1 = require("@nestjs/config");
|
||||
const friendships_module_1 = require("./friendship/friendships.module");
|
||||
const authentication_module_1 = require("./auth/42/authentication.module");
|
||||
const passport_1 = require("@nestjs/passport");
|
||||
let AppModule = class AppModule {
|
||||
};
|
||||
AppModule = __decorate([
|
||||
(0, common_1.Module)({
|
||||
imports: [users_module_1.UsersModule,
|
||||
authentication_module_1.AuthenticationModule,
|
||||
passport_1.PassportModule.register({ session: true }),
|
||||
friendships_module_1.FriendshipsModule,
|
||||
config_1.ConfigModule.forRoot(),
|
||||
typeorm_1.TypeOrmModule.forRoot({
|
||||
type: 'postgres',
|
||||
host: process.env.POSTGRES_HOST,
|
||||
port: parseInt(process.env.POSTGRES_PORT),
|
||||
username: process.env.POSTGRES_USER,
|
||||
password: process.env.POSTGRES_PASSWORD,
|
||||
database: process.env.POSTGRES_DATABASE,
|
||||
autoLoadEntities: true,
|
||||
synchronize: true,
|
||||
}),
|
||||
],
|
||||
controllers: [app_controller_1.AppController],
|
||||
providers: [app_service_1.AppService],
|
||||
})
|
||||
], AppModule);
|
||||
exports.AppModule = AppModule;
|
||||
//# sourceMappingURL=app.module.js.map
|
||||
@@ -1 +0,0 @@
|
||||
{"version":3,"file":"app.module.js","sourceRoot":"","sources":["../src/app.module.ts"],"names":[],"mappings":";;;;;;;;;AAAA,2CAAwC;AACxC,qDAAiD;AACjD,+CAA2C;AAC3C,uDAAmD;AACnD,6CAAgD;AAChD,2CAA8C;AAC9C,wEAAoE;AACpE,2EAAuE;AACvE,+CAAkD;AAwB3C,IAAM,SAAS,GAAf,MAAM,SAAS;CAAG,CAAA;AAAZ,SAAS;IAtBrB,IAAA,eAAM,EAAC;QACN,OAAO,EAAE,CAAC,0BAAW;YACpB,4CAAoB;YACpB,yBAAc,CAAC,QAAQ,CAAC,EAAE,OAAO,EAAE,IAAI,EAAE,CAAC;YAC1C,sCAAiB;YACjB,qBAAY,CAAC,OAAO,EAAE;YACtB,uBAAa,CAAC,OAAO,CAAC;gBACrB,IAAI,EAAE,UAAU;gBAChB,IAAI,EAAE,OAAO,CAAC,GAAG,CAAC,aAAa;gBAC/B,IAAI,EAAE,QAAQ,CAAC,OAAO,CAAC,GAAG,CAAC,aAAa,CAAC;gBACzC,QAAQ,EAAE,OAAO,CAAC,GAAG,CAAC,aAAa;gBACnC,QAAQ,EAAE,OAAO,CAAC,GAAG,CAAC,iBAAiB;gBACvC,QAAQ,EAAE,OAAO,CAAC,GAAG,CAAC,iBAAiB;gBACvC,gBAAgB,EAAE,IAAI;gBAGtB,WAAW,EAAE,IAAI;aACjB,CAAC;SACJ;QACC,WAAW,EAAE,CAAC,8BAAa,CAAC;QAC5B,SAAS,EAAE,CAAC,wBAAU,CAAC;KACxB,CAAC;GACW,SAAS,CAAG;AAAZ,8BAAS"}
|
||||
@@ -1,3 +0,0 @@
|
||||
export declare class AppService {
|
||||
getHello(): string;
|
||||
}
|
||||
@@ -1,20 +0,0 @@
|
||||
"use strict";
|
||||
var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
|
||||
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
||||
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
||||
else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
||||
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
||||
};
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
exports.AppService = void 0;
|
||||
const common_1 = require("@nestjs/common");
|
||||
let AppService = class AppService {
|
||||
getHello() {
|
||||
return 'Hello Toto!';
|
||||
}
|
||||
};
|
||||
AppService = __decorate([
|
||||
(0, common_1.Injectable)()
|
||||
], AppService);
|
||||
exports.AppService = AppService;
|
||||
//# sourceMappingURL=app.service.js.map
|
||||
@@ -1 +0,0 @@
|
||||
{"version":3,"file":"app.service.js","sourceRoot":"","sources":["../src/app.service.ts"],"names":[],"mappings":";;;;;;;;;AAAA,2CAA4C;AAGrC,IAAM,UAAU,GAAhB,MAAM,UAAU;IACrB,QAAQ;QACN,OAAO,aAAa,CAAC;IACvB,CAAC;CACF,CAAA;AAJY,UAAU;IADtB,IAAA,mBAAU,GAAE;GACA,UAAU,CAItB;AAJY,gCAAU"}
|
||||
@@ -1,17 +0,0 @@
|
||||
import { AuthenticationService } from './authentication.service';
|
||||
import { Response } from 'express';
|
||||
import { TwoFaDto } from './dto/2fa.dto';
|
||||
import { UsersService } from 'src/users/users.service';
|
||||
export declare class AuthenticationController {
|
||||
private authService;
|
||||
private userService;
|
||||
constructor(authService: AuthenticationService, userService: UsersService);
|
||||
login(response: Response): void;
|
||||
redirect(response: Response, request: any): Promise<void>;
|
||||
status(): string;
|
||||
logout(request: any): {
|
||||
msg: string;
|
||||
};
|
||||
register(request: any, response: any): Promise<any>;
|
||||
verify(request: any, { twoFaCode }: TwoFaDto): Promise<void>;
|
||||
}
|
||||
@@ -1,112 +0,0 @@
|
||||
"use strict";
|
||||
var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
|
||||
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
||||
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
||||
else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
||||
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
||||
};
|
||||
var __metadata = (this && this.__metadata) || function (k, v) {
|
||||
if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
|
||||
};
|
||||
var __param = (this && this.__param) || function (paramIndex, decorator) {
|
||||
return function (target, key) { decorator(target, key, paramIndex); }
|
||||
};
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
exports.AuthenticationController = void 0;
|
||||
const common_1 = require("@nestjs/common");
|
||||
const _42guards_1 = require("./guards/42guards");
|
||||
const authentication_service_1 = require("./authentication.service");
|
||||
const _2fa_dto_1 = require("./dto/2fa.dto");
|
||||
const users_service_1 = require("../../users/users.service");
|
||||
let AuthenticationController = class AuthenticationController {
|
||||
constructor(authService, userService) {
|
||||
this.authService = authService;
|
||||
this.userService = userService;
|
||||
}
|
||||
login(response) {
|
||||
console.log('ON EST DANS LOGIN AUTH CONTROLLER');
|
||||
return;
|
||||
}
|
||||
async redirect(response, request) {
|
||||
console.log('ON EST DANS REDIRECT AUTH CONTROLLER' + request.user);
|
||||
console.log('On redirige');
|
||||
return response.status(200).redirect('http://transcendance:8080');
|
||||
}
|
||||
status() {
|
||||
return 'status';
|
||||
}
|
||||
logout(request) {
|
||||
console.log('ON EST DANS LOGOUT AUTH CONTROLLER');
|
||||
request.session.destroy();
|
||||
return { msg: 'You are now logged out' };
|
||||
}
|
||||
async register(request, response) {
|
||||
console.log('ON EST DANS REGISTER POUR 2FA AUTH CONTROLLER');
|
||||
const { otpauth } = await this.authService.generate2FaSecret(request.user);
|
||||
return this.authService.pipeQrCodeStream(response, otpauth);
|
||||
}
|
||||
async verify(request, { twoFaCode }) {
|
||||
console.log('ON EST DANS VERIFY POUR 2FA AUTH CONTROLLER');
|
||||
const isCodeIsValid = await this.authService.verify2FaCode(request.user, twoFaCode);
|
||||
if (isCodeIsValid === false) {
|
||||
throw new common_1.UnauthorizedException('Wrong Code.');
|
||||
}
|
||||
await this.userService.enableTwoFactorAuth(request.user.id);
|
||||
}
|
||||
};
|
||||
__decorate([
|
||||
(0, common_1.Get)(),
|
||||
(0, common_1.UseGuards)(_42guards_1.FortyTwoAuthGuard),
|
||||
__param(0, (0, common_1.Res)()),
|
||||
__metadata("design:type", Function),
|
||||
__metadata("design:paramtypes", [Object]),
|
||||
__metadata("design:returntype", void 0)
|
||||
], AuthenticationController.prototype, "login", null);
|
||||
__decorate([
|
||||
(0, common_1.Get)('redirect'),
|
||||
(0, common_1.UseGuards)(_42guards_1.FortyTwoAuthGuard),
|
||||
__param(0, (0, common_1.Res)()),
|
||||
__param(1, (0, common_1.Req)()),
|
||||
__metadata("design:type", Function),
|
||||
__metadata("design:paramtypes", [Object, Object]),
|
||||
__metadata("design:returntype", Promise)
|
||||
], AuthenticationController.prototype, "redirect", null);
|
||||
__decorate([
|
||||
(0, common_1.Get)('status'),
|
||||
(0, common_1.UseGuards)(_42guards_1.AuthenticateGuard),
|
||||
__metadata("design:type", Function),
|
||||
__metadata("design:paramtypes", []),
|
||||
__metadata("design:returntype", void 0)
|
||||
], AuthenticationController.prototype, "status", null);
|
||||
__decorate([
|
||||
(0, common_1.Get)('logout'),
|
||||
__param(0, (0, common_1.Req)()),
|
||||
__metadata("design:type", Function),
|
||||
__metadata("design:paramtypes", [Object]),
|
||||
__metadata("design:returntype", void 0)
|
||||
], AuthenticationController.prototype, "logout", null);
|
||||
__decorate([
|
||||
(0, common_1.Post)('2fa/generate'),
|
||||
(0, common_1.UseGuards)(_42guards_1.AuthenticateGuard),
|
||||
__param(0, (0, common_1.Req)()),
|
||||
__param(1, (0, common_1.Res)()),
|
||||
__metadata("design:type", Function),
|
||||
__metadata("design:paramtypes", [Object, Object]),
|
||||
__metadata("design:returntype", Promise)
|
||||
], AuthenticationController.prototype, "register", null);
|
||||
__decorate([
|
||||
(0, common_1.Post)('2fa/turn-on'),
|
||||
(0, common_1.UseGuards)(_42guards_1.AuthenticateGuard),
|
||||
__param(0, (0, common_1.Req)()),
|
||||
__param(1, (0, common_1.Body)()),
|
||||
__metadata("design:type", Function),
|
||||
__metadata("design:paramtypes", [Object, _2fa_dto_1.TwoFaDto]),
|
||||
__metadata("design:returntype", Promise)
|
||||
], AuthenticationController.prototype, "verify", null);
|
||||
AuthenticationController = __decorate([
|
||||
(0, common_1.Controller)('auth'),
|
||||
__metadata("design:paramtypes", [authentication_service_1.AuthenticationService,
|
||||
users_service_1.UsersService])
|
||||
], AuthenticationController);
|
||||
exports.AuthenticationController = AuthenticationController;
|
||||
//# sourceMappingURL=authentication.controller.js.map
|
||||
@@ -1 +0,0 @@
|
||||
{"version":3,"file":"authentication.controller.js","sourceRoot":"","sources":["../../../src/auth/42/authentication.controller.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;AAAA,2CAAkH;AAClH,iDAAyE;AACzE,qEAAiE;AAEjE,4CAAyC;AACzC,6DAAuD;AAGhD,IAAM,wBAA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+0,0 @@
|
||||
export declare class AuthenticationModule {
|
||||
}
|
||||
@@ -1,33 +0,0 @@
|
||||
"use strict";
|
||||
var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
|
||||
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
||||
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
||||
else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
||||
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
||||
};
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
exports.AuthenticationModule = void 0;
|
||||
const common_1 = require("@nestjs/common");
|
||||
const typeorm_1 = require("@nestjs/typeorm");
|
||||
const friendship_entity_1 = require("../../friendship/entities/friendship.entity");
|
||||
const user_entity_1 = require("../../users/entities/user.entity");
|
||||
const users_module_1 = require("../../users/users.module");
|
||||
const users_service_1 = require("../../users/users.service");
|
||||
const authentication_controller_1 = require("./authentication.controller");
|
||||
const authentication_service_1 = require("./authentication.service");
|
||||
const _42strategy_1 = require("./strategy/42strategy");
|
||||
const serializer_1 = require("./utils/serializer");
|
||||
let AuthenticationModule = class AuthenticationModule {
|
||||
};
|
||||
AuthenticationModule = __decorate([
|
||||
(0, common_1.Module)({
|
||||
imports: [typeorm_1.TypeOrmModule.forFeature([user_entity_1.User, friendship_entity_1.Friendship]), users_module_1.UsersModule,
|
||||
],
|
||||
providers: [authentication_service_1.AuthenticationService, _42strategy_1.FortyTwoStrategy, users_service_1.UsersService, serializer_1.SessionSerializer,
|
||||
],
|
||||
exports: [authentication_service_1.AuthenticationService],
|
||||
controllers: [authentication_controller_1.AuthenticationController],
|
||||
})
|
||||
], AuthenticationModule);
|
||||
exports.AuthenticationModule = AuthenticationModule;
|
||||
//# sourceMappingURL=authentication.module.js.map
|
||||
@@ -1 +0,0 @@
|
||||
{"version":3,"file":"authentication.module.js","sourceRoot":"","sources":["../../../src/auth/42/authentication.module.ts"],"names":[],"mappings":";;;;;;;;;AAAA,2CAAwC;AACxC,6CAAgD;AAChD,mFAAuE;AACvE,kEAAsD;AACtD,2DAAqD;AACrD,6DAAuD;AACvD,2EAAuE;AACvE,qEAAiE;AACjE,uDAAyD;AACzD,mDAAuD;AAmBhD,IAAM,oBAAoB,GAA1B,MAAM,oBAAoB;CAAG,CAAA;AAAvB,oBAAoB;IAjBhC,IAAA,eAAM,EAAC;QACL,OAAO,EAAE,CAAC,uBAAa,CAAC,UAAU,CAAC,CAAC,kBAAI,EAAE,8BAAU,CAAC,CAAC,EAAE,0BAAW;SASpE;QACC,SAAS,EAAE,CAAC,8CAAqB,EAAE,8BAAgB,EAAE,4BAAY,EAAE,8BAAiB;SAEtF;QACE,OAAO,EAAE,CAAC,8CAAqB,CAAC;QAChC,WAAW,EAAE,CAAC,oDAAwB,CAAC;KACzC,CAAC;GACW,oBAAoB,CAAG;AAAvB,oDAAoB"}
|
||||
@@ -1,15 +0,0 @@
|
||||
import { CreateUsersDto } from 'src/users/dto/create-users.dto';
|
||||
import { User } from 'src/users/entities/user.entity';
|
||||
import { UsersService } from 'src/users/users.service';
|
||||
export declare class AuthenticationService {
|
||||
private readonly userService;
|
||||
constructor(userService: UsersService);
|
||||
validateUser(createUsersDto: CreateUsersDto): Promise<User>;
|
||||
findUser(fourtytwo_id: string): Promise<User | undefined>;
|
||||
verify2FaCode(user: User, code: string): Promise<boolean>;
|
||||
generate2FaSecret(user: User): Promise<{
|
||||
secret: string;
|
||||
otpauth: string;
|
||||
}>;
|
||||
pipeQrCodeStream(stream: Response, otpauthUrl: string): Promise<any>;
|
||||
}
|
||||
@@ -1,49 +0,0 @@
|
||||
"use strict";
|
||||
var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
|
||||
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
||||
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
||||
else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
||||
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
||||
};
|
||||
var __metadata = (this && this.__metadata) || function (k, v) {
|
||||
if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
|
||||
};
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
exports.AuthenticationService = void 0;
|
||||
const common_1 = require("@nestjs/common");
|
||||
const users_service_1 = require("../../users/users.service");
|
||||
const qrcode_1 = require("qrcode");
|
||||
const otplib_1 = require("otplib");
|
||||
let AuthenticationService = class AuthenticationService {
|
||||
constructor(userService) {
|
||||
this.userService = userService;
|
||||
}
|
||||
async validateUser(createUsersDto) {
|
||||
console.log("Validate inside authentication.service.ts");
|
||||
const user = await this.userService.findOneByFourtyTwoId(createUsersDto.fortyTwoId);
|
||||
if (user)
|
||||
return user;
|
||||
return this.userService.create(createUsersDto);
|
||||
}
|
||||
async findUser(fourtytwo_id) {
|
||||
return await this.userService.findOneByFourtyTwoId(fourtytwo_id);
|
||||
}
|
||||
async verify2FaCode(user, code) {
|
||||
return otplib_1.authenticator.verify({ token: code, secret: user.secretTwoFactorAuth });
|
||||
}
|
||||
async generate2FaSecret(user) {
|
||||
const secret = otplib_1.authenticator.generateSecret();
|
||||
const otpauth = otplib_1.authenticator.keyuri(user.email, process.env.TWO_FACTOR_AUTHENTICATION_APP_NAME, secret);
|
||||
await this.userService.setAuthenticatorSecret(user.id, secret);
|
||||
return { secret, otpauth };
|
||||
}
|
||||
async pipeQrCodeStream(stream, otpauthUrl) {
|
||||
return (0, qrcode_1.toFileStream)(stream, otpauthUrl);
|
||||
}
|
||||
};
|
||||
AuthenticationService = __decorate([
|
||||
(0, common_1.Injectable)(),
|
||||
__metadata("design:paramtypes", [users_service_1.UsersService])
|
||||
], AuthenticationService);
|
||||
exports.AuthenticationService = AuthenticationService;
|
||||
//# sourceMappingURL=authentication.service.js.map
|
||||
@@ -1 +0,0 @@
|
||||
{"version":3,"file":"authentication.service.js","sourceRoot":"","sources":["../../../src/auth/42/authentication.service.ts"],"names":[],"mappings":";;;;;;;;;;;;AAAA,2CAA4C;AAG5C,6DAAuD;AACvD,mCAAsC;AACtC,mCAAuC;AAGhC,IAAM,qBAAqB,GAA3B,MAAM,qBAAqB;IACjC,YACmB,WAAyB;QAAzB,gBAAW,GAAX,WAAW,CAAc;IACxC,CAAC;IAEL,KAAK,CAAC,YAAY,CAAC,cAA8B;QAChD,OAAO,CAAC,GAAG,CAAC,2CAA2C,CAAC,CAAC;QACzD,MAAM,IAAI,GAAG,MAAM,IAAI,CAAC,WAAW,CAAC,oBAAoB,CAAC,cAAc,CAAC,UAAU,CAAC,CAAC;QACpF,IAAI,IAAI;YACP,OAAO,IAAI,CAAC;QACb,OAAO,IAAI,CAAC,WAAW,CAAC,MAAM,CAAC,cAAc,CAAC,CAAC;IAChD,CAAC;IAED,KAAK,CAAC,QAAQ,CAAC,YAAqB;QACnC,OAAO,MAAM,IAAI,CAAC,WAAW,CAAC,oBAAoB,CAAC,YAAY,CAAC,CAAC;IAClE,CAAC;IAED,KAAK,CAAC,aAAa,CAAC,IAAW,EAAE,IAAa;QAC7C,OAAO,sBAAa,CAAC,MAAM,CAAC,EAAE,KAAK,EAAE,IAAI,EAAE,MAAM,EAAE,IAAI,CAAC,mBAAmB,EAAE,CAAC,CAAC;IAChF,CAAC;IAED,KAAK,CAAC,iBAAiB,CAAC,IAAW;QAClC,MAAM,MAAM,GAAG,sBAAa,CAAC,cAAc,EAAE,CAAC;QAC9C,MAAM,OAAO,GAAG,sBAAa,CAAC,MAAM,CAAC,IAAI,CAAC,KAAK,EAAE,OAAO,CAAC,GAAG,CAAC,kCAAkC,EAAE,MAAM,CAAC,CAAC;QACzG,MAAM,IAAI,CAAC,WAAW,CAAC,sBAAsB,CAAC,IAAI,CAAC,EAAE,EAAE,MAAM,CAAC,CAAC;QAC/D,OAAO,EAAE,MAAM,EAAE,OAAO,EAAE,CAAC;IAC5B,CAAC;IAED,KAAK,CAAC,gBAAgB,CAAC,MAAiB,EAAE,UAAmB;QAC5D,OAAO,IAAA,qBAAY,EAAC,MAAM,EAAE,UAAU,CAAC,CAAC;IACzC,CAAC;CAED,CAAA;AAhCY,qBAAqB;IADjC,IAAA,mBAAU,GAAE;qCAGoB,4BAAY;GAFhC,qBAAqB,CAgCjC;AAhCY,sDAAqB"}
|
||||
@@ -1,3 +0,0 @@
|
||||
export declare class TwoFaDto {
|
||||
readonly twoFaCode: string;
|
||||
}
|
||||
@@ -1,21 +0,0 @@
|
||||
"use strict";
|
||||
var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
|
||||
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
||||
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
||||
else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
||||
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
||||
};
|
||||
var __metadata = (this && this.__metadata) || function (k, v) {
|
||||
if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
|
||||
};
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
exports.TwoFaDto = void 0;
|
||||
const class_validator_1 = require("class-validator");
|
||||
class TwoFaDto {
|
||||
}
|
||||
__decorate([
|
||||
(0, class_validator_1.IsString)(),
|
||||
__metadata("design:type", String)
|
||||
], TwoFaDto.prototype, "twoFaCode", void 0);
|
||||
exports.TwoFaDto = TwoFaDto;
|
||||
//# sourceMappingURL=2fa.dto.js.map
|
||||
@@ -1 +0,0 @@
|
||||
{"version":3,"file":"2fa.dto.js","sourceRoot":"","sources":["../../../../src/auth/42/dto/2fa.dto.ts"],"names":[],"mappings":";;;;;;;;;;;;AAAA,qDAAoD;AAEpD,MAAa,QAAQ;CAGpB;AAFA;IAAC,IAAA,0BAAQ,GAAE;;2CACgB;AAF5B,4BAGC"}
|
||||
@@ -1,9 +0,0 @@
|
||||
import { CanActivate, ExecutionContext } from "@nestjs/common";
|
||||
declare const FortyTwoAuthGuard_base: import("@nestjs/passport").Type<import("@nestjs/passport").IAuthGuard>;
|
||||
export declare class FortyTwoAuthGuard extends FortyTwoAuthGuard_base {
|
||||
canActivate(context: ExecutionContext): Promise<any>;
|
||||
}
|
||||
export declare class AuthenticateGuard implements CanActivate {
|
||||
canActivate(context: ExecutionContext): Promise<boolean>;
|
||||
}
|
||||
export {};
|
||||
@@ -1,35 +0,0 @@
|
||||
"use strict";
|
||||
var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
|
||||
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
||||
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
||||
else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
||||
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
||||
};
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
exports.AuthenticateGuard = exports.FortyTwoAuthGuard = void 0;
|
||||
const common_1 = require("@nestjs/common");
|
||||
const passport_1 = require("@nestjs/passport");
|
||||
let FortyTwoAuthGuard = class FortyTwoAuthGuard extends (0, passport_1.AuthGuard)('42') {
|
||||
async canActivate(context) {
|
||||
const activate = (await super.canActivate(context));
|
||||
const request = context.switchToHttp().getRequest();
|
||||
await super.logIn(request);
|
||||
return activate;
|
||||
}
|
||||
};
|
||||
FortyTwoAuthGuard = __decorate([
|
||||
(0, common_1.Injectable)()
|
||||
], FortyTwoAuthGuard);
|
||||
exports.FortyTwoAuthGuard = FortyTwoAuthGuard;
|
||||
let AuthenticateGuard = class AuthenticateGuard {
|
||||
async canActivate(context) {
|
||||
const request = context.switchToHttp().getRequest();
|
||||
console.log("Is User authenticated : " + request.isAuthenticated());
|
||||
return request.isAuthenticated();
|
||||
}
|
||||
};
|
||||
AuthenticateGuard = __decorate([
|
||||
(0, common_1.Injectable)()
|
||||
], AuthenticateGuard);
|
||||
exports.AuthenticateGuard = AuthenticateGuard;
|
||||
//# sourceMappingURL=42guards.js.map
|
||||
@@ -1 +0,0 @@
|
||||
{"version":3,"file":"42guards.js","sourceRoot":"","sources":["../../../../src/auth/42/guards/42guards.ts"],"names":[],"mappings":";;;;;;;;;AAAA,2CAA2E;AAC3E,+CAA6C;AAGtC,IAAM,iBAAiB,GAAvB,MAAM,iBAAkB,SAAQ,IAAA,oBAAS,EAAC,IAAI,CAAC;IACrD,KAAK,CAAC,WAAW,CAAC,OAAyB;QAC1C,MAAM,QAAQ,GAAG,CAAC,MAAM,KAAK,CAAC,WAAW,CAAC,OAAO,CAAC,CAAY,CAAC;QAC/D,MAAM,OAAO,GAAG,OAAO,CAAC,YAAY,EAAE,CAAC,UAAU,EAAE,CAAC;QACpD,MAAM,KAAK,CAAC,KAAK,CAAC,OAAO,CAAC,CAAC;QAC3B,OAAO,QAAQ,CAAC;IACjB,CAAC;CACD,CAAA;AAPY,iBAAiB;IAD7B,IAAA,mBAAU,GAAE;GACA,iBAAiB,CAO7B;AAPY,8CAAiB;AAUvB,IAAM,iBAAiB,GAAvB,MAAM,iBAAiB;IAC7B,KAAK,CAAC,WAAW,CAAC,OAAyB;QAC1C,MAAM,OAAO,GAAG,OAAO,CAAC,YAAY,EAAE,CAAC,UAAU,EAAE,CAAC;QACpD,OAAO,CAAC,GAAG,CAAC,0BAA0B,GAAG,OAAO,CAAC,eAAe,EAAE,CAAC,CAAC;QACpE,OAAO,OAAO,CAAC,eAAe,EAAE,CAAC;IAClC,CAAC;CACD,CAAA;AANY,iBAAiB;IAD7B,IAAA,mBAAU,GAAE;GACA,iBAAiB,CAM7B;AANY,8CAAiB"}
|
||||
@@ -1,9 +0,0 @@
|
||||
import { Profile } from "passport-42/lib";
|
||||
import { AuthenticationService } from "../authentication.service";
|
||||
declare const FortyTwoStrategy_base: new (...args: any[]) => any;
|
||||
export declare class FortyTwoStrategy extends FortyTwoStrategy_base {
|
||||
private authenticationService;
|
||||
constructor(authenticationService: AuthenticationService);
|
||||
validate(accessToken: string, refreshToken: string, profile: Profile, callbackURL: string): Promise<import("../../../users/entities/user.entity").User>;
|
||||
}
|
||||
export {};
|
||||
@@ -1,42 +0,0 @@
|
||||
"use strict";
|
||||
var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
|
||||
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
||||
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
||||
else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
||||
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
||||
};
|
||||
var __metadata = (this && this.__metadata) || function (k, v) {
|
||||
if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
|
||||
};
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
exports.FortyTwoStrategy = void 0;
|
||||
const lib_1 = require("passport-42/lib");
|
||||
const passport_1 = require("@nestjs/passport");
|
||||
const common_1 = require("@nestjs/common");
|
||||
const authentication_service_1 = require("../authentication.service");
|
||||
let FortyTwoStrategy = class FortyTwoStrategy extends (0, passport_1.PassportStrategy)(lib_1.Strategy, "42") {
|
||||
constructor(authenticationService) {
|
||||
super({
|
||||
clientID: process.env.FORTYTWO_CLIENT_ID,
|
||||
clientSecret: process.env.FORTYTWO_CLIENT_SECRET,
|
||||
callbackURL: process.env.FORTYTWO_CALLBACK_URL,
|
||||
scope: ["public"],
|
||||
});
|
||||
this.authenticationService = authenticationService;
|
||||
}
|
||||
async validate(accessToken, refreshToken, profile, callbackURL) {
|
||||
console.log("Validate inside strategy.ts");
|
||||
console.log(profile.id, profile.username, profile.phoneNumbers[0].value, profile.emails[0].value, profile.photos[0].value);
|
||||
const userDTO = { fortyTwoId: profile.id, username: profile.username, email: profile.emails[0].value, image_url: profile.photos[0].value, isEnabledTwoFactorAuth: false };
|
||||
const user = await this.authenticationService.validateUser(userDTO);
|
||||
if (!user)
|
||||
throw new common_1.UnauthorizedException();
|
||||
return user;
|
||||
}
|
||||
};
|
||||
FortyTwoStrategy = __decorate([
|
||||
(0, common_1.Injectable)(),
|
||||
__metadata("design:paramtypes", [authentication_service_1.AuthenticationService])
|
||||
], FortyTwoStrategy);
|
||||
exports.FortyTwoStrategy = FortyTwoStrategy;
|
||||
//# sourceMappingURL=42strategy.js.map
|
||||
@@ -1 +0,0 @@
|
||||
{"version":3,"file":"42strategy.js","sourceRoot":"","sources":["../../../../src/auth/42/strategy/42strategy.ts"],"names":[],"mappings":";;;;;;;;;;;;AAAA,yCAAoD;AACpD,+CAAoD;AACpD,2CAAmE;AACnE,sEAAkE;AAI3D,IAAM,gBAAgB,GAAtB,MAAM,gBAAiB,SAAQ,IAAA,2BAAgB,EAAC,cAAQ,EAAE,IAAI,CAAC;IACrE,YAAoB,qBAA4C;QAChE,KAAK,CAAC;YACJ,QAAQ,EAAE,OAAO,CAAC,GAAG,CAAC,kBAAkB;YACxC,YAAY,EAAE,OAAO,CAAC,GAAG,CAAC,sBAAsB;YAChD,WAAW,EAAE,OAAO,CAAC,GAAG,CAAC,qBAAqB;YAC9C,KAAK,EAAE,CAAC,QAAQ,CAAC;SAClB,CAAC,CAAC;QANiB,0BAAqB,GAArB,qBAAqB,CAAuB;IAO/D,CAAC;IAED,KAAK,CAAC,QAAQ,CAAC,WAAmB,EAAE,YAAoB,EAAE,OAAgB,EAAE,WAAmB;QAChG,OAAO,CAAC,GAAG,CAAC,6BAA6B,CAAC,CAAC;QAC3C,OAAO,CAAC,GAAG,CAAC,OAAO,CAAC,EAAE,EAAE,OAAO,CAAC,QAAQ,EAAE,OAAO,CAAC,YAAY,CAAC,CAAC,CAAC,CAAC,KAAK,EAAE,OAAO,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC,KAAK,EAAE,OAAO,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC,KAAK,CAAC,CAAC;QAC3H,MAAM,OAAO,GAAoB,EAAE,UAAU,EAAE,OAAO,CAAC,EAAE,EAAE,QAAQ,EAAE,OAAO,CAAC,QAAQ,EAAE,KAAK,EAAE,OAAO,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC,KAAK,EAAE,SAAS,EAAE,OAAO,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC,KAAK,EAAE,sBAAsB,EAAE,KAAK,EAAE,CAAC;QAC3L,MAAM,IAAI,GAAG,MAAM,IAAI,CAAC,qBAAqB,CAAC,YAAY,CAAC,OAAO,CAAC,CAAC;QACpE,IAAI,CAAC,IAAI;YACR,MAAM,IAAI,8BAAqB,EAAE,CAAC;QACnC,OAAO,IAAI,CAAC;IACX,CAAC;CACF,CAAA;AAnBY,gBAAgB;IAD5B,IAAA,mBAAU,GAAE;qCAE+B,8CAAqB;GADpD,gBAAgB,CAmB5B;AAnBY,4CAAgB"}
|
||||
@@ -1,9 +0,0 @@
|
||||
import { PassportSerializer } from "@nestjs/passport";
|
||||
import { User } from "src/users/entities/user.entity";
|
||||
import { AuthenticationService } from "../authentication.service";
|
||||
export declare class SessionSerializer extends PassportSerializer {
|
||||
private readonly authservice;
|
||||
constructor(authservice: AuthenticationService);
|
||||
serializeUser(user: User, done: (err: Error, user: User) => void): void;
|
||||
deserializeUser(user: User, done: (err: Error, user: User) => void): Promise<void>;
|
||||
}
|
||||
@@ -1,37 +0,0 @@
|
||||
"use strict";
|
||||
var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
|
||||
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
||||
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
||||
else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
||||
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
||||
};
|
||||
var __metadata = (this && this.__metadata) || function (k, v) {
|
||||
if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
|
||||
};
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
exports.SessionSerializer = void 0;
|
||||
const passport_1 = require("@nestjs/passport");
|
||||
const common_1 = require("@nestjs/common");
|
||||
const authentication_service_1 = require("../authentication.service");
|
||||
let SessionSerializer = class SessionSerializer extends passport_1.PassportSerializer {
|
||||
constructor(authservice) {
|
||||
super();
|
||||
this.authservice = authservice;
|
||||
}
|
||||
serializeUser(user, done) {
|
||||
done(null, user);
|
||||
}
|
||||
async deserializeUser(user, done) {
|
||||
const userDB = await this.authservice.findUser(user.fortyTwoId);
|
||||
if (userDB)
|
||||
done(null, userDB);
|
||||
else
|
||||
done(null, null);
|
||||
}
|
||||
};
|
||||
SessionSerializer = __decorate([
|
||||
(0, common_1.Injectable)(),
|
||||
__metadata("design:paramtypes", [authentication_service_1.AuthenticationService])
|
||||
], SessionSerializer);
|
||||
exports.SessionSerializer = SessionSerializer;
|
||||
//# sourceMappingURL=serializer.js.map
|
||||
@@ -1 +0,0 @@
|
||||
{"version":3,"file":"serializer.js","sourceRoot":"","sources":["../../../../src/auth/42/utils/serializer.ts"],"names":[],"mappings":";;;;;;;;;;;;AAAA,+CAAsD;AACtD,2CAA4C;AAE5C,sEAAkE;AAG3D,IAAM,iBAAiB,GAAvB,MAAM,iBAAkB,SAAQ,6BAAkB;IACxD,YAA6B,WAAmC;QAC/D,KAAK,EAAE,CAAC;QADoB,gBAAW,GAAX,WAAW,CAAwB;IAEhE,CAAC;IAED,aAAa,CAAC,IAAW,EAAE,IAAyC;QACnE,IAAI,CAAC,IAAI,EAAE,IAAI,CAAC,CAAC;IAClB,CAAC;IAED,KAAK,CAAC,eAAe,CAAC,IAAW,EAAE,IAAyC;QAC3E,MAAM,MAAM,GAAG,MAAM,IAAI,CAAC,WAAW,CAAC,QAAQ,CAAC,IAAI,CAAC,UAAU,CAAC,CAAC;QAChE,IAAI,MAAM;YACT,IAAI,CAAC,IAAI,EAAE,MAAM,CAAC,CAAC;;YAEnB,IAAI,CAAC,IAAI,EAAE,IAAI,CAAC,CAAC;IACnB,CAAC;CACD,CAAA;AAhBY,iBAAiB;IAD7B,IAAA,mBAAU,GAAE;qCAE+B,8CAAqB;GADpD,iBAAiB,CAgB7B;AAhBY,8CAAiB"}
|
||||
@@ -1,4 +0,0 @@
|
||||
export declare class PaginationQueryDto {
|
||||
limit: number;
|
||||
offset: number;
|
||||
}
|
||||
@@ -1,27 +0,0 @@
|
||||
"use strict";
|
||||
var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
|
||||
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
||||
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
||||
else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
||||
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
||||
};
|
||||
var __metadata = (this && this.__metadata) || function (k, v) {
|
||||
if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
|
||||
};
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
exports.PaginationQueryDto = void 0;
|
||||
const class_validator_1 = require("class-validator");
|
||||
class PaginationQueryDto {
|
||||
}
|
||||
__decorate([
|
||||
(0, class_validator_1.IsOptional)(),
|
||||
(0, class_validator_1.IsPositive)(),
|
||||
__metadata("design:type", Number)
|
||||
], PaginationQueryDto.prototype, "limit", void 0);
|
||||
__decorate([
|
||||
(0, class_validator_1.IsPositive)(),
|
||||
(0, class_validator_1.IsOptional)(),
|
||||
__metadata("design:type", Number)
|
||||
], PaginationQueryDto.prototype, "offset", void 0);
|
||||
exports.PaginationQueryDto = PaginationQueryDto;
|
||||
//# sourceMappingURL=pagination-query.dto.js.map
|
||||
@@ -1 +0,0 @@
|
||||
{"version":3,"file":"pagination-query.dto.js","sourceRoot":"","sources":["../../../src/common/dto/pagination-query.dto.ts"],"names":[],"mappings":";;;;;;;;;;;;AAAA,qDAAyD;AAEzD,MAAa,kBAAkB;CAS9B;AAPA;IAAC,IAAA,4BAAU,GAAE;IACZ,IAAA,4BAAU,GAAE;;iDACC;AAEd;IAAC,IAAA,4BAAU,GAAE;IACZ,IAAA,4BAAU,GAAE;;kDACE;AARhB,gDASC"}
|
||||
@@ -1,6 +0,0 @@
|
||||
import { FriendshipStatus } from '../entities/friendship.entity';
|
||||
export declare class CreateFriendshipDto {
|
||||
readonly requesterId: string;
|
||||
readonly addresseeId: string;
|
||||
readonly status: FriendshipStatus;
|
||||
}
|
||||
@@ -1,31 +0,0 @@
|
||||
"use strict";
|
||||
var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
|
||||
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
||||
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
||||
else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
||||
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
||||
};
|
||||
var __metadata = (this && this.__metadata) || function (k, v) {
|
||||
if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
|
||||
};
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
exports.CreateFriendshipDto = void 0;
|
||||
const class_validator_1 = require("class-validator");
|
||||
const friendship_entity_1 = require("../entities/friendship.entity");
|
||||
class CreateFriendshipDto {
|
||||
}
|
||||
__decorate([
|
||||
(0, class_validator_1.IsString)(),
|
||||
__metadata("design:type", String)
|
||||
], CreateFriendshipDto.prototype, "requesterId", void 0);
|
||||
__decorate([
|
||||
(0, class_validator_1.IsString)(),
|
||||
__metadata("design:type", String)
|
||||
], CreateFriendshipDto.prototype, "addresseeId", void 0);
|
||||
__decorate([
|
||||
(0, class_validator_1.IsEnum)(friendship_entity_1.FriendshipStatus),
|
||||
(0, class_validator_1.IsOptional)(),
|
||||
__metadata("design:type", String)
|
||||
], CreateFriendshipDto.prototype, "status", void 0);
|
||||
exports.CreateFriendshipDto = CreateFriendshipDto;
|
||||
//# sourceMappingURL=create-friendship.dto.js.map
|
||||
@@ -1 +0,0 @@
|
||||
{"version":3,"file":"create-friendship.dto.js","sourceRoot":"","sources":["../../../src/friendship/dto/create-friendship.dto.ts"],"names":[],"mappings":";;;;;;;;;;;;AAAA,qDAA4F;AAC5F,qEAAiE;AAEjE,MAAa,mBAAmB;CAQ/B;AAPA;IAAC,IAAA,0BAAQ,GAAE;;wDACkB;AAC7B;IAAC,IAAA,0BAAQ,GAAE;;wDACkB;AAC7B;IAAC,IAAA,wBAAM,EAAC,oCAAgB,CAAC;IACxB,IAAA,4BAAU,GAAE;;mDACqB;AAPnC,kDAQC"}
|
||||
@@ -1,5 +0,0 @@
|
||||
import { CreateFriendshipDto } from "./create-friendship.dto";
|
||||
declare const UpdateFriendshipDto_base: import("@nestjs/mapped-types").MappedType<Partial<CreateFriendshipDto>>;
|
||||
export declare class UpdateFriendshipDto extends UpdateFriendshipDto_base {
|
||||
}
|
||||
export {};
|
||||
@@ -1,9 +0,0 @@
|
||||
"use strict";
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
exports.UpdateFriendshipDto = void 0;
|
||||
const mapped_types_1 = require("@nestjs/mapped-types");
|
||||
const create_friendship_dto_1 = require("./create-friendship.dto");
|
||||
class UpdateFriendshipDto extends (0, mapped_types_1.PartialType)(create_friendship_dto_1.CreateFriendshipDto) {
|
||||
}
|
||||
exports.UpdateFriendshipDto = UpdateFriendshipDto;
|
||||
//# sourceMappingURL=update-friendship.dto.js.map
|
||||
@@ -1 +0,0 @@
|
||||
{"version":3,"file":"update-friendship.dto.js","sourceRoot":"","sources":["../../../src/friendship/dto/update-friendship.dto.ts"],"names":[],"mappings":";;;AAAA,uDAAmD;AACnD,mEAA8D;AAE9D,MAAa,mBAAoB,SAAQ,IAAA,0BAAW,EAAC,2CAAmB,CAAC;CAAE;AAA3E,kDAA2E"}
|
||||
@@ -1,13 +0,0 @@
|
||||
export declare enum FriendshipStatus {
|
||||
REQUESTED = "R",
|
||||
ACCEPTED = "A",
|
||||
DECLINED = "D",
|
||||
BLOCKED = "B"
|
||||
}
|
||||
export declare class Friendship {
|
||||
id: number;
|
||||
date: Date;
|
||||
requesterId: string;
|
||||
addresseeId: string;
|
||||
status: FriendshipStatus;
|
||||
}
|
||||
@@ -1,50 +0,0 @@
|
||||
"use strict";
|
||||
var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
|
||||
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
||||
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
||||
else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
||||
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
||||
};
|
||||
var __metadata = (this && this.__metadata) || function (k, v) {
|
||||
if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
|
||||
};
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
exports.Friendship = exports.FriendshipStatus = void 0;
|
||||
const typeorm_1 = require("typeorm");
|
||||
const user_entity_1 = require("../../users/entities/user.entity");
|
||||
var FriendshipStatus;
|
||||
(function (FriendshipStatus) {
|
||||
FriendshipStatus["REQUESTED"] = "R";
|
||||
FriendshipStatus["ACCEPTED"] = "A";
|
||||
FriendshipStatus["DECLINED"] = "D";
|
||||
FriendshipStatus["BLOCKED"] = "B";
|
||||
})(FriendshipStatus = exports.FriendshipStatus || (exports.FriendshipStatus = {}));
|
||||
let Friendship = class Friendship {
|
||||
};
|
||||
__decorate([
|
||||
(0, typeorm_1.PrimaryGeneratedColumn)(),
|
||||
__metadata("design:type", Number)
|
||||
], Friendship.prototype, "id", void 0);
|
||||
__decorate([
|
||||
(0, typeorm_1.CreateDateColumn)(),
|
||||
__metadata("design:type", Date)
|
||||
], Friendship.prototype, "date", void 0);
|
||||
__decorate([
|
||||
(0, typeorm_1.Column)(),
|
||||
(0, typeorm_1.ManyToOne)(type => user_entity_1.User, user => user.requesterId),
|
||||
__metadata("design:type", String)
|
||||
], Friendship.prototype, "requesterId", void 0);
|
||||
__decorate([
|
||||
(0, typeorm_1.Column)(),
|
||||
(0, typeorm_1.ManyToOne)(type => user_entity_1.User, user => user.addresseeId),
|
||||
__metadata("design:type", String)
|
||||
], Friendship.prototype, "addresseeId", void 0);
|
||||
__decorate([
|
||||
(0, typeorm_1.Column)({ type: 'enum', enum: FriendshipStatus, default: FriendshipStatus.REQUESTED }),
|
||||
__metadata("design:type", String)
|
||||
], Friendship.prototype, "status", void 0);
|
||||
Friendship = __decorate([
|
||||
(0, typeorm_1.Entity)('friendships')
|
||||
], Friendship);
|
||||
exports.Friendship = Friendship;
|
||||
//# sourceMappingURL=friendship.entity.js.map
|
||||
@@ -1 +0,0 @@
|
||||
{"version":3,"file":"friendship.entity.js","sourceRoot":"","sources":["../../../src/friendship/entities/friendship.entity.ts"],"names":[],"mappings":";;;;;;;;;;;;AACA,qCAAmI;AACnI,kEAAwD;AAExD,IAAY,gBAKX;AALD,WAAY,gBAAgB;IAC3B,mCAAe,CAAA;IACf,kCAAc,CAAA;IACd,kCAAc,CAAA;IACd,iCAAa,CAAA;AACd,CAAC,EALW,gBAAgB,GAAhB,wBAAgB,KAAhB,wBAAgB,QAK3B;AAGM,IAAM,UAAU,GAAhB,MAAM,UAAU;CAiBtB,CAAA;AAhBA;IAAC,IAAA,gCAAsB,GAAE;;sCACd;AAEX;IAAC,IAAA,0BAAgB,GAAE;8BACZ,IAAI;wCAAC;AAEZ;IAAC,IAAA,gBAAM,GAAE;IACR,IAAA,mBAAS,EAAC,IAAI,CAAC,EAAE,CAAC,kBAAI,EAAE,IAAI,CAAC,EAAE,CAAC,IAAI,CAAC,WAAW,CAAC;;+CAC9B;AAEpB;IAAC,IAAA,gBAAM,GAAE;IACR,IAAA,mBAAS,EAAC,IAAI,CAAC,EAAE,CAAC,kBAAI,EAAE,IAAI,CAAC,EAAE,CAAC,IAAI,CAAC,WAAW,CAAC;;+CAC9B;AAEpB;IAAC,IAAA,gBAAM,EAAC,EAAE,IAAI,EAAE,MAAM,EAAE,IAAI,EAAE,gBAAgB,EAAE,OAAO,EAAE,gBAAgB,CAAC,SAAS,EAAC,CAAC;;0CAC5D;AAhBb,UAAU;IADtB,IAAA,gBAAM,EAAC,aAAa,CAAC;GACT,UAAU,CAiBtB;AAjBY,gCAAU"}
|
||||
@@ -1,15 +0,0 @@
|
||||
import { HttpException } from '@nestjs/common';
|
||||
import { CreateFriendshipDto } from './dto/create-friendship.dto';
|
||||
import { FriendshipService } from './friendship.service';
|
||||
export declare class FriendshipController {
|
||||
private readonly friendshipService;
|
||||
constructor(friendshipService: FriendshipService);
|
||||
findEmpty(req: any): Promise<import("./entities/friendship.entity").Friendship[]>;
|
||||
findOneFriend(relationshipId: string, req: any): Promise<import("./entities/friendship.entity").Friendship[]>;
|
||||
create(createFriendshipDto: CreateFriendshipDto, req: any): HttpException | Promise<import("./entities/friendship.entity").Friendship>;
|
||||
update(relationshipId: string, status: string, req: any): Promise<import("./entities/friendship.entity").Friendship>;
|
||||
remove(relationshipId: string): Promise<import("./entities/friendship.entity").Friendship>;
|
||||
findAllBlocked(req: any): Promise<import("./entities/friendship.entity").Friendship[]>;
|
||||
findAllPendantFriendshipRequested(req: any): Promise<import("./entities/friendship.entity").Friendship[]>;
|
||||
findAllPendantFriendshipReceived(req: any): Promise<import("./entities/friendship.entity").Friendship[]>;
|
||||
}
|
||||
@@ -1,133 +0,0 @@
|
||||
"use strict";
|
||||
var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
|
||||
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
||||
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
||||
else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
||||
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
||||
};
|
||||
var __metadata = (this && this.__metadata) || function (k, v) {
|
||||
if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
|
||||
};
|
||||
var __param = (this && this.__param) || function (paramIndex, decorator) {
|
||||
return function (target, key) { decorator(target, key, paramIndex); }
|
||||
};
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
exports.FriendshipController = void 0;
|
||||
const common_1 = require("@nestjs/common");
|
||||
const _42guards_1 = require("../auth/42/guards/42guards");
|
||||
const create_friendship_dto_1 = require("./dto/create-friendship.dto");
|
||||
const friendship_service_1 = require("./friendship.service");
|
||||
let FriendshipController = class FriendshipController {
|
||||
constructor(friendshipService) {
|
||||
this.friendshipService = friendshipService;
|
||||
}
|
||||
findEmpty(req) {
|
||||
const user = req.user;
|
||||
return this.friendshipService.findAllFriends(user.id);
|
||||
}
|
||||
findOneFriend(relationshipId, req) {
|
||||
const user = req.user;
|
||||
return this.friendshipService.findOneFriend(relationshipId, user.id);
|
||||
}
|
||||
create(createFriendshipDto, req) {
|
||||
const user = req.user;
|
||||
console.log(`User id: ${user.id}\n Friend id: ${createFriendshipDto.requesterId}`);
|
||||
if (user.id === +createFriendshipDto.requesterId)
|
||||
return this.friendshipService.create(createFriendshipDto, user);
|
||||
return new common_1.HttpException('You can\'t request a frienship for another user', common_1.HttpStatus.FORBIDDEN);
|
||||
}
|
||||
update(relationshipId, status, req) {
|
||||
const user = req.user;
|
||||
return this.friendshipService.updateFriendship(relationshipId, user, status);
|
||||
}
|
||||
remove(relationshipId) {
|
||||
return this.friendshipService.removeFriendship(relationshipId);
|
||||
}
|
||||
findAllBlocked(req) {
|
||||
const user = req.user;
|
||||
return this.friendshipService.findAllBlockedFriends(user.id);
|
||||
}
|
||||
findAllPendantFriendshipRequested(req) {
|
||||
const user = req.user;
|
||||
return this.friendshipService.findAllPendantRequestsForFriendship(user.id);
|
||||
}
|
||||
findAllPendantFriendshipReceived(req) {
|
||||
const user = req.user;
|
||||
return this.friendshipService.findAllReceivedRequestsForFriendship(user.id);
|
||||
}
|
||||
};
|
||||
__decorate([
|
||||
(0, common_1.Get)('myfriends'),
|
||||
(0, common_1.UseGuards)(_42guards_1.AuthenticateGuard),
|
||||
__param(0, (0, common_1.Req)()),
|
||||
__metadata("design:type", Function),
|
||||
__metadata("design:paramtypes", [Object]),
|
||||
__metadata("design:returntype", void 0)
|
||||
], FriendshipController.prototype, "findEmpty", null);
|
||||
__decorate([
|
||||
(0, common_1.Get)('myfriends/:relationshipId'),
|
||||
(0, common_1.UseGuards)(_42guards_1.AuthenticateGuard),
|
||||
__param(0, (0, common_1.Param)('relationshipId')),
|
||||
__param(1, (0, common_1.Req)()),
|
||||
__metadata("design:type", Function),
|
||||
__metadata("design:paramtypes", [String, Object]),
|
||||
__metadata("design:returntype", void 0)
|
||||
], FriendshipController.prototype, "findOneFriend", null);
|
||||
__decorate([
|
||||
(0, common_1.Post)('myfriends'),
|
||||
(0, common_1.HttpCode)(common_1.HttpStatus.CREATED),
|
||||
(0, common_1.UseGuards)(_42guards_1.AuthenticateGuard),
|
||||
__param(0, (0, common_1.Body)()),
|
||||
__param(1, (0, common_1.Req)()),
|
||||
__metadata("design:type", Function),
|
||||
__metadata("design:paramtypes", [create_friendship_dto_1.CreateFriendshipDto, Object]),
|
||||
__metadata("design:returntype", void 0)
|
||||
], FriendshipController.prototype, "create", null);
|
||||
__decorate([
|
||||
(0, common_1.Patch)('myfriends/:relationshipId'),
|
||||
(0, common_1.UseGuards)(_42guards_1.AuthenticateGuard),
|
||||
__param(0, (0, common_1.Param)('relationshipId')),
|
||||
__param(1, (0, common_1.Query)('status')),
|
||||
__param(2, (0, common_1.Req)()),
|
||||
__metadata("design:type", Function),
|
||||
__metadata("design:paramtypes", [String, String, Object]),
|
||||
__metadata("design:returntype", void 0)
|
||||
], FriendshipController.prototype, "update", null);
|
||||
__decorate([
|
||||
(0, common_1.Delete)('myfriends/:relationshipId'),
|
||||
(0, common_1.UseGuards)(_42guards_1.AuthenticateGuard),
|
||||
__param(0, (0, common_1.Param)('relationshipId')),
|
||||
__metadata("design:type", Function),
|
||||
__metadata("design:paramtypes", [String]),
|
||||
__metadata("design:returntype", void 0)
|
||||
], FriendshipController.prototype, "remove", null);
|
||||
__decorate([
|
||||
(0, common_1.Get)('blocked'),
|
||||
(0, common_1.UseGuards)(_42guards_1.AuthenticateGuard),
|
||||
__param(0, (0, common_1.Req)()),
|
||||
__metadata("design:type", Function),
|
||||
__metadata("design:paramtypes", [Object]),
|
||||
__metadata("design:returntype", void 0)
|
||||
], FriendshipController.prototype, "findAllBlocked", null);
|
||||
__decorate([
|
||||
(0, common_1.Get)('pending'),
|
||||
(0, common_1.UseGuards)(_42guards_1.AuthenticateGuard),
|
||||
__param(0, (0, common_1.Req)()),
|
||||
__metadata("design:type", Function),
|
||||
__metadata("design:paramtypes", [Object]),
|
||||
__metadata("design:returntype", void 0)
|
||||
], FriendshipController.prototype, "findAllPendantFriendshipRequested", null);
|
||||
__decorate([
|
||||
(0, common_1.Get)('received'),
|
||||
(0, common_1.UseGuards)(_42guards_1.AuthenticateGuard),
|
||||
__param(0, (0, common_1.Req)()),
|
||||
__metadata("design:type", Function),
|
||||
__metadata("design:paramtypes", [Object]),
|
||||
__metadata("design:returntype", void 0)
|
||||
], FriendshipController.prototype, "findAllPendantFriendshipReceived", null);
|
||||
FriendshipController = __decorate([
|
||||
(0, common_1.Controller)('network'),
|
||||
__metadata("design:paramtypes", [friendship_service_1.FriendshipService])
|
||||
], FriendshipController);
|
||||
exports.FriendshipController = FriendshipController;
|
||||
//# sourceMappingURL=friendship.controller.js.map
|
||||
@@ -1 +0,0 @@
|
||||
{"version":3,"file":"friendship.controller.js","sourceRoot":"","sources":["../../src/friendship/friendship.controller.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;AAAA,2CAA+I;AAC/I,0DAAgE;AAEhE,uEAAkE;AAClE,6DAAyD;AAGlD,IAAM,oBAAoB,GAA1B,MAAM,oBAAoB;IAChC,YAA6B,iBAAoC;QAApC,sBAAiB,GAAjB,iBAAiB,CAAmB;IAAI,CAAC;IAKtE,SAAS,CAAQ,GAAG;QACnB,MAAM,IAAI,GAAG,GAAG,CAAC,IAAI,CAAC;QACtB,OAAO,IAAI,CAAC,iBAAiB,CAAC,cAAc,CAAC,IAAI,CAAC,EAAE,CAAC,CAAC;IACvD,CAAC;IAKD,aAAa,CAA0B,cAAsB,EAAS,GAAG;QACxE,MAAM,IAAI,GAAG,GAAG,CAAC,IAAI,CAAC;QACtB,OAAO,IAAI,CAAC,iBAAiB,CAAC,aAAa,CAAC,cAAc,EAAE,IAAI,CAAC,EAAE,CAAC,CAAC;IACtE,CAAC;IAMD,MAAM,CAAS,mBAAwC,EAAS,GAAG;QAClE,MAAM,IAAI,GAAG,GAAG,CAAC,IAAI,CAAC;QACtB,OAAO,CAAC,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;;;;4EAGtC;AAtEW,oBAAoB;IADhC,IAAA,mBAAU,EAAC,SAAS,CAAC;qCAE2B,sCAAiB;GADrD,oBAAoB,CAuEhC;AAvEY,oDAAoB"}
|
||||
@@ -1,18 +0,0 @@
|
||||
import { User } from 'src/users/entities/user.entity';
|
||||
import { Repository } from 'typeorm';
|
||||
import { CreateFriendshipDto } from './dto/create-friendship.dto';
|
||||
import { Friendship } from './entities/friendship.entity';
|
||||
export declare class FriendshipService {
|
||||
private readonly friendshipRepository;
|
||||
private readonly userRepository;
|
||||
constructor(friendshipRepository: Repository<Friendship>, userRepository: Repository<User>);
|
||||
findOneFriend(friendshipId: string, userId: string): Promise<Friendship[]>;
|
||||
findOneBlocked(friendshipId: string): Promise<Friendship[]>;
|
||||
findAllFriends(userId: string): Promise<Friendship[]>;
|
||||
findAllBlockedFriends(userId: string): Promise<Friendship[]>;
|
||||
findAllPendantRequestsForFriendship(userId: string): Promise<Friendship[]>;
|
||||
findAllReceivedRequestsForFriendship(userId: string): Promise<Friendship[]>;
|
||||
create(createFriendshipDto: CreateFriendshipDto, creator: User): Promise<Friendship>;
|
||||
updateFriendship(relationshipId: string, user: User, status: string): Promise<Friendship>;
|
||||
removeFriendship(relationshipId: string): Promise<Friendship>;
|
||||
}
|
||||
@@ -1,123 +0,0 @@
|
||||
"use strict";
|
||||
var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
|
||||
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
||||
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
||||
else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
||||
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
||||
};
|
||||
var __metadata = (this && this.__metadata) || function (k, v) {
|
||||
if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
|
||||
};
|
||||
var __param = (this && this.__param) || function (paramIndex, decorator) {
|
||||
return function (target, key) { decorator(target, key, paramIndex); }
|
||||
};
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
exports.FriendshipService = void 0;
|
||||
const common_1 = require("@nestjs/common");
|
||||
const typeorm_1 = require("@nestjs/typeorm");
|
||||
const user_entity_1 = require("../users/entities/user.entity");
|
||||
const typeorm_2 = require("typeorm");
|
||||
const friendship_entity_1 = require("./entities/friendship.entity");
|
||||
let FriendshipService = class FriendshipService {
|
||||
constructor(friendshipRepository, userRepository) {
|
||||
this.friendshipRepository = friendshipRepository;
|
||||
this.userRepository = userRepository;
|
||||
}
|
||||
async findOneFriend(friendshipId, userId) {
|
||||
const friendship = await this.friendshipRepository.find({ where: { id: +friendshipId, requesterId: userId, status: friendship_entity_1.FriendshipStatus.ACCEPTED } });
|
||||
if (!friendship)
|
||||
throw new common_1.HttpException(`The requested friend not found.`, common_1.HttpStatus.NOT_FOUND);
|
||||
return friendship;
|
||||
}
|
||||
async findOneBlocked(friendshipId) {
|
||||
const friendship = await this.friendshipRepository.find({ where: { id: +friendshipId, status: friendship_entity_1.FriendshipStatus.BLOCKED } });
|
||||
if (!friendship)
|
||||
throw new common_1.HttpException(`The requested user not found.`, common_1.HttpStatus.NOT_FOUND);
|
||||
return friendship;
|
||||
}
|
||||
async findAllFriends(userId) {
|
||||
const friendship = await this.friendshipRepository
|
||||
.createQueryBuilder('friendship')
|
||||
.where('friendship.status = :status', { status: friendship_entity_1.FriendshipStatus.ACCEPTED })
|
||||
.andWhere('friendship.addresseeId = :addressee', { addressee: userId })
|
||||
.orWhere('friendship.requesterId = :requester', { requester: userId })
|
||||
.andWhere('friendship.status = :status', { status: friendship_entity_1.FriendshipStatus.ACCEPTED })
|
||||
.getMany();
|
||||
for (const friend of friendship)
|
||||
console.log("FRIENDSHIP : " + friend.status);
|
||||
return friendship;
|
||||
}
|
||||
async findAllBlockedFriends(userId) {
|
||||
return await this.friendshipRepository
|
||||
.createQueryBuilder('friendship')
|
||||
.where('friendship.requesterId = :requestee', { requestee: userId })
|
||||
.orWhere('friendship.addresseeId = :addressee', { addressee: userId })
|
||||
.andWhere('friendship.status = :status', { status: friendship_entity_1.FriendshipStatus.BLOCKED })
|
||||
.getMany();
|
||||
}
|
||||
async findAllPendantRequestsForFriendship(userId) {
|
||||
return await this.friendshipRepository
|
||||
.createQueryBuilder('friendship')
|
||||
.where('friendship.requesterId = :requestee', { requestee: userId })
|
||||
.andWhere('friendship.status = :status', { status: friendship_entity_1.FriendshipStatus.REQUESTED })
|
||||
.getMany();
|
||||
}
|
||||
async findAllReceivedRequestsForFriendship(userId) {
|
||||
return await this.friendshipRepository
|
||||
.createQueryBuilder('friendship')
|
||||
.where('friendship.addresseeId = :addressee', { addressee: userId })
|
||||
.andWhere('friendship.status = :status', { status: friendship_entity_1.FriendshipStatus.REQUESTED })
|
||||
.getMany();
|
||||
}
|
||||
async create(createFriendshipDto, creator) {
|
||||
const addressee = await this.userRepository.findOneBy({ id: +createFriendshipDto.addresseeId });
|
||||
if (!addressee)
|
||||
throw new common_1.HttpException(`The addressee does not exist.`, common_1.HttpStatus.NOT_FOUND);
|
||||
if (creator.id === addressee.id)
|
||||
throw new common_1.HttpException(`You can't add yourself.`, common_1.HttpStatus.NOT_FOUND);
|
||||
const friendship = await this.friendshipRepository.findOneBy({ requesterId: createFriendshipDto.requesterId, addresseeId: createFriendshipDto.addresseeId });
|
||||
if (friendship) {
|
||||
if (friendship.status && friendship.status === friendship_entity_1.FriendshipStatus.ACCEPTED)
|
||||
throw new common_1.HttpException(`The friendship request has already been accepted.`, common_1.HttpStatus.OK);
|
||||
else if (friendship.status && friendship.status === friendship_entity_1.FriendshipStatus.REQUESTED)
|
||||
throw new common_1.HttpException(`The friendship request has already been sent the ${friendship.date}.`, common_1.HttpStatus.OK);
|
||||
else if (friendship.status && friendship.status === friendship_entity_1.FriendshipStatus.BLOCKED)
|
||||
throw new common_1.HttpException(`We can't do that`, common_1.HttpStatus.OK);
|
||||
else if (friendship.status && friendship.status === friendship_entity_1.FriendshipStatus.DECLINED)
|
||||
throw new common_1.HttpException(`The request has been declined.`, common_1.HttpStatus.OK);
|
||||
}
|
||||
const newFriendship = this.friendshipRepository.create({ requesterId: createFriendshipDto.requesterId, addresseeId: createFriendshipDto.addresseeId, status: friendship_entity_1.FriendshipStatus.REQUESTED });
|
||||
return this.friendshipRepository.save(newFriendship);
|
||||
}
|
||||
async updateFriendship(relationshipId, user, status) {
|
||||
const relation = await this.friendshipRepository.findOneBy({ id: +relationshipId });
|
||||
if (!relation)
|
||||
throw new common_1.HttpException(`The requested relationship not found.`, common_1.HttpStatus.NOT_FOUND);
|
||||
if (status === friendship_entity_1.FriendshipStatus.ACCEPTED)
|
||||
relation.status = friendship_entity_1.FriendshipStatus.ACCEPTED;
|
||||
else if (status === friendship_entity_1.FriendshipStatus.DECLINED)
|
||||
relation.status = friendship_entity_1.FriendshipStatus.DECLINED;
|
||||
else if (status === friendship_entity_1.FriendshipStatus.BLOCKED)
|
||||
relation.status = friendship_entity_1.FriendshipStatus.BLOCKED;
|
||||
else
|
||||
throw new common_1.HttpException(`The status is not valid.`, common_1.HttpStatus.NOT_FOUND);
|
||||
if (relation.status !== status)
|
||||
throw new common_1.HttpException(`We could not update the status.`, common_1.HttpStatus.OK);
|
||||
return this.friendshipRepository.save(relation);
|
||||
}
|
||||
async removeFriendship(relationshipId) {
|
||||
const friendship = await this.friendshipRepository.findOneBy({ id: +relationshipId });
|
||||
if (!friendship)
|
||||
throw new common_1.HttpException(`Your friend could not be deleted.`, common_1.HttpStatus.NOT_FOUND);
|
||||
return this.friendshipRepository.remove(friendship);
|
||||
}
|
||||
};
|
||||
FriendshipService = __decorate([
|
||||
(0, common_1.Injectable)(),
|
||||
__param(0, (0, typeorm_1.InjectRepository)(friendship_entity_1.Friendship)),
|
||||
__param(1, (0, typeorm_1.InjectRepository)(user_entity_1.User)),
|
||||
__metadata("design:paramtypes", [typeorm_2.Repository,
|
||||
typeorm_2.Repository])
|
||||
], FriendshipService);
|
||||
exports.FriendshipService = FriendshipService;
|
||||
//# sourceMappingURL=friendship.service.js.map
|
||||
@@ -1 +0,0 @@
|
||||
{"version":3,"file":"friendship.service.js","sourceRoot":"","sources":["../../src/friendship/friendship.service.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;AAAA,2CAAuE;AACvE,6CAAmD;AACnD,+DAAsD;AACtD,qCAAqC;AAGrC,oEAA4E;AAGrE,IAAM,iBAAiB,GAAvB,MAAM,iBAAiB;IAE7B,YAEkB,oBAA4C,EAE5C,cAAgC;QAFhC,yBAAoB,GAApB,oBAAoB,CAAwB;QAE5C,mBAAc,GAAd,cAAc,CAAkB;IAC9C,CAAC;IAGL,KAAK,CAAC,aAAa,CAAC,YAAoB,EAAE,MAAc;QACvD,MAAM,UAAU,GAAG,MAAM,IAAI,CAAC,oBAAoB,CAAC,IAAI,CAAC,EAAE,KAAK,EAAE,EAAE,EAAE,EAAE,CAAC,YAAY,EAAE,WAAW,EAAE,MAAM,EAAE,MAAM,EAAE,oCAAgB,CAAC,QAAQ,EAAE,EAAE,CAAC,CAAC;QAClJ,IAAI,CAAC,UAAU;YACd,MAAM,IAAI,sBAAa,CAAC,iCAAiC,EAAE,mBAAU,CAAC,SAAS,CAAC,CAAC;QAClF,OAAO,UAAU,CAAC;IACnB,CAAC;IAED,KAAK,CAAC,cAAc,CAAC,YAAoB;QACxC,MAAM,UAAU,GAAG,MAAM,IAAI,CAAC,oBAAoB,CAAC,IAAI,CAAC,EAAE,KAAK,EAAE,EAAE,EAAE,EAAE,CAAC,YAAY,EAAE,MAAM,EAAE,oCAAgB,CAAC,OAAO,EAAE,EAAE,CAAC,CAAC;QAC5H,IAAI,CAAC,UAAU;YACd,MAAM,IAAI,sBAAa,CAAC,+BAA+B,EAAE,mBAAU,CAAC,SAAS,CAAC,CAAC;QAChF,OAAO,UAAU,CAAC;IACnB,CAAC;IAED,KAA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AAC;;YAE3C,MAAM,IAAI,sBAAa,CAAC,0BAA0B,EAAE,mBAAU,CAAC,SAAS,CAAC,CAAC;QAC3E,IAAI,QAAQ,CAAC,MAAM,KAAK,MAAM;YAC7B,MAAM,IAAI,sBAAa,CAAC,iCAAiC,EAAE,mBAAU,CAAC,EAAE,CAAC,CAAC;QAC3E,OAAO,IAAI,CAAC,oBAAoB,CAAC,IAAI,CAAC,QAAQ,CAAC,CAAC;IACjD,CAAC;IAED,KAAK,CAAC,gBAAgB,CAAC,cAAsB;QAC5C,MAAM,UAAU,GAAG,MAAM,IAAI,CAAC,oBAAoB,CAAC,SAAS,CAAC,EAAE,EAAE,EAAE,CAAC,cAAc,EAAE,CAAC,CAAC;QACtF,IAAI,CAAC,UAAU;YACd,MAAM,IAAI,sBAAa,CAAC,mCAAmC,EAAE,mBAAU,CAAC,SAAS,CAAC,CAAC;QACpF,OAAO,IAAI,CAAC,oBAAoB,CAAC,MAAM,CAAC,UAAU,CAAC,CAAC;IACrD,CAAC;CACD,CAAA;AA9GY,iBAAiB;IAD7B,IAAA,mBAAU,GAAE;IAIV,WAAA,IAAA,0BAAgB,EAAC,8BAAU,CAAC,CAAA;IAE5B,WAAA,IAAA,0BAAgB,EAAC,kBAAI,CAAC,CAAA;qCADgB,oBAAU;QAEhB,oBAAU;GANhC,iBAAiB,CA8G7B;AA9GY,8CAAiB"}
|
||||
@@ -1,2 +0,0 @@
|
||||
export declare class FriendshipsModule {
|
||||
}
|
||||
@@ -1,27 +0,0 @@
|
||||
"use strict";
|
||||
var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
|
||||
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
||||
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
||||
else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
||||
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
||||
};
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
exports.FriendshipsModule = void 0;
|
||||
const common_1 = require("@nestjs/common");
|
||||
const typeorm_1 = require("@nestjs/typeorm");
|
||||
const friendship_service_1 = require("./friendship.service");
|
||||
const friendship_controller_1 = require("./friendship.controller");
|
||||
const friendship_entity_1 = require("./entities/friendship.entity");
|
||||
const user_entity_1 = require("../users/entities/user.entity");
|
||||
let FriendshipsModule = class FriendshipsModule {
|
||||
};
|
||||
FriendshipsModule = __decorate([
|
||||
(0, common_1.Module)({
|
||||
imports: [typeorm_1.TypeOrmModule.forFeature([friendship_entity_1.Friendship, user_entity_1.User])],
|
||||
providers: [friendship_service_1.FriendshipService],
|
||||
controllers: [friendship_controller_1.FriendshipController],
|
||||
exports: [friendship_service_1.FriendshipService],
|
||||
})
|
||||
], FriendshipsModule);
|
||||
exports.FriendshipsModule = FriendshipsModule;
|
||||
//# sourceMappingURL=friendships.module.js.map
|
||||
@@ -1 +0,0 @@
|
||||
{"version":3,"file":"friendships.module.js","sourceRoot":"","sources":["../../src/friendship/friendships.module.ts"],"names":[],"mappings":";;;;;;;;;AAAA,2CAAwC;AACxC,6CAAgD;AAChD,6DAAyD;AACzD,mEAA+D;AAC/D,oEAA0D;AAC1D,+DAAqD;AAS9C,IAAM,iBAAiB,GAAvB,MAAM,iBAAiB;CAAG,CAAA;AAApB,iBAAiB;IAP7B,IAAA,eAAM,EAAC;QACP,OAAO,EAAE,CAAC,uBAAa,CAAC,UAAU,CAAC,CAAC,8BAAU,EAAE,kBAAI,CAAC,CAAC,CAAC;QACvD,SAAS,EAAE,CAAC,sCAAiB,CAAC;QAC9B,WAAW,EAAE,CAAC,4CAAoB,CAAC;QACnC,OAAO,EAAE,CAAC,sCAAiB,CAAC;KAC5B,CAAC;GAEW,iBAAiB,CAAG;AAApB,8CAAiB"}
|
||||
@@ -1 +0,0 @@
|
||||
export {};
|
||||
45
srcs/requirements/nestjs/api_back/dist/main.js
vendored
45
srcs/requirements/nestjs/api_back/dist/main.js
vendored
@@ -1,45 +0,0 @@
|
||||
"use strict";
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
const core_1 = require("@nestjs/core");
|
||||
const common_1 = require("@nestjs/common");
|
||||
const app_module_1 = require("./app.module");
|
||||
const session = require("express-session");
|
||||
const passport = require("passport");
|
||||
const redis = require("redis");
|
||||
const connectRedis = require("connect-redis");
|
||||
async function bootstrap() {
|
||||
const app = await core_1.NestFactory.create(app_module_1.AppModule, { cors: true });
|
||||
const port = process.env.PORT || 3001;
|
||||
const client = redis.createClient({
|
||||
socket: { host: process.env.REDIS_HOST, port: parseInt(process.env.REDIS_PORT) },
|
||||
legacyMode: true,
|
||||
});
|
||||
client.connect();
|
||||
const RedisStore = connectRedis(session);
|
||||
client.on('connect', () => {
|
||||
console.log("Redis successfully Connected");
|
||||
});
|
||||
app.useGlobalPipes(new common_1.ValidationPipe({
|
||||
whitelist: true,
|
||||
forbidNonWhitelisted: true,
|
||||
transform: true,
|
||||
transformOptions: {
|
||||
enableImplicitConversion: true,
|
||||
},
|
||||
}));
|
||||
app.setGlobalPrefix('api/v2');
|
||||
app.use(session({
|
||||
cookie: {
|
||||
maxAge: 3600000 * 24,
|
||||
},
|
||||
secret: process.env.COOKIE_SECRET,
|
||||
resave: false,
|
||||
saveUninitialized: false,
|
||||
store: new RedisStore({ client }),
|
||||
}));
|
||||
app.use(passport.initialize());
|
||||
app.use(passport.session());
|
||||
await app.listen(port, () => { console.log(`Listening on port ${port}`); });
|
||||
}
|
||||
bootstrap();
|
||||
//# sourceMappingURL=main.js.map
|
||||
@@ -1 +0,0 @@
|
||||
{"version":3,"file":"main.js","sourceRoot":"","sources":["../src/main.ts"],"names":[],"mappings":";;AAAA,uCAA2C;AAC3C,2CAAgD;AAChD,6CAAyC;AACzC,2CAA2C;AAC3C,qCAAqC;AACrC,+BAA+B;AAC/B,8CAA8C;AAE9C,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C,CAAC;IAC/B,GAAG,CAAC,GAAG,CAAC,QAAQ,CAAC,OAAO,EAAE,CAAC,CAAC;IAC5B,MAAM,GAAG,CAAC,MAAM,CAAC,IAAI,EAAE,GAAG,EAAE,GAAG,OAAO,CAAC,GAAG,CAAC,qBAAqB,IAAI,EAAE,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC;AAC7E,CAAC;AACD,SAAS,EAAE,CAAC"}
|
||||
File diff suppressed because one or more lines are too long
@@ -1,7 +0,0 @@
|
||||
export declare class CreateUsersDto {
|
||||
readonly username: string;
|
||||
readonly fortyTwoId: string;
|
||||
readonly email: string;
|
||||
readonly image_url: string;
|
||||
readonly isEnabledTwoFactorAuth: boolean;
|
||||
}
|
||||
@@ -1,38 +0,0 @@
|
||||
"use strict";
|
||||
var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
|
||||
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
||||
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
||||
else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
||||
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
||||
};
|
||||
var __metadata = (this && this.__metadata) || function (k, v) {
|
||||
if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
|
||||
};
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
exports.CreateUsersDto = void 0;
|
||||
const class_validator_1 = require("class-validator");
|
||||
class CreateUsersDto {
|
||||
}
|
||||
__decorate([
|
||||
(0, class_validator_1.IsString)(),
|
||||
__metadata("design:type", String)
|
||||
], CreateUsersDto.prototype, "username", void 0);
|
||||
__decorate([
|
||||
(0, class_validator_1.IsString)(),
|
||||
__metadata("design:type", String)
|
||||
], CreateUsersDto.prototype, "fortyTwoId", void 0);
|
||||
__decorate([
|
||||
(0, class_validator_1.IsEmail)(),
|
||||
__metadata("design:type", String)
|
||||
], CreateUsersDto.prototype, "email", void 0);
|
||||
__decorate([
|
||||
(0, class_validator_1.IsString)(),
|
||||
__metadata("design:type", String)
|
||||
], CreateUsersDto.prototype, "image_url", void 0);
|
||||
__decorate([
|
||||
(0, class_validator_1.IsBoolean)(),
|
||||
(0, class_validator_1.IsOptional)(),
|
||||
__metadata("design:type", Boolean)
|
||||
], CreateUsersDto.prototype, "isEnabledTwoFactorAuth", void 0);
|
||||
exports.CreateUsersDto = CreateUsersDto;
|
||||
//# sourceMappingURL=create-users.dto.js.map
|
||||
@@ -1 +0,0 @@
|
||||
{"version":3,"file":"create-users.dto.js","sourceRoot":"","sources":["../../../src/users/dto/create-users.dto.ts"],"names":[],"mappings":";;;;;;;;;;;;AAAA,qDAA2E;AAG3E,MAAa,cAAc;CAY1B;AAXA;IAAC,IAAA,0BAAQ,GAAE;;gDACe;AAC1B;IAAC,IAAA,0BAAQ,GAAE;;kDACiB;AAC5B;IAAC,IAAA,yBAAO,GAAE;;6CACa;AACvB;IAAC,IAAA,0BAAQ,GAAE;;iDACgB;AAC3B;IAAC,IAAA,2BAAS,GAAE;IACX,IAAA,4BAAU,GAAE;;8DAC4B;AAX1C,wCAYC"}
|
||||
@@ -1,5 +0,0 @@
|
||||
import { CreateUsersDto } from "./create-users.dto";
|
||||
declare const UpdateUsersDto_base: import("@nestjs/mapped-types").MappedType<Partial<CreateUsersDto>>;
|
||||
export declare class UpdateUsersDto extends UpdateUsersDto_base {
|
||||
}
|
||||
export {};
|
||||
@@ -1,9 +0,0 @@
|
||||
"use strict";
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
exports.UpdateUsersDto = void 0;
|
||||
const mapped_types_1 = require("@nestjs/mapped-types");
|
||||
const create_users_dto_1 = require("./create-users.dto");
|
||||
class UpdateUsersDto extends (0, mapped_types_1.PartialType)(create_users_dto_1.CreateUsersDto) {
|
||||
}
|
||||
exports.UpdateUsersDto = UpdateUsersDto;
|
||||
//# sourceMappingURL=update-users.dto.js.map
|
||||
@@ -1 +0,0 @@
|
||||
{"version":3,"file":"update-users.dto.js","sourceRoot":"","sources":["../../../src/users/dto/update-users.dto.ts"],"names":[],"mappings":";;;AAIA,uDAAmD;AACnD,yDAAoD;AAEpD,MAAa,cAAe,SAAQ,IAAA,0BAAW,EAAC,iCAAc,CAAC;CAAE;AAAjE,wCAAiE"}
|
||||
@@ -1,14 +0,0 @@
|
||||
import { Friendship } from "../../friendship/entities/friendship.entity";
|
||||
export declare class User {
|
||||
id: number;
|
||||
fortyTwoId: string;
|
||||
username: string;
|
||||
email: string;
|
||||
image_url: string;
|
||||
phone: string;
|
||||
status: [string];
|
||||
isEnabledTwoFactorAuth: boolean;
|
||||
secretTwoFactorAuth: string;
|
||||
requesterId: Friendship[];
|
||||
addresseeId: Friendship[];
|
||||
}
|
||||
@@ -1,70 +0,0 @@
|
||||
"use strict";
|
||||
var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
|
||||
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
||||
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
||||
else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
||||
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
||||
};
|
||||
var __metadata = (this && this.__metadata) || function (k, v) {
|
||||
if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
|
||||
};
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
exports.User = void 0;
|
||||
const class_validator_1 = require("class-validator");
|
||||
const typeorm_1 = require("typeorm");
|
||||
const friendship_entity_1 = require("../../friendship/entities/friendship.entity");
|
||||
let User = class User {
|
||||
};
|
||||
__decorate([
|
||||
(0, typeorm_1.PrimaryGeneratedColumn)(),
|
||||
__metadata("design:type", Number)
|
||||
], User.prototype, "id", void 0);
|
||||
__decorate([
|
||||
(0, typeorm_1.Column)({ unique: true }),
|
||||
__metadata("design:type", String)
|
||||
], User.prototype, "fortyTwoId", void 0);
|
||||
__decorate([
|
||||
(0, typeorm_1.Column)(),
|
||||
__metadata("design:type", String)
|
||||
], User.prototype, "username", void 0);
|
||||
__decorate([
|
||||
(0, typeorm_1.Column)(),
|
||||
(0, class_validator_1.IsEmail)(),
|
||||
__metadata("design:type", String)
|
||||
], User.prototype, "email", void 0);
|
||||
__decorate([
|
||||
(0, typeorm_1.Column)({ nullable: true }),
|
||||
__metadata("design:type", String)
|
||||
], User.prototype, "image_url", void 0);
|
||||
__decorate([
|
||||
(0, typeorm_1.Column)({ nullable: true }),
|
||||
__metadata("design:type", String)
|
||||
], User.prototype, "phone", void 0);
|
||||
__decorate([
|
||||
(0, typeorm_1.Column)('json', { nullable: true }),
|
||||
__metadata("design:type", Array)
|
||||
], User.prototype, "status", void 0);
|
||||
__decorate([
|
||||
(0, typeorm_1.Column)({ default: false, nullable: true }),
|
||||
__metadata("design:type", Boolean)
|
||||
], User.prototype, "isEnabledTwoFactorAuth", void 0);
|
||||
__decorate([
|
||||
(0, typeorm_1.Column)({ nullable: true }),
|
||||
__metadata("design:type", String)
|
||||
], User.prototype, "secretTwoFactorAuth", void 0);
|
||||
__decorate([
|
||||
(0, typeorm_1.JoinTable)(),
|
||||
(0, typeorm_1.OneToMany)(type => friendship_entity_1.Friendship, (friendship) => friendship.requesterId),
|
||||
__metadata("design:type", Array)
|
||||
], User.prototype, "requesterId", void 0);
|
||||
__decorate([
|
||||
(0, typeorm_1.JoinTable)(),
|
||||
(0, typeorm_1.OneToMany)(type => friendship_entity_1.Friendship, (friendship) => friendship.addresseeId),
|
||||
__metadata("design:type", Array)
|
||||
], User.prototype, "addresseeId", void 0);
|
||||
User = __decorate([
|
||||
(0, typeorm_1.Entity)('user'),
|
||||
(0, typeorm_1.Unique)(['email', 'username'])
|
||||
], User);
|
||||
exports.User = User;
|
||||
//# sourceMappingURL=user.entity.js.map
|
||||
@@ -1 +0,0 @@
|
||||
{"version":3,"file":"user.entity.js","sourceRoot":"","sources":["../../../src/users/entities/user.entity.ts"],"names":[],"mappings":";;;;;;;;;;;;AACA,qDAAkD;AAClD,qCAA2G;AAC3G,mFAAyE;AAKlE,IAAM,IAAI,GAAV,MAAM,IAAI;CAqChB,CAAA;AAnCA;IAAC,IAAA,gCAAsB,GAAE;;gCACd;AAEX;IAAC,IAAA,gBAAM,EAAC,EAAC,MAAM,EAAE,IAAI,EAAC,CAAC;;wCACJ;AAEnB;IAAC,IAAA,gBAAM,GAAE;;sCACQ;AAEjB;IAAC,IAAA,gBAAM,GAAE;IACR,IAAA,yBAAO,GAAE;;mCACI;AAEd;IAAC,IAAA,gBAAM,EAAC,EAAE,QAAQ,EAAE,IAAI,EAAE,CAAC;;uCACR;AAEnB;IAAC,IAAA,gBAAM,EAAC,EAAE,QAAQ,EAAE,IAAI,EAAE,CAAC;;mCACb;AAEd;IAAC,IAAA,gBAAM,EAAC,MAAM,EAAE,EAAE,QAAQ,EAAE,IAAI,EAAE,CAAC;;oCAClB;AAEjB;IAAC,IAAA,gBAAM,EAAC,EAAE,OAAO,EAAE,KAAK,EAAE,QAAQ,EAAE,IAAI,EAAE,CAAC;;oDACX;AAEhC;IAAC,IAAA,gBAAM,EAAC,EAAE,QAAQ,EAAE,IAAI,EAAE,CAAC;;iDACC;AAE5B;IAAC,IAAA,mBAAS,GAAE;IACX,IAAA,mBAAS,EAAC,IAAI,CAAC,EAAE,CAAC,8BAAU,EAAG,CAAC,UAAU,EAAE,EAAE,CAAC,UAAU,CAAC,WAAW,CAAC;;yCAC7C;AAE1B;IAAC,IAAA,mBAAS,GAAE;IACX,IAAA,mBAAS,EAAC,IAAI,CAAC,EAAE,CAAC,8BAAU,EAAG,CAAC,UAAU,EAAE,EAAE,CAAC,UAAU,CAAC,WAAW,CAAC;;yCAC7C;AApCd,IAAI;IAFhB,IAAA,gBAAM,EAAC,MAAM,CAAC;IACd,IAAA,gBAAM,EAAC,CAAC,OAAO,EAAE,UAAU,CAAC,CAAC;GACjB,IAAI,CAqChB;AArCY,oBAAI"}
|
||||
@@ -1,13 +0,0 @@
|
||||
import { PaginationQueryDto } from 'src/common/dto/pagination-query.dto';
|
||||
import { CreateUsersDto } from './dto/create-users.dto';
|
||||
import { UpdateUsersDto } from './dto/update-users.dto';
|
||||
import { UsersService } from './users.service';
|
||||
export declare class UsersController {
|
||||
private readonly usersService;
|
||||
constructor(usersService: UsersService);
|
||||
findAll(paginationquery: PaginationQueryDto): Promise<import("./entities/user.entity").User[]>;
|
||||
findOne(req: any): Promise<import("./entities/user.entity").User>;
|
||||
create(createUsersDto: CreateUsersDto): Promise<import("./entities/user.entity").User>;
|
||||
update(req: any, usersUpdateDto: UpdateUsersDto): Promise<import("./entities/user.entity").User>;
|
||||
remove(req: any): Promise<import("./entities/user.entity").User>;
|
||||
}
|
||||
@@ -1,89 +0,0 @@
|
||||
"use strict";
|
||||
var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
|
||||
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
||||
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
||||
else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
||||
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
||||
};
|
||||
var __metadata = (this && this.__metadata) || function (k, v) {
|
||||
if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
|
||||
};
|
||||
var __param = (this && this.__param) || function (paramIndex, decorator) {
|
||||
return function (target, key) { decorator(target, key, paramIndex); }
|
||||
};
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
exports.UsersController = void 0;
|
||||
const common_1 = require("@nestjs/common");
|
||||
const _42guards_1 = require("../auth/42/guards/42guards");
|
||||
const pagination_query_dto_1 = require("../common/dto/pagination-query.dto");
|
||||
const create_users_dto_1 = require("./dto/create-users.dto");
|
||||
const update_users_dto_1 = require("./dto/update-users.dto");
|
||||
const users_service_1 = require("./users.service");
|
||||
let UsersController = class UsersController {
|
||||
constructor(usersService) {
|
||||
this.usersService = usersService;
|
||||
}
|
||||
findAll(paginationquery) {
|
||||
return this.usersService.findAll(paginationquery);
|
||||
}
|
||||
findOne(req) {
|
||||
return this.usersService.findOne(req.user.id);
|
||||
}
|
||||
create(createUsersDto) {
|
||||
return this.usersService.create(createUsersDto);
|
||||
}
|
||||
update(req, usersUpdateDto) {
|
||||
return this.usersService.update(req.user.id, usersUpdateDto);
|
||||
}
|
||||
remove(req) {
|
||||
return this.usersService.remove(req.user.id);
|
||||
}
|
||||
};
|
||||
__decorate([
|
||||
(0, common_1.UseGuards)(_42guards_1.AuthenticateGuard),
|
||||
(0, common_1.Get)('all'),
|
||||
__param(0, (0, common_1.Query)()),
|
||||
__metadata("design:type", Function),
|
||||
__metadata("design:paramtypes", [pagination_query_dto_1.PaginationQueryDto]),
|
||||
__metadata("design:returntype", void 0)
|
||||
], UsersController.prototype, "findAll", null);
|
||||
__decorate([
|
||||
(0, common_1.UseGuards)(_42guards_1.AuthenticateGuard),
|
||||
(0, common_1.Get)(),
|
||||
__param(0, (0, common_1.Req)()),
|
||||
__metadata("design:type", Function),
|
||||
__metadata("design:paramtypes", [Object]),
|
||||
__metadata("design:returntype", void 0)
|
||||
], UsersController.prototype, "findOne", null);
|
||||
__decorate([
|
||||
(0, common_1.UseGuards)(_42guards_1.AuthenticateGuard),
|
||||
(0, common_1.Post)(),
|
||||
(0, common_1.HttpCode)(common_1.HttpStatus.CREATED),
|
||||
__param(0, (0, common_1.Body)()),
|
||||
__metadata("design:type", Function),
|
||||
__metadata("design:paramtypes", [create_users_dto_1.CreateUsersDto]),
|
||||
__metadata("design:returntype", void 0)
|
||||
], UsersController.prototype, "create", null);
|
||||
__decorate([
|
||||
(0, common_1.UseGuards)(_42guards_1.AuthenticateGuard),
|
||||
(0, common_1.Patch)(),
|
||||
__param(0, (0, common_1.Req)()),
|
||||
__param(1, (0, common_1.Body)()),
|
||||
__metadata("design:type", Function),
|
||||
__metadata("design:paramtypes", [Object, update_users_dto_1.UpdateUsersDto]),
|
||||
__metadata("design:returntype", void 0)
|
||||
], UsersController.prototype, "update", null);
|
||||
__decorate([
|
||||
(0, common_1.UseGuards)(_42guards_1.AuthenticateGuard),
|
||||
(0, common_1.Delete)(),
|
||||
__param(0, (0, common_1.Req)()),
|
||||
__metadata("design:type", Function),
|
||||
__metadata("design:paramtypes", [Object]),
|
||||
__metadata("design:returntype", void 0)
|
||||
], UsersController.prototype, "remove", null);
|
||||
UsersController = __decorate([
|
||||
(0, common_1.Controller)('user'),
|
||||
__metadata("design:paramtypes", [users_service_1.UsersService])
|
||||
], UsersController);
|
||||
exports.UsersController = UsersController;
|
||||
//# sourceMappingURL=users.controller.js.map
|
||||
@@ -1 +0,0 @@
|
||||
{"version":3,"file":"users.controller.js","sourceRoot":"","sources":["../../src/users/users.controller.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;AAAA,2CAGwB;AACxB,0DAAgE;AAChE,6EAAyE;AACzE,6DAAwD;AACxD,6DAAwD;AAExD,mDAA+C;AAIxC,IAAM,eAAe,GAArB,MAAM,eAAe;IAC3B,YAA6B,YAA0B;QAA1B,iBAAY,GAAZ,YAAY,CAAc;IAAG,CAAC;IAK3D,OAAO,CAAU,eAAoC;QAEpD,OAAO,IAAI,CAAC,YAAY,CAAC,OAAO,CAAC,eAAe,CAAC,CAAC;IACnD,CAAC;IAaD,OAAO,CAAQ,GAAG;QACjB,OAAO,IAAI,CAAC,YAAY,CAAC,OAAO,CAAC,GAAG,CAAC,IAAI,CAAC,EAAE,CAAC,CAAC;IAC/C,CAAC;IAKD,MAAM,CAA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0,0 @@
|
||||
export declare class UsersModule {
|
||||
}
|
||||
@@ -1,27 +0,0 @@
|
||||
"use strict";
|
||||
var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
|
||||
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
||||
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
||||
else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
||||
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
||||
};
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
exports.UsersModule = void 0;
|
||||
const common_1 = require("@nestjs/common");
|
||||
const users_service_1 = require("./users.service");
|
||||
const users_controller_1 = require("./users.controller");
|
||||
const user_entity_1 = require("./entities/user.entity");
|
||||
const typeorm_1 = require("@nestjs/typeorm");
|
||||
const friendship_entity_1 = require("../friendship/entities/friendship.entity");
|
||||
let UsersModule = class UsersModule {
|
||||
};
|
||||
UsersModule = __decorate([
|
||||
(0, common_1.Module)({
|
||||
imports: [typeorm_1.TypeOrmModule.forFeature([user_entity_1.User, friendship_entity_1.Friendship,])],
|
||||
providers: [users_service_1.UsersService],
|
||||
exports: [users_service_1.UsersService],
|
||||
controllers: [users_controller_1.UsersController],
|
||||
})
|
||||
], UsersModule);
|
||||
exports.UsersModule = UsersModule;
|
||||
//# sourceMappingURL=users.module.js.map
|
||||
@@ -1 +0,0 @@
|
||||
{"version":3,"file":"users.module.js","sourceRoot":"","sources":["../../src/users/users.module.ts"],"names":[],"mappings":";;;;;;;;;AAAA,2CAAwC;AACxC,mDAA+C;AAC/C,yDAAqD;AACrD,wDAA8C;AAC9C,6CAAgD;AAChD,gFAAsE;AAU/D,IAAM,WAAW,GAAjB,MAAM,WAAW;CAAG,CAAA;AAAd,WAAW;IANvB,IAAA,eAAM,EAAC;QACP,OAAO,EAAE,CAAC,uBAAa,CAAC,UAAU,CAAC,CAAC,kBAAI,EAAE,8BAAU,EAAE,CAAC,CAAC;QACxD,SAAS,EAAE,CAAC,4BAAY,CAAC;QACzB,OAAO,EAAE,CAAC,4BAAY,CAAC;QACvB,WAAW,EAAE,CAAC,kCAAe,CAAC;KAC9B,CAAC;GACW,WAAW,CAAG;AAAd,kCAAW"}
|
||||
@@ -1,19 +0,0 @@
|
||||
import { User } from './entities/user.entity';
|
||||
import { Repository } from 'typeorm';
|
||||
import { CreateUsersDto } from './dto/create-users.dto';
|
||||
import { UpdateUsersDto } from './dto/update-users.dto';
|
||||
import { Friendship } from '../friendship/entities/friendship.entity';
|
||||
import { PaginationQueryDto } from 'src/common/dto/pagination-query.dto';
|
||||
export declare class UsersService {
|
||||
private readonly userRepository;
|
||||
private readonly friendshipRepository;
|
||||
constructor(userRepository: Repository<User>, friendshipRepository: Repository<Friendship>);
|
||||
findOneByFourtyTwoId(fortytwo_id: string): Promise<User>;
|
||||
findOne(id: string): Promise<User>;
|
||||
findAll(paginationquery: PaginationQueryDto): Promise<User[]>;
|
||||
create(createUserDto: CreateUsersDto): Promise<User>;
|
||||
update(id: string, updateUserDto: UpdateUsersDto): Promise<User>;
|
||||
remove(id: string): Promise<User>;
|
||||
enableTwoFactorAuth(id: string): Promise<import("typeorm").UpdateResult>;
|
||||
setAuthenticatorSecret(id: number, secret: string): Promise<import("typeorm").UpdateResult>;
|
||||
}
|
||||
@@ -1,84 +0,0 @@
|
||||
"use strict";
|
||||
var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
|
||||
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
||||
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
||||
else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
||||
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
||||
};
|
||||
var __metadata = (this && this.__metadata) || function (k, v) {
|
||||
if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
|
||||
};
|
||||
var __param = (this && this.__param) || function (paramIndex, decorator) {
|
||||
return function (target, key) { decorator(target, key, paramIndex); }
|
||||
};
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
exports.UsersService = void 0;
|
||||
const common_1 = require("@nestjs/common");
|
||||
const typeorm_1 = require("@nestjs/typeorm");
|
||||
const user_entity_1 = require("./entities/user.entity");
|
||||
const typeorm_2 = require("typeorm");
|
||||
const friendship_entity_1 = require("../friendship/entities/friendship.entity");
|
||||
let UsersService = class UsersService {
|
||||
constructor(userRepository, friendshipRepository) {
|
||||
this.userRepository = userRepository;
|
||||
this.friendshipRepository = friendshipRepository;
|
||||
}
|
||||
async findOneByFourtyTwoId(fortytwo_id) {
|
||||
const user = await this.userRepository.findOneBy({ fortyTwoId: fortytwo_id });
|
||||
if (!user) {
|
||||
console.log(`The requested user not found.`);
|
||||
return null;
|
||||
}
|
||||
console.log(`The requested user found.`);
|
||||
return user;
|
||||
}
|
||||
async findOne(id) {
|
||||
const user = await this.userRepository.findOneBy({ id: +id });
|
||||
if (!user)
|
||||
throw new common_1.NotFoundException(`The requested user not found.`);
|
||||
return user;
|
||||
}
|
||||
findAll(paginationquery) {
|
||||
const { limit, offset } = paginationquery;
|
||||
return this.userRepository.find({
|
||||
skip: offset,
|
||||
take: limit,
|
||||
});
|
||||
}
|
||||
async create(createUserDto) {
|
||||
if (await this.userRepository.findOneBy({ fortyTwoId: createUserDto.fortyTwoId }))
|
||||
throw new common_1.HttpException(`The user already exists.`, common_1.HttpStatus.CONFLICT);
|
||||
const user = this.userRepository.create(createUserDto);
|
||||
if (!user)
|
||||
throw new common_1.HttpException(`The user could not be created.`, common_1.HttpStatus.NOT_FOUND);
|
||||
return this.userRepository.save(user);
|
||||
}
|
||||
async update(id, updateUserDto) {
|
||||
console.log(`Update user ${id} with ${updateUserDto}`);
|
||||
const user = await this.userRepository.preload(Object.assign({ id: +id }, updateUserDto));
|
||||
if (!user)
|
||||
throw new common_1.HttpException(`The user could not be updated.`, common_1.HttpStatus.NOT_FOUND);
|
||||
return this.userRepository.save(user);
|
||||
}
|
||||
async remove(id) {
|
||||
const user = await this.findOne(id);
|
||||
if (!user)
|
||||
throw new common_1.HttpException(`The user could not be deleted.`, common_1.HttpStatus.NOT_FOUND);
|
||||
return this.userRepository.remove(user);
|
||||
}
|
||||
async enableTwoFactorAuth(id) {
|
||||
return this.userRepository.update(id, { isEnabledTwoFactorAuth: true });
|
||||
}
|
||||
async setAuthenticatorSecret(id, secret) {
|
||||
return this.userRepository.update(id, { secretTwoFactorAuth: secret });
|
||||
}
|
||||
};
|
||||
UsersService = __decorate([
|
||||
(0, common_1.Injectable)(),
|
||||
__param(0, (0, typeorm_1.InjectRepository)(user_entity_1.User)),
|
||||
__param(1, (0, typeorm_1.InjectRepository)(friendship_entity_1.Friendship)),
|
||||
__metadata("design:paramtypes", [typeorm_2.Repository,
|
||||
typeorm_2.Repository])
|
||||
], UsersService);
|
||||
exports.UsersService = UsersService;
|
||||
//# sourceMappingURL=users.service.js.map
|
||||
@@ -1 +0,0 @@
|
||||
{"version":3,"file":"users.service.js","sourceRoot":"","sources":["../../src/users/users.service.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;AAAA,2CAAsG;AACtG,6CAAmD;AAEnD,wDAA8C;AAC9C,qCAA8D;AAG9D,gFAAsE;AAO/D,IAAM,YAAY,GAAlB,MAAM,YAAY;IAExB,YAEiB,cAAgC,EAEhC,oBAA4C;QAF5C,mBAAc,GAAd,cAAc,CAAkB;QAEhC,yBAAoB,GAApB,oBAAoB,CAAwB;IAC1D,CAAC;IAEJ,KAAK,CAAC,oBAAoB,CAAC,WAAmB;QAC7C,MAAM,IAAI,GAAI,MAAM,IAAI,CAAC,cAAc,CAAC,SAAS,CAAC,E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