Resource icon

3.3.5a [WEB] FusionGEN - API Module 1.0.2

[WEB] FusionGEN - API Module
FusionGEN - API Callback : How it works?!

psQc6cm.png


Installation
- Place the API folder in "application/modules"
- Setup the API Key (it is recommended to use a minimum 64 character string)
- Set the API to (Enabled / Disabled) in the Admin Panel
- Only PostRequests allowed
- Exclude CSRF Tokens from the API:
Code:
$config['csrf_exclude_uris'] = array('donate', 'vote/callback', 'api/checkLogin');

Example C# .NET 7 Request

C#:
public async void CheckLogin(string username, string password)
        {
            if (txtUser.Text == "" || txtPass.Password == "")
            {
                MessageBox.Show("Benutzername oder Passwort Leer!",  "Launcher", MessageBoxButton.OK, MessageBoxImage.Error);
            }
            else
            {
                var apikey = "YOURAPIKEY";
                var url = "https://yourendpoint.com/api/checkLogin";
                using var client = new HttpClient();
                client.DefaultRequestHeaders.Add("User-Agentt", "WoW Launcher / API");

                var data = new Dictionary<string, string>
                {
                    {"username", username},
                    {"password", password},
                    {"apikey", apikey},
                };

                var content = new FormUrlEncodedContent(data);
                var response = await client.PostAsync(url, content);
                var responseString = await response.Content.ReadAsStringAsync();

                var jsonResult = JsonObject.Parse(responseString);

                string apiDisabled = null;
                string wrongApiKey = null;
                string lockedMinutes = null;
                string loginAccountNotFound = null;
                string loginPasswordError = null;
                string loginSuccess = null;

                var info = jsonResult["info"];

                if (info != null)
                {
                    var apiLocked = info["disabled"];
                    var wrongKey = info["secretkey"];
                    var lockminutes = info["lockminutes"];
                    var noAcc = info["accounterror"];
                    var wrongPass = info["passworderror"];
                    var loginOK = info["success"];

                    if (apiLocked != null)
                    {
                        apiDisabled = apiLocked.ToString();
                    }
                    else if (wrongKey != null)
                    {
                        wrongApiKey = wrongKey.ToString();
                    }
                    else if (lockminutes != null)
                    {
                        lockedMinutes = lockminutes.ToString();
                    }
                    else if (noAcc != null)
                    {
                        loginAccountNotFound = noAcc.ToString();
                    }
                    else if (wrongPass != null)
                    {
                        loginPasswordError = wrongPass.ToString();
                    }
                    else if (loginOK != null)
                    {
                        loginSuccess = loginOK.ToString();
                    }
                }

                if (apiDisabled != null)
                {
                    MessageBox.Show($"Folgende Fehlermeldung liegt vor : {apiDisabled}", "Launcher", MessageBoxButton.OK, MessageBoxImage.Warning);
                }
                else if (wrongApiKey != null)
                {
                    MessageBox.Show($"Folgende Fehlermeldung liegt vor : {wrongApiKey}", "Launcher", MessageBoxButton.OK, MessageBoxImage.Warning);
                }
                else if (lockedMinutes != null)
                {
                    MessageBox.Show($"Deine IP wurde für {lockedMinutes} Minuten gesperrt.", "Launcher", MessageBoxButton.OK, MessageBoxImage.Warning);
                }

                else if (loginAccountNotFound != null)
                {
                    MessageBox.Show("Der Account wurde nicht gefunden.", "Launcher", MessageBoxButton.OK, MessageBoxImage.Warning);
                }

                else if (loginPasswordError != null)
                {

                    MessageBox.Show("Das Passwort ist nicht korrekt.", "Launcher", MessageBoxButton.OK, MessageBoxImage.Warning);
                }

                else if (loginSuccess != null)
                {
                    Hide();
                    var mnw = new Main();
                    Window.GetWindow(this);
                    mnw.ShowDialog();
                }
            }
        }

Any questions will be answered in this case!
Liked By 2 members :
Register & Get access to index
JustZerooo
Author JustZerooo
banned

Posts

6

Likes

10

Resources

2

Version 1.0.2
Downloads 10
Views 893
Last Update
0.00 star(s) 0 ratings
None

Latest updates

  1. API - Corrections / Checks

    - Added some more checks :)...
  2. API - KeyHandling / Login Update

    https://github.com/FusionGen/FusionGEN/pull/185/commits/230fb0f20e2df69b75f65d47ed01e886fb0ca774...

3,376

1,252

9,523

410

Top