Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

135
Vistas
SailsJS User Profiles Routing

I'm developing an application in Sails.js, where I have two kinds of users; ordinary users (who should be able to view their own profile), and administrators (who should be able to view/edit/delete every users' profile). For authentication, I've followed this example.

Currently, I'm using the blueprints to directly access this information via a view /views/user/show/userID, e.g. /views/user/show/ + user.id, where the view displays information based on the userID provided (e.g. <%= user.name %>. Currently, anyone can access any profile due to this.

I need to limit access so that a "regular" user only has access to his/her own profile, as well as not be able to edit/delete other users.

I'm not sure how exactly to do this, and I've tried using custom routes, without success.

Any suggestion/answer will be greatly appreciated.

over 4 years ago · Santiago Trujillo
1 Respuestas
Responde la pregunta

0

You can use a policy (i.e. isAdmin.js) where you check if the user has an "administrator" user role and if not you can return a "forbidden" error code.

Then in your config/policies.js you can associate the specific policy isAdmin.js to your api method.

Another valid approach could be defining a isProfileOwner.js policy where you check if the user that submitted the request is the owner of the profile on which he wants to operate

Hope this could help you

over 4 years ago · Santiago Trujillo Denunciar
Responde la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda