once user put phonenumber and clicked signin i send a post request to get token from…
- User
once user put phonenumber and clicked signin i send a post request to get token from /api/generate_token then i send another post request with otp number and phonenumber which user is typed if otp is ok then i will get a jwt token from backend and now user is logged in using authjs: curl -X 'POST'
'https://api.bimehtakmili.com/api/login/generate_token'
-H 'accept: application/json'
-H 'Content-Type: application/json'
-d '{ "mobile_no": "6588761007" }' curl -X 'POST'
'https://api.bimehtakmili.com/api/login/verify_otp'
-H 'accept: application/json'
-H 'Content-Type: application/json'
-d '{ "mobile_no": "3150744036", "otp": "26561" }' i want to do this flow with next-auth in next 14 with app router once user put phonenumber and clicked signin i send a post request to get token from /api/generate_token then i send another post request with otp number and phonenumber which user is typed if otp is ok then i will get a jwt token from backend and now user is logged in using authjs: curl -X 'POST'
'https://api.bimehtakmili.com/api/login/generate_token'
-H 'accept: application/json'
-H 'Content-Type: application/json'
-d '{ "mobile_no": "6588761007" }' curl -X 'POST'
'https://api.bimehtakmili.com/api/login/verify_otp'
-H 'accept: application/json'
-H 'Content-Type: application/json'
-d '{ "mobile_no": "3150744036", "otp": "26561" }' i want to do this flow with next-auth in next 14 with app router "use client";import { useCRUD } from "@/src/hooks/swr"; import { phoneAtom, stepAtom } from "@/src/store"; import { Button, Form, Input } from "antd"; import { useAtomValue, useSetAtom } from "jotai"; import { ChangeEvent, useState } from "react"; import toast from "react-hot-toast"; import { CiMobile3 } from "react-icons/ci"; import { signIn } from "@/auth";
const EnterPhone = () => { const setStep = useSetAtom(stepAtom); const phone = useAtomValue(phoneAtom); const setPhone = useSetAtom(phoneAtom); const [isLoginLoading, setIsLoginLoading] = useState(false);
const { createItem } = useCRUD(
${process.env.NEXT_PUBLIC_BASE_URL}/login/generate_token, );const handlePhoneChange = (e: ChangeEvent) => { setPhone(e.target.value); };
const handleLogin = async (values: { phone: string }) => { setIsLoginLoading(true); // Set loading state before the API call try { signIn(); // const { data } = result; // if (data?.statusCode === 10) { // if (data?.token) { // setCookie("token", data.token, { // maxAge: 60 * 60 * 24, // path: "/", // secure: true, // sameSite: "strict", // }); // } // signIn(); // toast.success("کد otp به شماره تلفن شما ارسال شد"); // setStep((prev) => prev + 1); // } else { // toast.error("ساخت توکن با مشکل مواجه شد"); // } } catch (error) { console.error("Error during login:", error); // Log the error for debugging toast.error("ساخت توکن با مشکل مواجه شد"); } finally { setIsLoginLoading(false); // Reset loading state after the API call } };
- Assistant
Other models, same or similar prompt
Responses were produced in different, uncontrolled contexts (system prompts, settings, prior turns). This is not a benchmark.