app.js 2.1 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788
  1. if (Meteor.isClient) {
  2. Template.register.events({
  3. "submit form": function(e){
  4. e.preventDefault();
  5. var username = e.target.registerUsername.value;
  6. var email = e.target.registerEmail.value;
  7. var password = e.target.registerPassword.value;
  8. Accounts.createUser({
  9. username: username,
  10. email: email,
  11. password: password
  12. });
  13. },
  14. "click #facebook-login": function(){
  15. Meteor.loginWithFacebook()
  16. },
  17. "click #github-login": function(){
  18. Meteor.loginWithGithub()
  19. },
  20. "click #login": function(){
  21. $("#register-view").hide();
  22. $("#login-view").show();
  23. }
  24. });
  25. Template.login.events({
  26. "submit form": function(e){
  27. e.preventDefault();
  28. var username = e.target.loginUsername.value;
  29. var password = e.target.loginPassword.value;
  30. Meteor.loginWithPassword(username, password);
  31. Accounts.onLoginFailure(function(){
  32. $("input").css("background-color","indianred");
  33. $("input").on("click",function(){
  34. $("input").css({
  35. "background-color": "transparent",
  36. "width": "250px"
  37. });
  38. })
  39. });
  40. },
  41. "click #facebook-login": function(){
  42. Meteor.loginWithFacebook()
  43. },
  44. "click #github-login": function(){
  45. Meteor.loginWithGithub()
  46. },
  47. "click #register": function(){
  48. $("#login-view").hide();
  49. $("#register-view").show();
  50. }
  51. });
  52. Template.dashboard.events({
  53. "click .logout": function(e){
  54. e.preventDefault();
  55. Meteor.logout();
  56. }
  57. })
  58. }
  59. if (Meteor.isServer) {
  60. ServiceConfiguration.configurations.remove({
  61. service: "facebook"
  62. });
  63. ServiceConfiguration.configurations.insert({
  64. service: "facebook",
  65. appId: "1496014310695890",
  66. secret: "9a039f254a08a1488c08bb0737dbd2a6"
  67. });
  68. ServiceConfiguration.configurations.remove({
  69. service: "github"
  70. });
  71. ServiceConfiguration.configurations.insert({
  72. service: "github",
  73. clientId: "dcecd720f47c0e4001f7",
  74. secret: "375939d001ef1a0ca67c11dbf8fb9aeaa551e01b"
  75. });
  76. }