Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

139
Views
La estrategia de autenticación personalizada en LoopBack4 no funciona

Estoy tratando de seguirhttps://loopback.io/doc/en/lb4/Implement-your-own-strategy.html y llegué hasta ahora con los siguientes pasos:

Paso 1: creó una estrategia personalizada (auth/my-strategy.ts) basada en el siguiente patrón

 export class MyAuthenticationStrategy implements AuthenticationStrategy { name: string = 'my'; /** * The 'authenticate' method takes in a given request and returns a user profile * which is an instance of 'UserProfile'. * (A user profile is a minimal subset of a user object) * If the user credentials are valid, this method should return a 'UserProfile' instance. * If the user credentials are invalid, this method should throw an error * If the user credentials are missing, this method should throw an error, or return ' undefined' * and let the authentication action deal with it. * * @param request - Express request object */ authenticate(request: Request): Promise<UserProfile | undefined> { // custom auth logic // throw error or return UserProfile }; }

Paso 2: he registrado la estrategia en application.ts

 // Mount authentication system this.component(AuthenticationComponent); // Register Auth Strategy registerAuthenticationStrategy(this, MyAuthenticationStrategy);

Paso 3: Se agregó lo siguiente en mi clase de controlador

 @authenticate('my') export class XxxController { ... }

No estoy seguro de lo que me estoy perdiendo aquí, ya que no hay ningún error ni mi función de autenticación funciona/ejecuta.

No estoy seguro de lo que hace este paso como se explica aquí . ¿Necesito crear una extensión separada para mi estrategia? más bien, preferiría mantener este código (estrategia de autenticación) dentro del proyecto principal, en lugar de crear un proyecto separado para la extensión.

Por favor ayuda. Gracias,

Gagan

about 4 years ago · Juan Pablo Isaza
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!