Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 6 additions & 1 deletion backend/.env.example
Original file line number Diff line number Diff line change
Expand Up @@ -5,5 +5,10 @@ MONGO_URI=mongodb://localhost:27017/prodesk
PORT=3000
NODE_ENV=development

# EMAIL
EMAIL_USER=seuemail@gmail.com
EMAIL_PASS=sua_senha_de_app
EMAIL_PASS=sua_senha_de_app

# DEEP LINKING (Substitua SEU_IP_LOCAL pelo IP IPv4 da sua máquina, ex: 192.168.1.15)
API_URL="http://SEU_IP_LOCAL:3000"
EXPO_URL="exp://SEU_IP_LOCAL:8081"
2 changes: 1 addition & 1 deletion backend/model.nlp

Large diffs are not rendered by default.

15 changes: 14 additions & 1 deletion backend/src/modules/auth/auth.controller.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,11 @@ import {
HttpStatus,
Post,
UseGuards,
Get,
Query,
Res,
} from '@nestjs/common';
import type { Response } from 'express';
import { AuthService } from './auth.service';
import {
CreateAdminDTO,
Expand Down Expand Up @@ -166,4 +170,13 @@ export class AuthController {
body.newPassword,
);
}
}

@Get('redirect-app')
@ApiOperation({ summary: 'Redirecionar usuário para o App Mobile' })
redirectApp(@Query('token') token: string, @Res() res: Response) {
const expoUrl = process.env.EXPO_URL || 'exp://192.168.0.217:8081';
const appLink = `${expoUrl}/--/resetPassword?token=${token}`;

return res.redirect(appLink);
}
}
15 changes: 8 additions & 7 deletions backend/src/modules/email/email.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,19 +11,20 @@ export class EmailService {
},
});

async sendResetPasswordEmail(email: string, token: string) {
const resetLink = `frontend://resetPassword?token=${token}`;
async sendResetPasswordEmail(email: string, token: string) {
const apiUrl = process.env.API_URL || 'http://localhost:3000';
const resetLink = `${apiUrl}/ProDeskApi/auth/redirect-app?token=${token}`;

await this.transporter.sendMail({
to: email,
subject: 'Recuperação de senha',
html: `
to: email,
subject: 'Recuperação de senha',
html: `
<h2>Recuperação de senha</h2>
<p>Clique no link abaixo:</p>
<a href="${resetLink}">Redefinir senha</a>
<p>Se não abrir, copie o link:</p>
<p>${resetLink}</p>
`,
`,
});
}
}
}
Loading