Skip to content

Commit

Permalink
Add ability to signup on #/login
Browse files Browse the repository at this point in the history
  • Loading branch information
xaun committed Oct 20, 2016
1 parent 9e31427 commit b1e3554
Show file tree
Hide file tree
Showing 5 changed files with 45 additions and 4 deletions.
1 change: 1 addition & 0 deletions workspace/app/services/dev-user.svc.js
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand Down
23 changes: 20 additions & 3 deletions workspace/app/views/workspace/login/login.controller.js
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}
);
Expand Down
7 changes: 7 additions & 0 deletions workspace/app/views/workspace/login/login.css
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
14 changes: 13 additions & 1 deletion workspace/app/views/workspace/login/login.html
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,19 @@ <h2>Sign In</h2>
<div class="form-group">
<input name="password" type="password" class="form-control" placeholder="Password" ng-model="vm.creds.password" required>
</div>
<button class="btn btn-warning btn-block" ng-click="vm.login()" ng-keyup="($event.keyCode == 13 && vm.login())" ng-disabled="!vm.workspaceLoginForm.$valid">LOGIN</button>
<div class="form-group" ng-show="vm.showRegisterForm">
<input name="company" type="text" class="form-control" placeholder="Company" ng-model="vm.creds.company" ng-required="vm.showRegisterForm">
</div>
<div class="login-box-actions">
<div ng-hide="vm.showRegisterForm">
<button class="btn btn-warning btn-block" ng-click="vm.login()" ng-keyup="($event.keyCode == 13 && vm.login())" ng-disabled="!vm.workspaceLoginForm.$valid">LOGIN</button>
<a href="" class="btn" ng-click="vm.toggleRegisterForm()">Don't have an account? Sign up.</a>
</div>
<div ng-show="vm.showRegisterForm">
<button class="btn btn-warning btn-block" ng-click="vm.register()" ng-keyup="($event.keyCode == 13 && vm.register())" ng-disabled="!vm.workspaceLoginForm.$valid">SIGN UP!</button>
<button style="margin-top: 5px"; class="btn btn-default btn-block" ng-click="vm.toggleRegisterForm()">BACK</button>
</div>
</div>
</form>
</div>
</div>
Expand Down
4 changes: 4 additions & 0 deletions workspace/app/views/workspace/workspace.controller.js
Original file line number Diff line number Diff line change
Expand Up @@ -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();
});
Expand Down

0 comments on commit b1e3554

Please sign in to comment.