1
0
forked from Yara724/api

Initial commit after migration to gitea

This commit is contained in:
2026-01-18 11:27:43 +03:30
parent a21039410c
commit ea4b8eb543
196 changed files with 45567 additions and 9 deletions

View File

@@ -0,0 +1,123 @@
import {
Body,
Controller,
Get,
Param,
Patch,
Post,
Req,
UseGuards,
} from "@nestjs/common";
import {
ApiBody,
ApiAcceptedResponse,
ApiResponse,
ApiTags,
ApiBearerAuth,
} from "@nestjs/swagger";
import { ActorAuthService } from "src/auth/auth-services/actor.auth.service";
import {
ForgetPasswordSendCodeDto,
ForgetPasswordVerifyCodeDto,
} from "src/auth/dto/actor/forget-password.actor.dto";
import { LoginActorDto } from "src/auth/dto/actor/login.actor.dto";
import { ActorEditUserProfileDto } from "src/auth/dto/actor/profile.actor.dto";
import {
GenuineRegisterDto,
InsurerRegisterDto,
LegalRegisterDto,
} from "src/auth/dto/actor/register.actor.dto";
import { LocalActorAuthGuard } from "src/auth/guards/actor-local.guard";
import { ClientKey } from "src/decorators/clientKey.decorator";
import { Roles } from "src/decorators/roles.decorator";
import { CurrentUser } from "src/decorators/user.decorator";
@Controller("actor")
@ApiTags("actor")
export class ActorAuthController {
constructor(private readonly actorAuthService: ActorAuthService) {}
@Post("register/genuine")
@ApiBody({ type: GenuineRegisterDto })
async registerGenuine(@Body() body: GenuineRegisterDto) {
return await this.actorAuthService.genuineRegister(body);
}
@Post("register/legal")
@ApiBody({ type: LegalRegisterDto })
async registerLegal(@Body() body: LegalRegisterDto) {
return await this.actorAuthService.legalRegister(body);
}
@Post("register/insurer")
@ApiBody({ type: InsurerRegisterDto })
async registerInsurer(@Body() body: InsurerRegisterDto) {
return await this.actorAuthService.insurerRegister(body);
}
@UseGuards(LocalActorAuthGuard)
@Post("login")
@Roles()
@ApiBody({
type: LoginActorDto,
description: "user verify otp -- call this api and get a tokens",
})
@ApiAcceptedResponse()
async login(@Body() body, @Req() req, @ClientKey() client) {
return await this.actorAuthService.loginActors(req.user);
}
@Post("forget-password")
@ApiBody({
type: ForgetPasswordSendCodeDto,
description: "send otp when call this api",
})
@ApiAcceptedResponse()
@ApiResponse({ type: ForgetPasswordSendCodeDto })
async forgetPassword(@Body() body: ForgetPasswordSendCodeDto) {
return await this.actorAuthService.forgetPasswordSendMail(body.email);
}
@Post("forget-password-verify")
@ApiBody({
type: ForgetPasswordVerifyCodeDto,
description: "send otp when call this api",
})
@ApiAcceptedResponse()
@ApiResponse({ type: ForgetPasswordVerifyCodeDto })
async forgetPasswordVerify(@Body() body: ForgetPasswordVerifyCodeDto) {
const { email, otp, newPassword } = body;
return await this.actorAuthService.forgetPasswordVerify(
email,
otp,
newPassword,
);
}
@Get("register/form/states/list")
async getStates() {
return await this.actorAuthService.getStates();
}
@Get("register/form/cities/list/:stateId")
async getCities(@Param("stateId") stateId: number) {
return await this.actorAuthService.getCities(stateId);
}
@Get("/profile")
@UseGuards(LocalActorAuthGuard)
@ApiBearerAuth()
async getProfile(@CurrentUser() user) {
return await this.actorAuthService.getProfiles(user);
}
@Patch("/profile")
@UseGuards(LocalActorAuthGuard)
@ApiBearerAuth()
async editProfile(
@CurrentUser() user,
@Body() update: ActorEditUserProfileDto,
) {
return await this.actorAuthService.modifyProfile(user, update);
}
}