Skip to content

Commit

Permalink
Merge pull request rambl#63 from tmoc/master
Browse files Browse the repository at this point in the history
Added alert when attemping to create account that already exists.
  • Loading branch information
tmoc committed Jul 22, 2014
2 parents 787c115 + d6acecb commit fed22a9
Show file tree
Hide file tree
Showing 5 changed files with 15 additions and 3 deletions.
1 change: 1 addition & 0 deletions client/app/home/home.html
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ <h1 class="logo text-center">Rambl</h1>
<div class="signin">
<div id='login' class="jumbotron signin_div">
<form name='loginForm' ng-submit='login();'>
<div class="alert alert-danger" ng-show="invalidAccountInfo">Invalid email/password.</div>
<input placeholder="Email" required class="form-control" type='email' maxlength="32" ng-model='user.email'>
<input placeholder="Password" required class="form-control" type='password' maxlength="32" ng-model='user.password'>
<br />
Expand Down
8 changes: 7 additions & 1 deletion client/app/home/home.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,8 @@ angular.module('ramblApp.home', [])
.controller('homeController', ['$scope', '$window', '$location', 'Auth', 'EasyRTC',
function ($scope, $window, $location, Auth, EasyRTC) {

$scope.invalidAccountInfo = false;

// if user has userName and token, redirect to lobby, else check if they're coming from
// lobby/room having signed out and if so remove them from room and/or disconnect from easyrtc
if ($window.localStorage.getItem('ramblUsername') && $window.localStorage.getItem('ramblToken')) {
Expand All @@ -19,7 +21,11 @@ angular.module('ramblApp.home', [])
$scope.login = function () {
Auth.login($scope.user)
.then(function (userObject) {
Auth.processLogin(userObject);
if (userObject.token !== undefined && userObject.userName !== undefined) {
Auth.processLogin(userObject);
} else {
$scope.invalidAccountInfo = true;
}
})
.catch(function (error) {
console.error(error);
Expand Down
1 change: 1 addition & 0 deletions client/app/signup/signup.html
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
<div id="signup" class="jumbotron signup_div">
<h2>Sign Up!</h2>
<form name="signupForm" ng-submit="signup();">
<div class="alert alert-danger" ng-show="accountAlreadyExists">Account already exists.</div>
<input placeholder='Your email' required class="form-control" type="email" maxlength="32" ng-model="user.email">
<input placeholder='Your display name' required class="form-control" type="text" maxlength="32" ng-model="user.name">
<input placeholder='Password' required class="form-control" type="password" maxlength="32" ng-model="user.password">
Expand Down
4 changes: 4 additions & 0 deletions client/app/signup/signup.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@ angular.module('ramblApp.signup', [])

.controller('signupController', ['$scope', '$window', '$location', 'Auth', 'EasyRTC',
function ($scope, $window, $location, Auth, EasyRTC) {

$scope.accountAlreadyExists = false;

// if user has userName and token, redirect to lobby, else check if they're coming from
// lobby/room having signed out and if so remove them from room and/or disconnect from easyrtc
Expand All @@ -21,6 +23,8 @@ angular.module('ramblApp.signup', [])
.then(function (userObject) {
if (userObject.token !== undefined && userObject.userName !== undefined) {
Auth.processLogin(userObject);
} else {
$scope.accountAlreadyExists = true;
}
})
.catch(function (error) {
Expand Down
4 changes: 2 additions & 2 deletions client/built.min.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit fed22a9

Please sign in to comment.