Phaser Amazon Cognito
A Phaser plugin that adds user register/login support trough amazon cognito.
- Works on mobile and desktop
- Included TypeScript support
- Async library with promise calls
- Easy to use as phaser plugin
First you want to get a fresh copy of the plugin. You can get it from this repo or from npm, ain't that handy.
npm install @orange-games/phaser-amazon-cognito --save-dev
Next up you'd want to add it to your list of js sources you load into your game:
After adding the script to the page you can activate it by enabling the plugin:
If you are using typescript, you have to user typescript 2.0.0 or higher for the promises to work.
First off you want to set the user pool info using the userPoolId and clientId.
Register a new user to the user pool.
An account has to be confirmed after registration. The code will be in the inbox of the users email.
Resend conformation mail to users email. Will only work if user is not confirmed yet.
Sends a reset code to the user's email address.
Confirm Password Reset
Use the reset code given in the reset email to change password.
Changes the password for the current user. The user has to be logged in.
Logs in a user from the user pool.
Logs out a user from the user pool.
Loading User From LocalStorage
Loads the userState from the localStorage on the device.
Checks if a session has been set. Does not actually check if the user is logged in. Can be used to check if the loadedStorageUser had a session.
Most commands will use the last used user, if you want to call verify on a different user for example you need to call this first. Login or register will automatically set this.
This library uses the amazon-cognito-identity-js library provided by amazon. (https://github.com/aws/amazon-cognito-identity-js)
We at OrangeGames just love playing and creating awesome games. We aren't affiliated with Phaser.io. We just needed some awesome login handling in our awesome HTML5 games. Feel free to use it for enhancing your own awesome games!
Phaser Amazon Cognito is distributed under the MIT license. All 3rd party libraries and components are distributed under their respective license terms.