Get Current User Profile
curl -X GET https://api.sociapp.com/auth/me \
-H "Authorization: Bearer YOUR_ACCESS_TOKEN"
{
"IdUsuario": 15,
"nombre": "Juan",
"apellidos": "García López",
"dni": "12345678A",
"direccion": "Calle Mayor 123",
"CP": "28001",
"provincia": "Madrid",
"poblacion": "Madrid",
"pais": "España",
"email": "[email protected]",
"telefono": "+34 600 123 456",
"fechaalta": "2024-01-15",
"fechabaja": null,
"formadepago": "Transferencia",
"cuota": 25.00,
"categoria": "admin",
"socio": "Socio",
"isVerified": true,
"verificationCode": null,
"verificationExpires": null
}
Endpoint
Authentication
Required: JWT Bearer token in Authorization header
This endpoint requires authentication with a valid access token obtained from login or refresh.
Response Fields
National identification number
Registration date (YYYY-MM-DD format)
Deactivation date (null if active)
Payment method (e.g., “Transferencia”, “Efectivo”, “Tarjeta”)
User category: “admin”, “monitor”, “trabajador”, “voluntario”, or “usuario”
Membership status: “Socio” (member) or “NoSocio” (non-member)
Whether email is verified
Security Notes
The password field is excluded from the response for security. Verification code details are also removed.
- Password Excluded: User’s hashed password is never returned
- Verification Data: Verification codes and expiration are included but should not be displayed to end users
- Token Validation: Endpoint validates JWT signature and expiration
- User Identification: User ID extracted from JWT payload
Use Cases
- Profile Page: Display user information on profile/settings page
- Navigation: Show user name in header/navbar
- Authorization: Check user category/role for feature access
- Session Validation: Verify token is still valid and user exists
Example Integration
// Fetch current user on app load
async function getCurrentUser() {
const token = localStorage.getItem('access_token');
if (!token) {
return null;
}
try {
const response = await fetch('/auth/me', {
headers: {
'Authorization': `Bearer ${token}`
}
});
if (!response.ok) {
// Token invalid or expired
localStorage.removeItem('access_token');
return null;
}
const user = await response.json();
return user;
} catch (error) {
console.error('Failed to fetch user:', error);
return null;
}
}
Vue.js Store Integration
// Pinia store example
import { defineStore } from 'pinia';
export const useAuthStore = defineStore('auth', {
state: () => ({
user: null,
isAuthenticated: false
}),
actions: {
async init() {
try {
const response = await fetch('/auth/me', {
headers: {
'Authorization': `Bearer ${localStorage.getItem('access_token')}`
}
});
if (response.ok) {
this.user = await response.json();
this.isAuthenticated = true;
} else {
this.user = null;
this.isAuthenticated = false;
}
} catch (error) {
console.error('Auth init failed:', error);
this.isAuthenticated = false;
}
}
},
getters: {
isAdmin: (state) => state.user?.categoria === 'admin',
isMonitor: (state) => state.user?.categoria === 'monitor',
fullName: (state) =>
state.user ? `${state.user.nombre} ${state.user.apellidos}` : ''
}
});
- Login - Authenticate and get tokens
- Refresh - Refresh expired access token
- Edit User - Update user profile information