@@ -6,7 +6,6 @@ import { useRouter } from "next/router";
66import { ToastContainer , toast } from "react-toastify" ;
77import "react-toastify/dist/ReactToastify.css" ;
88import LoadingSpinner from "./components/LoadingSpinner" ;
9- import generateToken from "../utils/generateToken" ;
109import { FaSun , FaMoon , FaSignOutAlt } from "react-icons/fa" ;
1110
1211const Dashboard = ( ) => {
@@ -127,10 +126,13 @@ const Dashboard = () => {
127126 throw new Error ( "Access token not found." ) ;
128127 }
129128
130- const newToken = generateToken ( user . id , process . env . HMAC_KEY ) ;
129+ const response = await axios . post ( "/api/auth/generate-random-token" , {
130+ id : user . id ,
131+ } ) ;
131132
132- // Send the new token to the server to save it, similar to the original logic
133- const response = await axios . post ( "/api/auth/user" , {
133+ const newToken = response . data . token ;
134+ // Send the new token to the server to save it, similar to the original logic
135+ await axios . post ( "/api/auth/user" , {
134136 id : user . id ,
135137 token : newToken ,
136138 } ) ;
@@ -144,8 +146,6 @@ const Dashboard = () => {
144146 toast . info ( "Successfully regenerated!" , {
145147 position : toast . POSITION . BOTTOM_RIGHT ,
146148 } ) ;
147-
148- console . log ( response . data ) ;
149149 } catch ( error ) {
150150 if ( error . message . startsWith ( "Rate limit exceeded" ) ) {
151151 toast . error ( error . message , {
0 commit comments