From b1e3554d98699aa873c71a05db4916600c6a49d9 Mon Sep 17 00:00:00 2001 From: Xaun Lopez Date: Thu, 20 Oct 2016 17:59:58 +0100 Subject: [PATCH] Add ability to signup on #/login --- workspace/app/services/dev-user.svc.js | 1 + .../views/workspace/login/login.controller.js | 23 ++++++++++++++++--- workspace/app/views/workspace/login/login.css | 7 ++++++ .../app/views/workspace/login/login.html | 14 ++++++++++- .../views/workspace/workspace.controller.js | 4 ++++ 5 files changed, 45 insertions(+), 4 deletions(-) diff --git a/workspace/app/services/dev-user.svc.js b/workspace/app/services/dev-user.svc.js index f05059fe..f279ec94 100644 --- a/workspace/app/services/dev-user.svc.js +++ b/workspace/app/services/dev-user.svc.js @@ -10,6 +10,7 @@ angular.module('impacWorkspace').service('DevUser', function ($log, $http, $q, A // ------ this.login = Auth.login; this.logout = Auth.logout; + this.register = Auth.register; this.isAuthenticated = Auth.isAuthenticated; this.currentUser = Auth.currentUser; diff --git a/workspace/app/views/workspace/login/login.controller.js b/workspace/app/views/workspace/login/login.controller.js index 054f2a3c..00e04612 100644 --- a/workspace/app/views/workspace/login/login.controller.js +++ b/workspace/app/views/workspace/login/login.controller.js @@ -10,14 +10,31 @@ angular.module('impacWorkspace').controller('LoginController', function ($state, }); } - vm.creds = { email: '', password: '' }; + vm.showRegisterForm = false; + vm.creds = { email: '', password: '', company: '' }; + + vm.toggleRegisterForm = function () { + vm.showRegisterForm = !vm.showRegisterForm; + }; vm.login = function () { - DevUser.login(vm.creds).then( + DevUser.login(_.omit(vm.creds, ['company'])).then( function () { $state.go('workspace.impac'); }, function (response) { - var msg = (response.data && response.data.error) || 'Unable to login'; + var msg = (response.data && response.data.error) || 'Unable to login :('; + DevUser.fail(msg, response); + } + ); + }; + + vm.register = function () { + DevUser.register(vm.creds).then( + function (res) { + console.log(res); + $state.go('workspace.impac'); + }, function (err) { + var msg = (response.data && response.data.error) || 'Unable to sign up :('; DevUser.fail(msg, response); } ); diff --git a/workspace/app/views/workspace/login/login.css b/workspace/app/views/workspace/login/login.css index 09588a74..0faa660d 100644 --- a/workspace/app/views/workspace/login/login.css +++ b/workspace/app/views/workspace/login/login.css @@ -14,6 +14,13 @@ border-radius: 3px; } +#workspace .workspace-login .login-box-actions a { + color: rgb(117, 129, 146); +} +#workspace .workspace-login .login-box-actions a:hover { + color: black; +} + #workspace .workspace-login .login-box-title { color: rgb(117, 129, 146); margin-bottom: 15px; diff --git a/workspace/app/views/workspace/login/login.html b/workspace/app/views/workspace/login/login.html index a64a983a..53932dbb 100644 --- a/workspace/app/views/workspace/login/login.html +++ b/workspace/app/views/workspace/login/login.html @@ -11,7 +11,19 @@

Sign In

- +
+ +
+
+
+ + Don't have an account? Sign up. +
+
+ + +
+
diff --git a/workspace/app/views/workspace/workspace.controller.js b/workspace/app/views/workspace/workspace.controller.js index b28440bd..7c19cd5f 100644 --- a/workspace/app/views/workspace/workspace.controller.js +++ b/workspace/app/views/workspace/workspace.controller.js @@ -9,6 +9,10 @@ angular.module('impacWorkspace').controller('WorkspaceController', function ($sc setCurrentOrganization(); }); + $scope.$on('devise:new-registration', function() { + setCurrentOrganization(); + }); + $scope.$on('updated-providers', function () { setCurrentOrganization(); });