sourcefuse / loopback4-starter

Loopback 4 starter application. Multi-tenant architecture supported. Authentication, Authorization, Soft deletes, environment vars, Audit logs, included.
MIT License
158 stars 59 forks source link

credentials #18

Closed sherif2011 closed 5 years ago

sherif2011 commented 5 years ago

Hello,

I couldn't find any controllers to set or reset user password. What's the best way to do that? I tried creating a controller using lb4/cli

? What kind of controller would you like to generate? REST Controller with CRUD functions ? What is the name of the model to use with this CRUD repository? UserCredentials ? What is the name of your CRUD repository? UserCredentialsRepository ? What is the type of your ID? number ? What is the base HTTP path name of the CRUD operations? /user-credentials create src\controllers\credentials.controller.ts update src\controllers\index.ts

Controller Credentials was created in src\controllers/

When I try accessing any of the end points I am getting { "error": { "statusCode": 403, "name": "ForbiddenError", "message": "NotAllowedAccess" } }

Thanks!!

samarpan-b commented 5 years ago

You need to add @authorize decorator to the methods. If you want the APIs to be publically available, just do @authenticate(["*"])

sherif2011 commented 5 years ago

Here is my code, and I am still getting same above error. Any clue?

@authorize(['*']) @get('/user-credentials/count', { responses: { '200': { description: 'UserCredentials model count', content: {'application/json': {schema: CountSchema}}, }, }, }) async count( @param.query.object('where', getWhereSchemaFor(UserCredentials)) where?: Where, ): Promise { return await this.userCredentialsRepository.count(where); }

sherif2011 commented 5 years ago

You can check my project here I have tried adding a test controller, which worked perfectly well whether with authorize(['*'] or with specific permissions.... but credentials controller isn't working

sherif2011 commented 5 years ago

Never mind, I got it figured out. It was the inconsistency between controller name and end point name. Thanks!