import axios from 'axios'; import { Cookies } from 'react-cookie'; import cookie from 'cookie'; import moment from 'moment'; import jwt from 'jsonwebtoken'; import Redis from 'ioredis'; import md5 from 'md5'; import { cors } from '../../../lib/cors'; import RedisClient from '../../../lib/RedisClient'; export default async function handler(req, res) { await cors(req, res); const { email, code, } = req.body; let token = ""; const key = md5(`email_code_${ email }`); let existed_data = await RedisClient.get(key); if(existed_data !== null) { const existed_data_json = JSON.parse(existed_data); if(existed_data_json.code === code) { await RedisClient.set(key, JSON.stringify({ code }), 'EX', 900); res.status(200).json({ status: "success" }); } else { res.status(403).json(); } } else { res.status(403).json(); } }