Mock Authentication System
When you enable the Mock Auth toggle in your project settings, Rest Faker automatically provides a complete authentication system with signup, signin, and profile management endpoints.
What You Get
User Registration
Sign up new users with email validation
Secure Login
JWT-based authentication system
Profile Management
View user profiles
Authentication Endpoints
User Registration
POST /api/schema/signupRegister a new user account. Automatically generates a JWT token upon successful registration.
Request Body:
lastName: string (required)
email: string (required)
password: string (required)
Example Request:
// Sign up a new user
fetch('https://api.restfaker.dev/api/schema/signup', {
method: 'POST',
headers: {
'apiToken': 'your_api_token_here',
'Content-Type': 'application/json'
},
body: JSON.stringify({
email: 'user@example.com',
password: 'securePassword123',
firstName: 'John',
lastName: 'Doe'
})
})
.then(response => response.json())
.then(data => console.log(data));Response:
{
"success": true,
"message": "User created successfully",
"data": {
"id": "uuid-string",
"email": "user@example.com",
"firstName": "John",
"lastName": "Doe",
"projectId": "uuid-string",
"createdAt": "2025-01-15T10:30:00Z",
"updatedAt": "2025-01-15T10:30:00Z",
}
}User Login
POST /api/schema/signinAuthenticate an existing user and receive a JWT token for accessing protected routes.
Request Body:
password: string (required)
Example Request:
// Sign in an existing user
fetch('https://api.restfaker.dev/api/schema/signin', {
method: 'POST',
headers: {
'apiToken': 'your_api_token_here',
'Content-Type': 'application/json'
},
body: JSON.stringify({
email: 'user@example.com',
password: 'securePassword123'
})
})
.then(response => response.json())
.then(data => {
// Store the auth token for future requests
const authToken = data.token;
console.log(data);
});Response:
{
"success": true,
"message": "Login successful",
"token": "jwt-token-string"
}Profile Management
GET /api/schema/profileView user profile information. Requires authentication token in the Authorization header.
Get Profile:
// Get user profile (requires auth token)
fetch('https://api.restfaker.dev/api/schema/profile', {
headers: {
'apiToken': 'your_api_token_here',
'Authorization': 'Bearer jwt-token-here',
'Content-Type': 'application/json'
}
})
.then(response => response.json())
.then(data => console.log(data));Profile Response:
{
"success": true,
"data": {
"id": "uuid-string",
"email": "user@example.com",
"projectId": "uuid-string",
"firstName": "John",
"lastName": "Doe",
"createdAt": "2025-01-15T10:30:00Z",
"updatedAt": "2025-01-15T10:30:00Z",
}
}Important Notes
Getting Started with Mock Auth
Enable Mock Auth
Toggle the "Mock Auth" switch in your project settings to activate the authentication system.
Test User Registration
Use the signup endpoint to create test users with fake email addresses.
Implement Frontend Auth
Store JWT tokens and include them in headers for protected API calls.