From 8463450d1c913e22b9d8952a9cc8b2d5461f823a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Darko=20Miji=C4=87?= Date: Fri, 15 Jan 2016 08:38:27 +0100 Subject: [PATCH 01/10] Refactor events to JavaScript --- package.js | 2 +- source/client/{events.coffee => events.js} | 35 +++++++++++----------- 2 files changed, 19 insertions(+), 18 deletions(-) rename source/client/{events.coffee => events.js} (71%) diff --git a/package.js b/package.js index 13b4706..1ad24ca 100644 --- a/package.js +++ b/package.js @@ -37,7 +37,7 @@ Package.onUse(function(api) { // CLIENT api.addFiles([ - 'source/client/events.coffee', + 'source/client/events.js', // Stores 'source/client/stores/users-store.js', 'source/client/stores/signups-store.js', diff --git a/source/client/events.coffee b/source/client/events.js similarity index 71% rename from source/client/events.coffee rename to source/client/events.js index 5a2eede..bf6904a 100644 --- a/source/client/events.coffee +++ b/source/client/events.js @@ -1,54 +1,55 @@ -Space.messaging.define Space.messaging.Event, 'Space.accountsUi', { +Space.messaging.define(Space.messaging.Event, 'Space.accountsUi', { - # SIGNUP + // SIGNUP SignupRequested: { username: Match.OneOf(Username, null), email: Match.OneOf(EmailAddress, null), password: Match.OneOf(Password, null) - } + }, SignupInitiated: { signupId: Guid - } + }, SignupRetried: { signupId: Guid, - } + }, SignupFailed: { signupId: Guid, error: String - } + }, SignupCompleted: { signupId: Guid - } + }, - # LOGIN + // LOGIN LoginRequested: { - user: String + user: String, password: Password - } + }, LoginInitiated: { user: String - } + }, LoginFailed: { - user: String + user: String, error: Meteor.Error - } + }, LoginSucceeded: { user: String - } + }, - # LOGOUT + // LOGOUT - LogoutRequested: {} + LogoutRequested: {}, LoggedOut: {} -} +}); + From a1e8214d66ed21c0afc1bf84d7de31502389f6f7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Darko=20Miji=C4=87?= Date: Fri, 15 Jan 2016 08:42:48 +0100 Subject: [PATCH 02/10] Refactor module to JavaScript --- package.js | 4 ++-- source/client/module.coffee | 25 ------------------------- source/client/module.js | 28 ++++++++++++++++++++++++++++ 3 files changed, 30 insertions(+), 27 deletions(-) delete mode 100644 source/client/module.coffee create mode 100644 source/client/module.js diff --git a/package.js b/package.js index 1ad24ca..30892f1 100644 --- a/package.js +++ b/package.js @@ -27,8 +27,8 @@ Package.onUse(function(api) { ]); // MODULES - api.addFiles(['source/server/module.coffee'], 'server'); - api.addFiles(['source/client/module.coffee'], 'client'); + api.addFiles(['source/server/module.js'], 'server'); + api.addFiles(['source/client/module.js'], 'client'); // SHARED api.addFiles([ diff --git a/source/client/module.coffee b/source/client/module.coffee deleted file mode 100644 index 9e499ce..0000000 --- a/source/client/module.coffee +++ /dev/null @@ -1,25 +0,0 @@ -Space.accountsUi = Space.Module.define 'Space.accountsUi', - - requiredModules: [ - 'Space.flux' - ] - - stores: [ - 'Space.accountsUi.SignupsStore', - 'Space.accountsUi.LoginStore' - 'Space.accountsUi.UsersStore' - ] - - controllers: [ - 'Space.accountsUi.LoginController' - ] - - singletons: [ - 'Space.accountsUi.SignupsTracker' - ] - - onInitialize: -> - @injector.map('SHA256').to SHA256 - @injector.map('Meteor.user').to Meteor.user - @injector.map('Meteor.users').to Meteor.users - @injector.map('Space.accountsUi.Signups').asStaticValue() diff --git a/source/client/module.js b/source/client/module.js new file mode 100644 index 0000000..dba45e8 --- /dev/null +++ b/source/client/module.js @@ -0,0 +1,28 @@ +Space.accountsUi = Space.Module.define('Space.accountsUi', { + + requiredModules: [ + 'Space.flux' + ], + + stores: [ + 'Space.accountsUi.SignupsStore', + 'Space.accountsUi.LoginStore', + 'Space.accountsUi.UsersStore' + ], + + controllers: [ + 'Space.accountsUi.LoginController' + ], + + singletons: [ + 'Space.accountsUi.SignupsTracker' + ], + + onInitialize() { + this.injector.map('SHA256').to(SHA256); + this.injector.map('Meteor.user').to(Meteor.user); + this.injector.map('Meteor.users').to(Meteor.users); + this.injector.map('Space.accountsUi.Signups').asStaticValue(); + } + +}); From 24ba3532195de1f1997b763186de40d0f60f011c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Darko=20Miji=C4=87?= Date: Fri, 15 Jan 2016 08:47:20 +0100 Subject: [PATCH 03/10] Refactor module to JavaScript --- source/server/module.coffee | 17 ----------------- source/server/module.js | 19 +++++++++++++++++++ 2 files changed, 19 insertions(+), 17 deletions(-) delete mode 100644 source/server/module.coffee create mode 100644 source/server/module.js diff --git a/source/server/module.coffee b/source/server/module.coffee deleted file mode 100644 index b23c81c..0000000 --- a/source/server/module.coffee +++ /dev/null @@ -1,17 +0,0 @@ -class Space.accountsUi extends Space.Module - - @publish this, 'Space.accountsUi' - - requiredModules: [ - 'Space.accounts' - ] - - singletons: [ - 'Space.accountsUi.SignupsPublication' - ] - - onInitialize: -> - @injector.map('SHA256').to SHA256 - @injector.map('Meteor.user').to Meteor.user - @injector.map('Meteor.users').to Meteor.users - @injector.map('Space.accountsUi.Signups').asStaticValue() diff --git a/source/server/module.js b/source/server/module.js new file mode 100644 index 0000000..a375e15 --- /dev/null +++ b/source/server/module.js @@ -0,0 +1,19 @@ +Space.accountsUi = Space.Module.define('Space.accountsUi', { + + requiredModules: [ + 'Space.accounts' + ], + + singletons: [ + 'Space.accountsUi.SignupsPublication' + ], + + onInitialize() { + this.injector.map('SHA256').to(SHA256); + this.injector.map('Meteor.user').to(Meteor.user); + this.injector.map('Meteor.users').to(Meteor.users); + this.injector.map('Space.accountsUi.Signups').asStaticValue(); + } + +}); + From 8040ac19896bba6d2ef2a8c8892f04cf57076d7f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Darko=20Miji=C4=87?= Date: Fri, 15 Jan 2016 11:31:59 +0100 Subject: [PATCH 04/10] Add support for google login --- package.js | 2 ++ source/client/controllers/login-controller.js | 18 +++++++++++++++++- source/client/events.js | 15 +++++++++++++++ 3 files changed, 34 insertions(+), 1 deletion(-) diff --git a/package.js b/package.js index 30892f1..f59720b 100644 --- a/package.js +++ b/package.js @@ -21,6 +21,8 @@ Package.onUse(function(api) { 'check', 'accounts-base', 'accounts-password', + 'accounts-google', + 'service-configuration', 'space:vo-user@0.2.1', 'space:accounts@0.1.2', 'space:flux@0.6.0' diff --git a/source/client/controllers/login-controller.js b/source/client/controllers/login-controller.js index 50332bd..5f808f0 100644 --- a/source/client/controllers/login-controller.js +++ b/source/client/controllers/login-controller.js @@ -8,7 +8,8 @@ Space.messaging.Controller.extend(Space.accountsUi, 'LoginController', { eventSubscriptions() { return [{ 'Space.accountsUi.LoginRequested': this._onLoginRequested, - 'Space.accountsUi.LogoutRequested': this._onLogoutRequested + 'Space.accountsUi.LogoutRequested': this._onLogoutRequested, + 'Space.accountsUi.LoginWithGoogleRequested': this._onLoginWithGoogleRequested, }]; }, @@ -30,5 +31,20 @@ Space.messaging.Controller.extend(Space.accountsUi, 'LoginController', { _onLogoutRequested() { this.meteor.logout(); this.publish(new Space.accountsUi.LoggedOut()); + }, + + _onLoginWithGoogleRequested() { + this.meteor.loginWithGoogle({requestPermissions: ['email']}, (error) => { + if (error) { + let errorEvent = new Space.accountsUi.LoginWithGoogleFailed({ + error: error + }); + this.publish(errorEvent); + } else { + this.publish(new Space.accountsUi.LoginWithGoogleSucceeded({})); + } + }); + this.publish(new Space.accountsUi.LoginWithGoogleInitiated({})); } + }); diff --git a/source/client/events.js b/source/client/events.js index bf6904a..318d96d 100644 --- a/source/client/events.js +++ b/source/client/events.js @@ -45,6 +45,21 @@ Space.messaging.define(Space.messaging.Event, 'Space.accountsUi', { user: String }, + // LOGIN WITH GOOGLE + LoginWithGoogleRequested: { + + }, + + LoginWithGoogleInitiated: { + }, + + LoginWithGoogleFailed: { + error: Match.OneOf(Meteor.Error, ServiceConfiguration.ConfigError) + }, + + LoginWithGoogleSucceeded: { + }, + // LOGOUT LogoutRequested: {}, From 6d8a592b29dcfc56773c506e91517db08ecfcddf Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Darko=20Miji=C4=87?= Date: Sun, 17 Jan 2016 21:34:10 +0100 Subject: [PATCH 05/10] Unify events for logging in with service and username/email and password --- source/client/controllers/login-controller.js | 71 ++++++++++++------- source/client/events.js | 31 +++----- 2 files changed, 54 insertions(+), 48 deletions(-) diff --git a/source/client/controllers/login-controller.js b/source/client/controllers/login-controller.js index 5f808f0..474c373 100644 --- a/source/client/controllers/login-controller.js +++ b/source/client/controllers/login-controller.js @@ -8,43 +8,60 @@ Space.messaging.Controller.extend(Space.accountsUi, 'LoginController', { eventSubscriptions() { return [{ 'Space.accountsUi.LoginRequested': this._onLoginRequested, - 'Space.accountsUi.LogoutRequested': this._onLogoutRequested, - 'Space.accountsUi.LoginWithGoogleRequested': this._onLoginWithGoogleRequested, + 'Space.accountsUi.LogoutRequested': this._onLogoutRequested }]; }, _onLoginRequested(event) { - let password = event.password.toString(); - this.meteor.loginWithPassword(event.user, password, (error) => { - if (error) { - this.publish(new Space.accountsUi.LoginFailed({ - user: event.user, - error: error - })); - } else { - this.publish(new Space.accountsUi.LoginSucceeded({ user: event.user })); + + if (!event.loginType.isService()) { + let password = event.password.toString(); + this.meteor.loginWithPassword(event.user, password, (error) => { + if (error) { + this.publish(new Space.accountsUi.LoginFailed({ + user: event.user, + error: error, + loginType: event.loginType + })); + } else { + this.publish(new Space.accountsUi.LoginSucceeded({ + user: event.user, + loginType: event.loginType + })); + } + }); + this.publish(new Space.accountsUi.LoginInitiated({ + user: event.user, + loginType: event.loginType + })); + } else { + switch(event.loginType.loginType) { + case 'google': + this.meteor.loginWithGoogle({requestPermissions: ['email']}, (error) => { + if (error) { + let errorEvent = new Space.accountsUi.LoginFailed({ + error: error, + loginType: event.loginType + }); + this.publish(errorEvent); + } else { + this.publish(new Space.accountsUi.LoginSucceeded({ + loginType: event.loginType + })); + } + }); + this.publish(new Space.accountsUi.LoginInitiated({ + loginType: event.loginType + })); + break; } - }); - this.publish(new Space.accountsUi.LoginInitiated({ user: event.user })); + } + }, _onLogoutRequested() { this.meteor.logout(); this.publish(new Space.accountsUi.LoggedOut()); - }, - - _onLoginWithGoogleRequested() { - this.meteor.loginWithGoogle({requestPermissions: ['email']}, (error) => { - if (error) { - let errorEvent = new Space.accountsUi.LoginWithGoogleFailed({ - error: error - }); - this.publish(errorEvent); - } else { - this.publish(new Space.accountsUi.LoginWithGoogleSucceeded({})); - } - }); - this.publish(new Space.accountsUi.LoginWithGoogleInitiated({})); } }); diff --git a/source/client/events.js b/source/client/events.js index 318d96d..1ed2dd6 100644 --- a/source/client/events.js +++ b/source/client/events.js @@ -28,36 +28,25 @@ Space.messaging.define(Space.messaging.Event, 'Space.accountsUi', { // LOGIN LoginRequested: { - user: String, - password: Password + user: Match.OneOf(null, Username, EmailAddress), + password: Match.OneOf(null, Password), + loginType: LoginType }, LoginInitiated: { - user: String + user: Match.OneOf(null, Username, EmailAddress), + loginType: LoginType }, LoginFailed: { - user: String, - error: Meteor.Error - }, - - LoginSucceeded: { - user: String - }, - - // LOGIN WITH GOOGLE - LoginWithGoogleRequested: { - - }, - - LoginWithGoogleInitiated: { - }, - - LoginWithGoogleFailed: { + user: Match.OneOf(null, Username, EmailAddress), + loginType: LoginType, error: Match.OneOf(Meteor.Error, ServiceConfiguration.ConfigError) }, - LoginWithGoogleSucceeded: { + LoginSucceeded: { + user: Match.OneOf(null, Username, EmailAddress), + loginType: LoginType }, // LOGOUT From 32b7c6e27ed066167a88049a58c4b031021a1f7e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Darko=20Miji=C4=87?= Date: Sun, 17 Jan 2016 21:38:18 +0100 Subject: [PATCH 06/10] Use correct version of space accounts --- git-packages.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/git-packages.json b/git-packages.json index 405ed13..d32d844 100644 --- a/git-packages.json +++ b/git-packages.json @@ -17,7 +17,7 @@ }, "space:accounts": { "git":"https://github.com/meteor-space/accounts.git", - "branch": "develop" + "branch": "feature/login-with-google" }, "space:vo-user": { "git":"https://github.com/meteor-space/vo-user.git", From ebc40d1d652e32ec27630c49b5fbd3303def16e6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Darko=20Miji=C4=87?= Date: Sun, 17 Jan 2016 21:39:48 +0100 Subject: [PATCH 07/10] Fix indentation --- source/client/module.js | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/source/client/module.js b/source/client/module.js index dba45e8..7bde9bf 100644 --- a/source/client/module.js +++ b/source/client/module.js @@ -19,10 +19,10 @@ Space.accountsUi = Space.Module.define('Space.accountsUi', { ], onInitialize() { - this.injector.map('SHA256').to(SHA256); - this.injector.map('Meteor.user').to(Meteor.user); - this.injector.map('Meteor.users').to(Meteor.users); - this.injector.map('Space.accountsUi.Signups').asStaticValue(); + this.injector.map('SHA256').to(SHA256); + this.injector.map('Meteor.user').to(Meteor.user); + this.injector.map('Meteor.users').to(Meteor.users); + this.injector.map('Space.accountsUi.Signups').asStaticValue(); } }); From 4869e762f8d30a903cee948f4bbdb01238024dd9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Darko=20Miji=C4=87?= Date: Sun, 17 Jan 2016 22:55:29 +0100 Subject: [PATCH 08/10] Make events more flexible --- source/client/events.js | 17 +++++++++-------- 1 file changed, 9 insertions(+), 8 deletions(-) diff --git a/source/client/events.js b/source/client/events.js index 1ed2dd6..09752a0 100644 --- a/source/client/events.js +++ b/source/client/events.js @@ -3,9 +3,10 @@ Space.messaging.define(Space.messaging.Event, 'Space.accountsUi', { // SIGNUP SignupRequested: { - username: Match.OneOf(Username, null), - email: Match.OneOf(EmailAddress, null), - password: Match.OneOf(Password, null) + username: Match.Optional(Username), + email: Match.Optional(EmailAddress), + password: Match.Optional(Password), + loginType: LoginType }, SignupInitiated: { @@ -28,24 +29,24 @@ Space.messaging.define(Space.messaging.Event, 'Space.accountsUi', { // LOGIN LoginRequested: { - user: Match.OneOf(null, Username, EmailAddress), - password: Match.OneOf(null, Password), + user: Match.Optional(Match.OneOf(Username, EmailAddress)), + password: Match.Optional(Password), loginType: LoginType }, LoginInitiated: { - user: Match.OneOf(null, Username, EmailAddress), + user: Match.Optional(Match.OneOf(Username, EmailAddress)), loginType: LoginType }, LoginFailed: { - user: Match.OneOf(null, Username, EmailAddress), + user: Match.Optional(Match.OneOf(Username, EmailAddress)), loginType: LoginType, error: Match.OneOf(Meteor.Error, ServiceConfiguration.ConfigError) }, LoginSucceeded: { - user: Match.OneOf(null, Username, EmailAddress), + user: Match.Optional(Match.OneOf(Username, EmailAddress)), loginType: LoginType }, From 24680fc528e30b87e75e3a8c6252aa491331bbd6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Darko=20Miji=C4=87?= Date: Mon, 18 Jan 2016 00:37:01 +0100 Subject: [PATCH 09/10] Add facebook support to user creation --- source/client/controllers/login-controller.js | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/source/client/controllers/login-controller.js b/source/client/controllers/login-controller.js index 474c373..b2a8119 100644 --- a/source/client/controllers/login-controller.js +++ b/source/client/controllers/login-controller.js @@ -54,6 +54,24 @@ Space.messaging.Controller.extend(Space.accountsUi, 'LoginController', { loginType: event.loginType })); break; + case 'facebook': + this.meteor.loginWithFacebook({requestPermissions: ['email', 'public_profile']}, (error) => { + if (error) { + let errorEvent = new Space.accountsUi.LoginFailed({ + error: error, + loginType: event.loginType + }); + this.publish(errorEvent); + } else { + this.publish(new Space.accountsUi.LoginSucceeded({ + loginType: event.loginType + })); + } + }); + this.publish(new Space.accountsUi.LoginInitiated({ + loginType: event.loginType + })); + break; } } From a5b8f99e4cec158e1cfb734e0bf062661e2ba889 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Darko=20Miji=C4=87?= Date: Sun, 24 Jan 2016 19:22:51 +0100 Subject: [PATCH 10/10] Minimal update to new APIs --- .versions | 1 - git-packages.json | 16 ++++++++-------- package.js | 3 +-- 3 files changed, 9 insertions(+), 11 deletions(-) diff --git a/.versions b/.versions index e620f47..0c03db9 100644 --- a/.versions +++ b/.versions @@ -37,6 +37,5 @@ space:messaging@1.7.0 space:ui@5.3.0 spacebars@1.0.6 spacebars-compiler@1.0.6 -templating@1.1.1 tracker@1.0.7 underscore@1.0.3 diff --git a/git-packages.json b/git-packages.json index d32d844..2bd333f 100644 --- a/git-packages.json +++ b/git-packages.json @@ -1,19 +1,19 @@ { "space:base": { "git":"https://github.com/meteor-space/base.git", - "branch": "develop" + "version": "1d99a64fe51904569742aee13e94b3cae29abdb4" }, "space:messaging": { "git":"https://github.com/meteor-space/messaging.git", - "branch": "develop" + "version": "bbaf57c511f7230c662d2ea4473b056148c82787" }, - "space:event-sourcing": { - "git":"https://github.com/meteor-space/event-sourcing.git", - "branch": "develop" + "space:ui": { + "git":"https://github.com/meteor-space/ui.git", + "version": "49651ba1c09b5ba3d410ac2676fb19c48900919c" }, "space:flux": { "git":"https://github.com/meteor-space/flux.git", - "branch": "develop" + "version": "fa2d297bda951442e02a41a1762100163471b863" }, "space:accounts": { "git":"https://github.com/meteor-space/accounts.git", @@ -21,10 +21,10 @@ }, "space:vo-user": { "git":"https://github.com/meteor-space/vo-user.git", - "branch": "develop" + "version": "780d1fc7e1c9a969fe8e1ddae06c86fcf9ca19ff" }, "space:testing": { "git":"https://github.com/meteor-space/testing.git", - "branch": "develop" + "version": "7a404a8cf8e19b1cd0490dac8025c58046fe10b1" } } diff --git a/package.js b/package.js index f59720b..77587e6 100644 --- a/package.js +++ b/package.js @@ -15,7 +15,6 @@ Package.onUse(function(api) { 'coffeescript', 'mongo', 'sha', - 'templating', 'tracker', 'ecmascript', 'check', @@ -25,7 +24,7 @@ Package.onUse(function(api) { 'service-configuration', 'space:vo-user@0.2.1', 'space:accounts@0.1.2', - 'space:flux@0.6.0' + 'space:flux@0.7.0' ]); // MODULES