我正在使用 jwt 确认电子邮件,我向用户发送一封电子邮件,其中包含带有令牌的 URL,这是接收用户的 URL 示例:http://localhost:3000/firstlogin?acces_token=eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJlbWFpbCI6InJleWVzZUBncnVwb2ludmVyby5jb20iLCJpYXQiOjE1OTY2Njk4OTcsImV4cCI6MTU5Njc1NjI5N30.dt-qr8h40QfPMOq-DQDfQVHatrAqOubKdlUbV4-nsTw我正在使用查询如何查看。接下来是确认码:const expressJwt = require('express-jwt')const _ =require('lodash')const { OAuth2Client } = require('google-auth-library')const fetch = require('node-fetch')const {validationResult} = require('express-validator')const jwt = require('jsonwebtoken')//Esto es para obtener el error de la base de datos, se puede personalizar para hacerlo amigable.const { errorHandler} =require('../helpers/dbErrorHandling')//el siguiente const se usará para enviar correosconst sgMail = require('@sendgrid/mail')sgMail.setApiKey(process.env.MAIL_KEY)const pool = require('../database/connection')class FirstloginController { async getToken(req, res, next) { const token = (req.params.token); const { access_token } = req.query; try { const decoded = jwt.verify(access_token, process.env.JWT_ACCOUNT_ACTIVATION) res.json({ message: "El acces token es valido", email: decoded}) } catch (err) { next(err); } }}const firstloginController = new FirstloginController();module.exports = firstloginController;
添加回答
举报
0/150
提交
取消