Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Help required integrating auto login #50

Open
GHMarc opened this issue Oct 18, 2021 · 0 comments
Open

Help required integrating auto login #50

GHMarc opened this issue Oct 18, 2021 · 0 comments

Comments

@GHMarc
Copy link

GHMarc commented Oct 18, 2021

Hi there,

this is not an issue with the chat but with a custom way to integrate this for my userbase. I have connected the chat to mysql to check for a valid username but I am having trouble to actually launch the chat when providing the user details.

Here is my solution so far:

I added:

app.get("/:username/:id?", (req, res) => {
console.log(escape(req.params.username));
console.log(escape(req.params.id));

});

to pass the username and a key to verify a valid user. The console returns the username and id correctly. Now my problem is that I want to auto connect the user to the chat with the given details. So I basically want to remove the option so the user has to enter a username and use my urll provided username to connect him.

Your help would be greatly appreciated. I am more than willng to donate a few bucks to get this working.

My actual code modification is:

app.get("/:username/:id?", (req, res) => {
	con.query(
      "SELECT * FROM users WHERE username = " +
        con.escape(req.params.username) +
        " AND token = "+
        con.escape(req.params.id),
        function (err, result, fields) {
		reslen = result.length;
	  	if (reslen == 0){
		if (err) throw err;
		console.log("Invalid user");
		} else {
		console.log("Valid user");
               // this is the place where I need to connect the username to the chat
		}
		}
    );
});

The mysql connection etc is working fine. It shows in the console if the details were correct or not. I just need a way to actually connect the user to the room with his username. Right now its just stuck loading nothing :)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant