Skip to content

Help required integrating auto login #50

@GHMarc

Description

@GHMarc

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 :)

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions