Code Monkey home page Code Monkey logo

strapi-azerothcore's Introduction

Strapi AzerothCore plugin

AzerothCore integration in Strapi CMS.

NPM Version

โœจ Features

  • Multi-realm support out of the box
  • Registration that also creates an in-game account with the same credentials
  • Login with the same credentials as the in-game account
  • Password reset and password change, which also change the in-game account password
  • Account confirmation
  • Linking of CMS accounts for existing in-game accounts

๐Ÿ“‹โœ”๏ธ Requirements

๐Ÿ› ๏ธ Installation

Install the plugin in your Strapi project:

# using npm
npm install strapi-azerothcore

# using yarn
yarn add strapi-azerothcore

Using a text/code editor, open config/plugins.js (or config/plugins.ts if applicable), add a "strapi-azerothcore" object with an enabled property set to true:

module.exports = ({ env }) => ({
	// ...
	"strapi-azerothcore": {
		enabled: true,
	},
	// ...
});

After installing the plugin, you must rebuild the admin dashboard for it to include the plugin.
Use the build script to rebuild Strapi, or use develop if you'd like to start it as well:

# using npm
npm run build
# or
npm run develop

# using yarn
yarn build
# or
yarn develop

The AzerothCore plugin should now appear in the left pane of your Strapi dashboard: Strapi dashboard left pane plugin

โš™๏ธ Setup

General settings

In the leftmost pane of the Strapi dashboard, go to "AzerothCore", then "General" under the Settings category

  • Allow linking existing game accounts
    Check this to enable creating CMS user accounts for existing AzerothCore accounts. To use this feature, users will need to go through the registration process on your website and make sure to provide the account name and password they're using to log into the game server.

Realms settings

In the leftmost pane of the Strapi dashboard, go to "AzerothCore", then "Realms" under the Settings category

This is where you define your different realms.
Typically you need to have one entry for each row in the realmlist table of your acore_auth database.

You can click the "โž• Create realm" button on the top right corner of the page to add an entry, click one of the table's rows to edit an entry, or click the ๐Ÿ—‘๏ธ button on the right to delete an entry.

Each entry has the following settings:

Characters Database

  • Host: the hostname on which your MySQL database server is running
  • Port: the port on which your MySQL database server is listening, usually 3306
  • Database: the name of the database, usually acore_characters
  • User: the MySQL user to connect with. Make sure that the user has access to the specified database.
  • Password: the user's password

You can press the "๐Ÿ”Œ Test Connection" button to ensure Strapi is able to connect to your database properly.

SOAP

  • Host: the hostname on which your AzerothCore worldserver is running.
    See SOAP.IP in your worldserver.conf.
  • Port: the port on which your AzerothCore worldserver is listening for SOAP connections, usually 7878.
    See SOAP.Port in your worldserver.conf.
  • Username: the AzerothCore account name to connect with.
    Make sure that the account has a security level of 3:
    • If you don't have an account for SOAP already, type this command in the worldserver console:
      account create soap mypassword (change soap and mypassword to your liking, they are the account name and password, respectively)
    • Change the security level to 3 for your SOAP account by typing this command in the worldserver console:
      account set gmlevel soap 3 -1 (change soap to the name of your SOAP account)
    • See AzerothCore's wiki on account creation for more info
  • Password: the SOAP account's password

You can press the "๐Ÿ”Œ Test Connection" button to ensure Strapi is able to connect to your AzerothCore server via SOAP properly.

Auth Database

In the leftmost pane of the Strapi dashboard, go to "AzerothCore", then "Auth Database" under the Settings category

  • Host: the hostname on which your MySQL database server is running
  • Port: the port on which your MySQL database server is listening, usually 3306
  • Database: the name of the database, usually acore_auth
  • User: the MySQL user to connect with. Make sure that the user has access to the specified database.
  • Password: the user's password

You can press the "๐Ÿ”Œ Test Connection" button to ensure Strapi is able to connect to your database properly.

Permissions

In the leftmost pane of the Strapi dashboard, go to "AzerothCore", then "Permissions" under the Settings category

This page displays permission issues that would prevent standard usage of the AzerothCore plugin. Press the "๐Ÿ”จ Fix" button to fix the permissions.
Feel free to ignore the recommendations on this page if you know what you're doing and would like to disable some of the plugin's features via the permissions system.

Users & permissions plugin

In the leftmost pane of the Strapi dashboard, go to "โš™๏ธ Settings", then visit the links under the "Users & permissions plugin" section:

Roles

This section allows you to manage which API endpoints are accessible for logged-in users ("Authenticated" role) and unauthenticated users ("Public" role).

Email templates

You can customize the emails sent to your users here.

Advanced settings

Make sure to change the "Reset password page" and "Redirection url" links:

  • Reset password page: when using the "forgot password" feature, an email is sent with the specified URL. Make sure to input a link to an existing page of your frontend, which needs to call the reset-password API endpoint.
  • Enable email confirmation: enable this if you'd like the CMS to send a confirmation email when registering an account.
  • Redirection url: when registering, a verification email is sent with a link that will redirect to the specified URL. Make sure to input a link to an existing page of your frontend, where you can notify the user that the account was successfully verified, for instance.

๐Ÿ”Œ API endpoints

Your frontend can query the following API endpoints:

Auth

  • Register
    POST /api/strapi-azerothcore/auth/register

    {
    	"username": "myaccount",
    	"email": "[email protected]",
    	"password": "mypassword",
    	"repeatPassword": "mypassword"
    }
  • Login
    POST /api/strapi-azerothcore/auth/login

    {
    	"identifier": "myaccount",
    	"password": "mypassword"
    }

    You can also use the email address to log in:

    {
    	"identifier": "[email protected]",
    	"password": "mypassword"
    }

    Example response:

    {
    	"jwt": "eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpZCI6NzMsImlhdCI6MTcxOTE1MTY0MiwiZXhwIjoxNzIxNzQzNjQyfQ.IoEBek2debDordaC0y1X_mlksjFPx_roi-BoJUeYfIg",
    	"user": {
    		"id": 73,
    		"username": "myaccount",
    		"email": "[email protected]",
    		"provider": "local",
    		"confirmed": true,
    		"blocked": false,
    		"createdAt": "2024-06-20T10:51:14.841Z",
    		"updatedAt": "2024-06-20T10:51:14.841Z"
    	}
    }

    Use the provided jwt in the Authorization header (Authorization: Bearer <your jwt> without the brackets) for the endpoints that need authentication.

  • Forgot Password
    POST /api/auth/forgot-password
    This will send an email to the provided email address if a user is found. The email will contain a link with a code as a query parameter (?code=xxxxx) which is needed for the reset-password endpoint.

    {
    	"email": "[email protected]"
    }
  • Reset Password
    POST /api/strapi-azerothcore/auth/reset-password

    {
    	"code": "xxxxxxxxxxxxxxxxxxxxxxx",
    	"password": "mynewpassword",
    	"passwordConfirmation": "mynewpassword"
    }

    The code is from a link sent via email when using the reset-password endpoint.
    password is the new password to set, and passwordConfirmation must be the value of a "repeat password" field in the form on your frontend.

  • Change Password
    POST /api/strapi-azerothcore/auth/change-password
    ๐Ÿ” Requires authentication

    {
    	"currentPassword": "password",
    	"password": "mynewpassword",
    	"passwordConfirmation": "mynewpassword"
    }
  • Change Email
    POST /api/strapi-azerothcore/auth/change-email
    ๐Ÿ” Requires authentication

    {
    	"email": "[email protected]"
    }

Characters

  • My Characters
    GET /api/strapi-azerothcore/characters/:realmId/my-characters
    ๐Ÿ” Requires authentication
    Returns data about the account's characters for a given realm

  • My Guilds
    GET /api/strapi-azerothcore/characters/:realmId/my-guilds
    ๐Ÿ” Requires authentication
    Returns data about the account's owned guilds for a given realm

Realms

  • Realms
    GET /api/strapi-azerothcore/realms
    Returns data about the realms

User Activity

  • User Activity
    GET /api/strapi-azerothcore/user-activity
    ๐Ÿ” Requires authentication
    ๐Ÿ’ญ You can use query parameters to control sorting and paging
    Returns data about activity for the account, such as logins, failed logins, password changes, etc.

๐Ÿค Contributing

Contributions are greatly appreciated.

If you have a suggestion that would make this project better, feel free to fork the repository and create a Pull Request. You can also open a Feature Request.

โญ๏ธ Show your support

โญ๏ธ Give the project a star if you like it!

Buy Me a Coffee at ko-fi.com

๐Ÿ”— Links

๐ŸŒŽ Community support

strapi-azerothcore's People

Contributors

r-o-b-o-t-o avatar

Watchers

 avatar

strapi-azerothcore's Issues

Reset password (and then create a Strapi account) for Azerothcore-only accounts

Describe your feature request or suggestion in detail

If accounts already exist in the auth DB for azerothcore, and have an email associated with them before the DB was linked to Strapi, it would be a nice feature to have to allow users to reset their passwords by providing the email that exists in the DB, which will also then create an account for them in Strapi. Currently, if they do not remember their password, they will need to have their password reset in the DB manually by an admin before they can login/create an account on Strapi.

Since the plugin is currently able to check to see that an account already exists in the auth DB and then create and tie it to a new account in Strapi if they remember their password, I'm not sure how difficult this would be to implement.

Describe a possible solution to your suggestion

An alternative solution would be to have a feature to perform a mass import of accounts that exist in the Auth DB but not currently in the CMS, that way once the accounts exist in the CMS, users can reset their password through normal means.

Additional context

No response

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.