Guest User

Untitled

a guest
Oct 16th, 2018
91
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.79 KB | None | 0 0
  1. component {
  2. this.name = "wspreso_example7";
  3. this.wschannels = [{name="news",cfclistener:"newsHandler"}];
  4.  
  5. public boolean function onApplicationStart() {
  6. return true;
  7. }
  8.  
  9. public boolean function onRequestStart(string req) {
  10. if(structKeyExists(url,"init")) {
  11. applicationStop();
  12. location(url="index.cfm",addToken="false");
  13. }
  14. return true;
  15. }
  16.  
  17. public boolean function onWSAuthenticate(string username, string password, struct connectionInfo) {
  18. writelog(file="application", text="onWSAuth called. #serializeJSON(arguments)#");
  19. if(username == "admin" || username == "bob") {
  20. connectionInfo.authenticated=true;
  21.  
  22. //random additional key
  23. connectionInfo.starwars = 1;
  24.  
  25. if(username == "admin") connectionInfo.role = "admin";
  26.  
  27. return true;
  28. } else {
  29. return false;
  30. }
  31.  
  32. }
  33. }
Add Comment
Please, Sign In to add comment