7.0 KiB
7.0 KiB
POST Request
Login
curl -X 'POST' \
'http://127.0.0.1:8080/api/v1/auth/login' \
-H 'accept: application/json' \
-H 'Content-Type: application/json' \
-d '{
"email": "beyhan@beyhan.dev",
"password": "1923btO**"
}'
Request URL
http://127.0.0.1:8080/api/v1/auth/login
Server Response
| Code | Details |
|---|---|
| 200 | Success |
Response Body
{
"access_token": "eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJ1c2VyX2lkIjo2LCJlbWFpbCI6ImJleWhhbkBiZXloYW4uZGV2IiwiaXNfYWRtaW4iOnRydWUsImZpcnN0X25hbWUiOiJCZXloYW4iLCJsYXN0X25hbWUiOiJPxJ91ciIsInRva2VuX3R5cGUiOiJhY2Nlc3MiLCJzdWIiOiI2IiwiZXhwIjoxNzcxNzAxNjcyLCJpYXQiOjE3NzE2OTQ0NzJ9.i3OcKU8ChmzR9DirsyRS1gvR0lvAcHuPCNnIvbnvtIc",
"refresh_token": "eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJ1c2VyX2lkIjo2LCJlbWFpbCI6ImJleWhhbkBiZXloYW4uZGV2IiwiaXNfYWRtaW4iOnRydWUsImZpcnN0X25hbWUiOiJCZXloYW4iLCJsYXN0X25hbWUiOiJPxJ91ciIsInRva2VuX3R5cGUiOiJyZWZyZXNoIiwic3ViIjoiNiIsImV4cCI6MTc3NDI4NjQ3MiwiaWF0IjoxNzcxNjk0NDcyfQ.MHG1gK1Jt_6mi2kLXfXpg59QhXaLX-KxFBdMPzQ3X1U",
"user": {
"email": "beyhan@beyhan.dev",
"first_name": "Beyhan",
"id": 6,
"is_admin": true,
"last_name": "Oğur",
"username": "Beyhan Oğur"
}
}
#########################
GET Request
Me
curl -X 'GET' \
'http://127.0.0.1:8080/api/v1/auth/me' \
-H 'accept: application/json' \
-H 'Authorization: Bearer eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJ1c2VyX2lkIjo2LCJlbWFpbCI6ImJleWhhbkBiZXloYW4uZGV2IiwiaXNfYWRtaW4iOnRydWUsImZpcnN0X25hbWUiOiJCZXloYW4iLCJsYXN0X25hbWUiOiJPxJ91ciIsInRva2VuX3R5cGUiOiJhY2Nlc3MiLCJzdWIiOiI2IiwiZXhwIjoxNzcxNzAyMTU2LCJpYXQiOjE3NzE2OTQ5NTZ9.QHid2xqKsdwe1E-vkrZLA7nB_qL3DEcEWztbkFoOaZU'
Request URL
http://127.0.0.1:8080/api/v1/auth/me
Server Response
| Code | Details |
|---|---|
| 200 | Success |
Response Body
{
"user": {
"email": "beyhan@beyhan.dev",
"first_name": "Beyhan",
"id": 6,
"is_admin": true,
"last_name": "Oğur"
}
}
#####################################
POST Request
Refrsfh Token
curl -X 'POST' \
'http://127.0.0.1:8080/api/v1/auth/refresh' \
-H 'accept: application/json' \
-H 'Content-Type: application/json' \
-d '{
"refresh_token": "eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJ1c2VyX2lkIjo2LCJlbWFpbCI6ImJleWhhbkBiZXloYW4uZGV2IiwiaXNfYWRtaW4iOnRydWUsImZpcnN0X25hbWUiOiJCZXloYW4iLCJsYXN0X25hbWUiOiJPxJ91ciIsInRva2VuX3R5cGUiOiJyZWZyZXNoIiwic3ViIjoiNiIsImV4cCI6MTc3NDI4Njk1NiwiaWF0IjoxNzcxNjk0OTU2fQ.IiVn9tmnItk_mmB5Hfp0dRJL_jFHlvp68hDvJROeGqo"
}'
Request URL
http://127.0.0.1:8080/api/v1/auth/refresh
Server Response
| Code | Details |
|---|---|
| 200 | Success |
Response Body
{
"access_token": "eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJ1c2VyX2lkIjo2LCJlbWFpbCI6ImJleWhhbkBiZXloYW4uZGV2IiwiaXNfYWRtaW4iOnRydWUsImZpcnN0X25hbWUiOiJCZXloYW4iLCJsYXN0X25hbWUiOiJPxJ91ciIsInRva2VuX3R5cGUiOiJhY2Nlc3MiLCJzdWIiOiI2IiwiZXhwIjoxNzcxNzAyMzQwLCJpYXQiOjE3NzE2OTUxNDB9.0RqIfDNY3Tc--Waaztgh2dOeKAxpUKWEPfN86SK7kOw",
"refresh_token": "eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJ1c2VyX2lkIjo2LCJlbWFpbCI6ImJleWhhbkBiZXloYW4uZGV2IiwiaXNfYWRtaW4iOnRydWUsImZpcnN0X25hbWUiOiJCZXloYW4iLCJsYXN0X25hbWUiOiJPxJ91ciIsInRva2VuX3R5cGUiOiJyZWZyZXNoIiwic3ViIjoiNiIsImV4cCI6MTc3NDI4NzE0MCwiaWF0IjoxNzcxNjk1MTQwfQ.bZkKmx-4KvlSy4A1Hf9YU5hZAV4e9HQfjtnbyG1PYwY"
}
POST Request
Register
curl -X 'POST' \
'http://127.0.0.1:8080/api/v1/auth/register' \
-H 'accept: application/json' \
-H 'Content-Type: application/json' \
-d '{
"email": "aresss1234@ddddd.com",
"first_name": "adi",
"last_name": "soyadi",
"password": "password",
"username": "username"
}'
Request URL
http://127.0.0.1:8080/api/v1/auth/register
Server Response
| Code | Details |
|---|---|
| 201 | Created |
Response Body
{
"message": "registration successful, please verify your email before login",
"user": {
"email": "aresss1234@ddddd.com",
"email_verified": false,
"first_name": "adi",
"id": 44,
"is_admin": false,
"last_name": "soyadi",
"username": "username"
}
}
####################
email Doğrulama
GET Request
curl -X 'GET' \
'http://127.0.0.1:8080/api/v1/auth/verify-email?token=7f9e5f4d2036e1194856cc1184f0ffbeb86480ecc08d2c5ca18e6da1de0bf829' \
-H 'accept: application/json'
Request URL
http://127.0.0.1:8080/api/v1/auth/verify-email?token=7f9e5f4d2036e1194856cc1184f0ffbeb86480ecc08d2c5ca18e6da1de0bf829
Server Response
| Code | Details |
|---|---|
| 200 | Success |
Response Body
{
"message": "email verified successfully"
}
Resent Email dogrulamasi
url -X 'POST'
'http://127.0.0.1:8080/api/v1/auth/resend-verification'
-H 'accept: application/json'
-H 'Content-Type: application/json'
-d '{
"email": "aressfsdfss1234@ddddd.com"
}'
Request URL
http://127.0.0.1:8080/api/v1/auth/resend-verification
################################
Prompt: Next.js Login/Register Pages with Turnstile Protection
Task:
Using the dependencies and devDependencies listed below, design and implement Login and Register pages for a Next.js application. Both pages should be protected with Turnstile (Cloudflare's CAPTCHA alternative).
Dependencies
{
"class-variance-authority": "^0.7.1",
"clsx": "^2.1.1",
"lucide-react": "^0.575.0",
"next": "16.1.6",
"next-themes": "^0.4.6",
"radix-ui": "^1.4.3",
"react": "19.2.3",
"react-dom": "19.2.3",
"tailwind-merge": "^3.5.0"
}
DevDependencies
{
"@tailwindcss/postcss": "^4",
"@types/node": "^20",
"@types/react": "^19",
"@types/react-dom": "^19",
"eslint": "^9",
"eslint-config-next": "16.1.6",
"shadcn": "^3.8.5",
"tailwindcss": "^4",
"tw-animate-css": "^1.4.0",
"typescript": "^5"
}
Requirements
- Design modern, responsive Login and Register pages using Next.js, React, Radix UI, and TailwindCSS utilities.
- Use Cloudflare Turnstile to protect both forms (login & register) from bot abuse.
- Leverage shadcn UI and lucide-react for enhanced UI and icons.
- Apply type safety using TypeScript and provide user feedback for validation/errors.
- Use best practices for modularity, accessibility (a11y), and theming (next-themes).
- Add animations with tw-animate-css for user interactions (e.g., button hover/submission feedback).
- Style using tailwind-merge, class-variance-authority, and clsx for dynamic class management.
- Lint and format with the provided ESLint setup.
Extra:
- Ensure proper email/password validation and error handling.
- Make the UI adaptive for light/dark themes.
- Provide a clear description in TypeScript doc comments.
References: