Edit this page

Once a user has successfully authenticated, the application should display the user’s domain (and not their wallet address) in the application’s UI to confirm the authorization was successful.

Showing an authenticated user's domain

Showing an authenticated user's domain

Authorizations are stored inside localStorage, so any identically configured UAuth instance has access to the same users. Any integration using @uauth/js or a dependent middleware package can access the authorized user information by instantiating a new UAuth object with the same client options and calling the user() method.

@uauth/jsweb3-onboardweb3-reactweb3modalmoralis
Copy
Copied
import UAuth from '@uauth/js'

const uauth = new UAuth({
  // ... options
})

uauth.user()
  .then((user) => {
    // user exists
    console.log("User information:", user)
  })
  .catch(() => {
    // user does not exist
  })
Copy
Copied
const wallets$ = onboard.state.select('wallets').pipe(share())

wallets$.subscribe(wallet => {
  const unstoppableUser = wallet.find(
    provider => provider.label === 'Unstoppable'
  )

  if (unstoppableUser) console.log(unstoppableUser.instance.user)
})
Copy
Copied
const uauthConnector = new UAuthConnector()

uauthConnector.uauth.user().then().catch()
Copy
Copied
import UAuth from '@uauth/js'

const uauthOptions = {
  clientID: "",
  redirectUri: ""
}

const web3ModalOptions = {
  'custom-uauth': {
    ...uauthOptions}
}

const web3Modal = new Web3Modal(web3ModalOptions)

new UAuth(uauthOptions).user().then().catch()
Copy
Copied
const uauthMoralisConnector = new UAuthMoralisConnector()

uauthMoralisConnector.uauth.user().then().catch()

The user() method will return a UserInfo object containing the information requested by your client scopes. The following key-value pairs would be returned by a login session with the minimum "openid wallet" scopes defined:

Copy
Copied
{
  "sub" : "domain.tld", // The domain used to login
  "wallet_address" : "0x . . . ", // The Ethereum wallet that owns the domain
  "wallet_type_hint" : "web3",
  "eip4361_message" : "identity.unstoppable domains wants you sign in with your Ethereum account: . . . ",
  "eip4361_signature" : "0x . . . ",
}