Authenticates the user
ColdFusion 10: Added this function
OnWSAuthenticate(username, password, connectionInfo)
| Parameter | Description | |
|---|---|---|
| username | Name of the user that has to be authenticated. | |
| password | Password for the user. | |
| connectionInfo | A struct that contains the following keys:
|
NO}}
|
The following example uses the function onWSAuthenticate, validates the user, and associates a user role.
Note: For this example to work, ensure that you implement the user-defined functions. |
component
{
this.name="websocketsampleapp23";
this.wschannels=[{name="stocks",cfclistener="stocksListener"}];
function onWSAuthenticate(username, password, connectionInfo)
{
//write appropriate logic to fetch user password in funtion checkPassword
If(checkPassword(username) eq password)
{
connectionInfo.authenticated="YES";
//Role is the custom information that you provide
connectionInfo.role= "admin";
return true;
}
else{
connectionInfo.authenticated="NO";
return false;
}
writedump("#connectionInfo#","console");
}
}
Sign in to your account