Raised This Month: $ Target: $400
 0% 

Discord/Email Checker


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
Supremache
Veteran Member
Join Date: Sep 2019
Location: Egypt
Old 11-06-2024 , 07:10   Discord/Email Checker
Reply With Quote #1

I am creating a Discord/Email Checker plugin is a CS2 plugin designed to verify and register players on a leaderboard using either their Discord ID or email address. The plugin interacts with a database to store user details and handles email verification through SMTP. This ensures players are authenticated and registered on the leaderboard with a verified account, either by Discord or email, before they can proceed.

Features
- Players can choose to register using their Discord ID or their email address.
- Checks if the provided email is already in the database to prevent duplicate entries.
- Generates a unique verification token for new users registering via email.
- If the player registers via email, the plugin sends a verification email with a unique link. This helps validate user email addresses before adding them to the leaderboard.

How It Works
When a player starts registration, they receive a menu with two options: Discord ID or email registration, and for players who choose Discord, the plugin validates the Discord ID provided in chat to ensure it matches the expected format and when an email is provided, the plugin checks if it already exists in the database. If it’s new, a verification token is generated and stored in the database, The plugin then sends a verification email using SMTP, prompting the player to click a link to confirm their registration.

Once registered, players can be added to the leaderboard, tracking verified users by Discord or email.


I’m new to SourceMod development, and my experience so far has been primarily with CS1.6. I’m looking for feedback on improving the compatibility and fixing issues with my plugin. Any advice, suggestions, or contributions would be greatly appreciated, especially from those with experience in similar authentication or leaderboard plugins!


Backend email verification:
PHP Code:
const express = require('express');
const 
mysql = require('mysql');
const 
Redis = require('redis');
const 
app express();
const 
port 3000;

const 
db mysql.createConnection({
    
host'localhost',
    
user'username',
    
password'password',
    
database'database_name'
});

db.connect(err => {
    if (
err) {
        
console.error('Could not connect to MySQL:'err);
        return;
    }
    
console.log('Connected to MySQL');
});

const 
redisClient Redis.createClient();
redisClient.on('error', (err) => console.error('Redis error:'err));

app.get('/verify', (reqres) => {
    const 
token req.query.token;
    
redisClient.get(token, (erruserID) => {
        if (
err) {
            return 
res.status(500).send('Error verifying token.');
        }
        if (
userID) {
            
db.query('UPDATE users SET verified = 1 WHERE id = ?', [userID], (err) => {
                if (
err) return res.status(500).send('Database error');
                
res.send('Email verified successfully!');
                
redisClient.del(token);
            });
        } else {
            
res.send('Invalid or expired token.');
        }
    });
});

app.listen(port, () => console.log(`Server running on port ${port}`)); 
Attached Files
File Type: sp Get Plugin or Get Source (DiscordEmailChecker.sp - 18 views - 6.9 KB)
__________________
Youtube.com/Supremache

Bank System [Nvault - SQL Support]
VIP System
  • If you think it's that simple, then do it yourself.

Last edited by Supremache; 11-06-2024 at 07:11.
Supremache is offline
xerox8521
Senior Member
Join Date: Sep 2011
Old 11-15-2024 , 06:44   Re: Discord/Email Checker
Reply With Quote #2

SM is not yet available for CS2 it's still being developed which will take time. Just as a side note.

Things I've noticed looking through the code:
- You are mixing old and new syntax choose one and stick to it.

- You shouldn't be hardcoding credentials to your database instead make use of the databases.cfg See here for examples.

- You are using non threaded queries that run on the same thread as the game server does which can cause significant lag if the database server is slow or otherwise busy replying to querys. You should be using threaded queries so gameplay is not interrupted by it.
xerox8521 is offline
Reply


Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT -4. The time now is 05:07.


Powered by vBulletin®
Copyright ©2000 - 2024, vBulletin Solutions, Inc.
Theme made by Freecode