Git Product home page Git Product logo

first-web-game-lb4's People

Contributors

daveyvr avatar gobackhuoxing avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar

first-web-game-lb4's Issues

interceptor bug

src/interceptors/autorize.interceptor.ts

async intercept(
    invocationCtx: InvocationContext,
    next: () => ValueOrPromise<InvocationResult>,
  ) {
    if (!this.metadata) return await next();

    const result = await next();

    const requiredPermissions = this.metadata.options as RequiredPermissions;
    const user = await this.getCurrentUser();
    if(!this.checkPermissons(user.permissions, requiredPermissions)){
      throw new HttpErrors.Forbidden('INVALID_ACCESS_PERMISSION');
    }
    return result;
  }

Checking permissions should be before:

const result = await next();

because when we have POST, PUT, DELETE endpoint then methods are executed before checking permissions. In response we have error 403 but in database we have changed data.

Solution

async intercept(
    invocationCtx: InvocationContext,
    next: () => ValueOrPromise<InvocationResult>,
  ) {
    if (!this.metadata) return await next();

    

    const requiredPermissions = this.metadata.options as RequiredPermissions;
    const user = await this.getCurrentUser();
    if(!this.checkPermissons(user.permissions, requiredPermissions)){
      throw new HttpErrors.Forbidden('INVALID_ACCESS_PERMISSION');
    }
    const result = await next();
    return result;
  }

Reason for registerInclusionResolver

In the todo list example, after creating a relationship, they register inclusion-resolver

this.todoList = this.createBelongsToAccessorFor(
   'todoList',
   todoListRepositoryGetter,
);

// They add this line to register the resolver
this.registerInclusionResolver('todoList', this.todoList.inclusionResolver);

What does this mean? What is it used for?

I noticed you didn't use it in your demo, I want to know what it does and how it affects the relationship.

MyUserProfile is not well defined

Hello,

I've an issue with the file JWT.service.ts, Typescript says that he cannot convert MyUserProfile to UserProfile

async verifyToken(token: string): Promise<MyUserProfile> {
    if (!token) {
      throw new HttpErrors.Unauthorized(
        `Error verifying token : 'token' is null`,
      );
    }

    const decryptedToken = await verifyAsync(token, TokenServiceConstants.TOKEN_SECRET_VALUE);
    return _.pick(decryptedToken, ['id', 'email', 'name', `permissions`]);
  }

  async generateToken(userProfile: MyUserProfile): Promise<string> {
    return signAsync(userProfile, TokenServiceConstants.TOKEN_SECRET_VALUE, {
      expiresIn: TokenServiceConstants.TOKEN_EXPIRES_IN_VALUE,
    });
  }

Compiler error with find(filter)

I was doing ok until I tried running PT3 of your tutorial. Tutorial and your repo seem to be in agreement with each other. I am running into an error when I attempt to run the full part 3. LB compiler complains about Argument of type 'Filter' is not assignable to parameter of type 'Filter'. I believe this is a typescipt error. How do I fix this?

Checkout my repo (https://github.com/EnergeticPixels/lb4game.git) in the develop => adv-controllers branch, commit #aba5bd5.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.