From 5cb1515235df290902fbf2ce2431ad53bfa9d89d Mon Sep 17 00:00:00 2001 From: Stefan Zermatten Date: Fri, 8 May 2015 12:59:38 +0200 Subject: [PATCH] Began implementing useraccounts and permissions properly --- rpg-docs/.meteor/packages | 4 ++ rpg-docs/.meteor/versions | 10 +++++ rpg-docs/Routes/Routes.js | 6 +++ rpg-docs/client/views/notFound/notFound.html | 11 +++++ rpg-docs/lib/constants/useraccountsConfig.js | 47 ++++++++++++++++++++ 5 files changed, 78 insertions(+) create mode 100644 rpg-docs/client/views/notFound/notFound.html create mode 100644 rpg-docs/lib/constants/useraccountsConfig.js diff --git a/rpg-docs/.meteor/packages b/rpg-docs/.meteor/packages index 01c9beda..62e1f17f 100644 --- a/rpg-docs/.meteor/packages +++ b/rpg-docs/.meteor/packages @@ -20,3 +20,7 @@ mike:mocha dburles:mongo-collection-instances percolate:migrations ecwyne:mathjs +useraccounts:polymer +accounts-google +splendido:accounts-meld +email diff --git a/rpg-docs/.meteor/versions b/rpg-docs/.meteor/versions index 54bc8520..6e9c1e6e 100644 --- a/rpg-docs/.meteor/versions +++ b/rpg-docs/.meteor/versions @@ -1,4 +1,6 @@ accounts-base@1.2.0 +accounts-google@1.0.4 +accounts-oauth@1.1.5 accounts-password@1.1.1 accounts-ui@1.1.5 accounts-ui-unstyled@1.1.7 @@ -24,6 +26,7 @@ ejson@1.0.6 email@1.0.6 fastclick@1.0.3 geojson-utils@1.0.3 +google@1.1.5 html-tools@1.0.4 htmljs@1.0.4 http@1.1.0 @@ -54,6 +57,8 @@ mobile-status-bar@1.0.3 momentjs:moment@2.10.3 mongo@1.1.0 npm-bcrypt@0.7.8_2 +oauth@1.1.4 +oauth2@1.1.3 observe-sequence@1.0.6 ordered-dict@1.0.3 package-version-parser@3.0.3 @@ -72,14 +77,19 @@ sanjo:meteor-version@1.0.0 service-configuration@1.0.4 session@1.1.0 sha@1.0.3 +softwarerero:accounts-t9n@1.0.9 spacebars@1.0.6 spacebars-compiler@1.0.6 +splendido:accounts-emails-field@1.2.0 +splendido:accounts-meld@1.3.0 srp@1.0.3 templating@1.1.1 tracker@1.0.7 ui@1.0.6 underscore@1.0.3 url@1.0.4 +useraccounts:core@1.9.1 +useraccounts:polymer@1.9.1 velocity:chokidar@0.12.6_1 velocity:core@0.6.0 velocity:html-reporter@0.5.3 diff --git a/rpg-docs/Routes/Routes.js b/rpg-docs/Routes/Routes.js index d559f196..ffed9def 100644 --- a/rpg-docs/Routes/Routes.js +++ b/rpg-docs/Routes/Routes.js @@ -3,6 +3,12 @@ Router.configure({ layoutTemplate: "layout", }); +Router.plugin("ensureSignedIn", { + except: ["home", "atSignIn", "atSignUp", "atForgotPassword", "notFound"] +}); + +Router.plugin("dataNotFound", {notFoundTemplate: "notFound"}); + Router.map(function() { this.route("/", { name: "home", diff --git a/rpg-docs/client/views/notFound/notFound.html b/rpg-docs/client/views/notFound/notFound.html new file mode 100644 index 00000000..7a996f34 --- /dev/null +++ b/rpg-docs/client/views/notFound/notFound.html @@ -0,0 +1,11 @@ + \ No newline at end of file diff --git a/rpg-docs/lib/constants/useraccountsConfig.js b/rpg-docs/lib/constants/useraccountsConfig.js new file mode 100644 index 00000000..31e2f38d --- /dev/null +++ b/rpg-docs/lib/constants/useraccountsConfig.js @@ -0,0 +1,47 @@ +AccountsTemplates.configure({ + //behaviour + sendVerificationEmail: true, + //appearance + continuousValidation: true, + negativeValidation: true, + negativeFeedback: true, + showValidating: true, + showAddRemoveServices: true, +}); + +AccountsTemplates.configureRoute("enrollAccount"); +AccountsTemplates.configureRoute("forgotPwd"); +AccountsTemplates.configureRoute("resetPwd"); +AccountsTemplates.configureRoute("signIn"); +AccountsTemplates.configureRoute("signUp"); +AccountsTemplates.configureRoute("verifyEmail"); +AccountsTemplates.configureRoute("resendVerificationEmail"); + +if (Meteor.isServer){ + Meteor.methods({ + "userExists": function(username){ + return !!Meteor.users.findOne({username: username}); + }, + }); +} + +AccountsTemplates.addField({ + _id: "username", + type: "text", + required: true, + func: function(value){ + if (Meteor.isClient) { + var self = this; + Meteor.call("userExists", value, function(err, userExists){ + if (!userExists) + self.setSuccess(); + else + self.setError("This username is taken"); + self.setValidating(false); + }); + return; + } + // Server + return Meteor.call("userExists", value); + }, +});