-
Notifications
You must be signed in to change notification settings - Fork 715
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
refactor: Harmonise Master’s auth signature with authenticateCredenti…
…als (#539) * test(server): Add coverage for the `authenticateCredentials` wrapper * feat(server): Don’t wrap user-provided authentication method * refactor(master): Call auth method with (credentials, playerMetadata) User-provided and default `auth` functions are now called with (credentials, playerMetadata). Checks in the default `auth` implementation that established whether or not we should authenticate have been split into a separate `doesGameRequireAuthentication` method, that is always used regardless of user-defined `auth` functions. * refactor(master): Account for undefined metadata in default auth method If a user were to dispatch an action with a non-existent playerID, we might plausibly get an undefined `playerMetadata` argument. * feat(master): Skip doesGameRequireAuthentication check for custom auth * fix(master): Safely retrieve player metadata Account for undefined parameters when getting player metadata to pass to auth method * test(master): Remove metadata from authentication test * test(master): Improve coverage * refactor(master): Don’t explicitly return undefined in getPlayerMetadata * refactor(master): Rename `credentials` parameter to `actionCredentials` * refactor(master): Tweak how the auth & shouldAuth fields are initialised If the `auth` parameter is not passed as `true` or a custom function, there is no need for the `shouldAuth` function to do anything except always return `false`. Co-authored-by: Nicolo John Davis <nicolodavis@gmail.com>
- Loading branch information
1 parent
5c9430f
commit afdb79e
Showing
3 changed files
with
139 additions
and
131 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.