mirror of
https://github.com/ershisan99/flashcards-api.git
synced 2025-12-16 20:59:26 +00:00
fix: remove secrets from code
This commit is contained in:
@@ -7,4 +7,9 @@ AWS_REGION=123
|
||||
AWS_SES_SMTP_HOST=123
|
||||
AWS_SES_SMTP_PORT=123
|
||||
AWS_SES_SMTP_USER=123
|
||||
AWS_SES_SMTP_PASS=123
|
||||
AWS_SES_SMTP_PASS=123
|
||||
AWS_BUCKET_NAME=123
|
||||
AWS_S3_ACCESS_KEY=123
|
||||
AWS_S3_SECRET_ACCESS_KEY=123
|
||||
ADMIN_LOGIN=123
|
||||
ADMIN_PASSWORD=123
|
||||
@@ -5,12 +5,14 @@ import { Observable } from 'rxjs'
|
||||
export class BaseAuthGuard implements CanActivate {
|
||||
canActivate(context: ExecutionContext): boolean | Promise<boolean> | Observable<boolean> {
|
||||
const request = context.switchToHttp().getRequest()
|
||||
const exceptedAuthInput = 'Basic YWRtaW46cXdlcnR5'
|
||||
const acceptedAuthInput =
|
||||
'Basic ' +
|
||||
Buffer.from(`${process.env.ADMIN_LOGIN}:${process.env.ADMIN_PASSWORD}`).toString('base64')
|
||||
|
||||
if (!request.headers || !request.headers.authorization) {
|
||||
throw new UnauthorizedException([{ message: 'No any auth headers' }])
|
||||
throw new UnauthorizedException([{ message: 'No auth headers found' }])
|
||||
} else {
|
||||
if (request.headers.authorization != exceptedAuthInput) {
|
||||
if (request.headers.authorization != acceptedAuthInput) {
|
||||
throw new UnauthorizedException([
|
||||
{
|
||||
message: 'login or password invalid',
|
||||
|
||||
@@ -42,7 +42,7 @@ export class UsersController {
|
||||
return users
|
||||
}
|
||||
|
||||
//@UseGuards(BaseAuthGuard)
|
||||
@UseGuards(BaseAuthGuard)
|
||||
@Post()
|
||||
async create(@Body() createUserDto: CreateUserDto) {
|
||||
return await this.commandBus.execute(
|
||||
|
||||
Reference in New Issue
Block a user