forked from Yara724/api
Fixed captcha for prod
This commit is contained in:
@@ -3,15 +3,13 @@ import { ConfigService } from "@nestjs/config";
|
||||
import * as svgCaptcha from "svg-captcha";
|
||||
|
||||
export interface GeneratedCaptcha {
|
||||
text?: string;
|
||||
text: string;
|
||||
image: string;
|
||||
expiresAt: number;
|
||||
}
|
||||
|
||||
@Injectable()
|
||||
export class CaptchaService {
|
||||
constructor(private readonly configService: ConfigService) {}
|
||||
|
||||
generate(): GeneratedCaptcha {
|
||||
const captcha = svgCaptcha.create({
|
||||
size: 5,
|
||||
@@ -24,13 +22,6 @@ export class CaptchaService {
|
||||
fontSize: 52,
|
||||
});
|
||||
|
||||
if (this.configService.get<string>("NODE_ENV") === "production") {
|
||||
return {
|
||||
image: `data:image/svg+xml;base64,${Buffer.from(captcha.data, "utf8").toString("base64")}`,
|
||||
expiresAt: this.buildExpireAt(),
|
||||
};
|
||||
}
|
||||
|
||||
return {
|
||||
text: captcha.text,
|
||||
image: `data:image/svg+xml;base64,${Buffer.from(captcha.data, "utf8").toString("base64")}`,
|
||||
|
||||
Reference in New Issue
Block a user