oneclickdapp / ethereum-auth

55 stars 6 forks source link

[Discussion] "Extend" DbAuth #7

Open pi0neerpat opened 3 years ago

pi0neerpat commented 3 years ago

Discussion

Redwood has its own self-hosted auth option now and its :100: ! See dbAuth. I think we should completely overhaul this to "extend/merge" with dbAuth.

Resources

Post I wrote on how to extend dbAuth: https://community.redwoodjs.com/t/combining-dbauth-oauth2/2452

Chatting on Discord with Oliver Lance:

In effect, you are losing part of the native AuthProvider's login mechanism, since you're replacing this whole method (note the client login method is actually full lowercase):

  logIn = async (options?: any) => {
    this.setState({ loading: true })
    const loginOutput = await this.rwClient.login(options)
    await this.reauthenticate()

    return loginOutput
  }

To follow your extension idea, we should actually do:

const dbAuth = new AuthProvider({ type: 'dbAuth' })
dbAuth.rwClient.login = login 

// OR

class AuthProviderOverride extends AuthProvider {
  constructor(props) {
    super(props)

    this.rwClient.login = () => {
      // my login override
    }
}
pi0neerpat commented 3 years ago

Discussion on the Redwood Forums

https://community.redwoodjs.com/t/eth-auth-to-extend-dbauth/2517

olance commented 3 years ago

Glad our discussion inspired you to improve your own integration! 🙂