Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

add: auth middleware to handle token, login, register #13

Open
thomasgazzoni opened this issue May 4, 2018 · 3 comments
Open

add: auth middleware to handle token, login, register #13

thomasgazzoni opened this issue May 4, 2018 · 3 comments

Comments

@thomasgazzoni
Copy link
Contributor

thomasgazzoni commented May 4, 2018

/token -> GET, no params, need to check authorization header
/login -> POST, {username, password} need to check if user exists
/register -> POST, {username, password} need to check if user already exists

/login and /register could be the same

@ghost ghost self-assigned this May 9, 2018
@ghost
Copy link

ghost commented May 9, 2018

Maybe we can add a new class decorator and a column type: 'fixed'.

exp:

@Auth({
  method: 'POST',
  url: '/login',
})
class User {
  
  @Column({
    type: 'fixed',
    value: 'admin'
  })
  username: string;

  @Column({
    type: 'fixed',
    value: 'adminpassword'
  })
  password: string;
}

@thomasgazzoni
Copy link
Contributor Author

thomasgazzoni commented May 10, 2018

Maybe we can have something like this if is possible to handle with the Decorators, (maybe need a new meta data class)

@Route({
  url: '/login',
})

class AuthLogin {

  @Request('get')
  request({username, password}) { // from the params object
     if(username === 'admin' && password) {
       retrurn this.response({token: 'xxxx'});
     } else {
       retrurn this.response({error: 'Username or password are wrong'});
     }
  } 

  @Respose('JSON')
  respose(data) {
     return {
        ...data,
        info: {
          log_time: Date.now(),
       }
     }
  }

}

@ghost
Copy link

ghost commented May 10, 2018

Great!

I will implement a standard config for auth server first.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant