thewillhuang on master
updated mongoose (compare)
thewillhuang on master
upgraded uglify to work with 0.… Merge branch 'master' of https:… removed trailing white spaces (compare)
simon-kim on master
Update README.md (compare)
simon-kim on master
Update bibleCtrl.js (compare)
simon-kim on master
Update bibleCtrl.js (compare)
simon-kim on master
Update .gitignore (compare)
thewillhuang on master
verse routes fix (compare)
thewillhuang on master
fix some bugs on the backend an… (compare)
thewillhuang on master
refactor into a function (compare)
thewillhuang on master
parsed out some html from esvap… (compare)
thewillhuang on master
server linting (compare)
thewillhuang on master
fix tests (compare)
thewillhuang on master
newrelic (compare)
require('./controllers/bibleCtrl')(bibleApp);
// require('./controllers/userCtrl')(bibleApp);
// bibleApp.config(['$routeProvider', function($routeProvider) {
// $routeProvider
// .when('/', {
// templateUrl: 'assets/templates/home.html',
// controller: 'bibleCtrl'
// })
// .when('/login', {
// templateUrl: 'assets/templates/login.html',
// controller: 'userCtrl'
// });
// // .otherwise({
// // redirectTo: '/'
// // });
// }]);
<div data-ng-controller="userCtrl">
<section id='buttons'data-ng-hide='signUp || signIn'>
<button id='signin' data-ng-click='signIn = true'>Log In</button>
<p>Or <a id='signup' href data-ng-click='signUp = true'>Sign Up</a></p>
</section>
<section id='signUp' class='form' data-ng-show='signUp'>
<i>{{errors}}</i><br>
<form>
<label>Username: </label><br>
<label>Email: </label><br>
<input type='text' data-ng-model='newUser.email'><br>
<label>Password: </label><br>
<input type='password' data-ng-model='newUser.password'><br>
<label>Password Confirmation: </label><br>
<input type='password' data-ng-model='newUser.passwordConfirmation'><br>
<button id='submit' class='submit' data-ng-click='signUp()'>Sign Up</button>
</form>
<a id='signin' href data-ng-click='signIn = true; signUp = false; errors = null;'>Log In</a>
</section>
<section id='signIn' class='form' data-ng-show='signIn'>
<i>{{errors}}</i><br>
<form>
<label>Email:</label><br>
<input type='text' data-ng-model='user.email'><br>
<label>Password:</label><br>
<input type='password' data-ng-model='user.password'><br>
<button id='login' class='submit' data-ng-click='logIn()'>Log In</button>
</form>
<a id='signin' href data-ng-click='signUp = true; signIn = false; errors = null;'>Sign Up</a>
</section>
</div>
'use strict';
module.exports = function(app) {
app.controller('userCtrl', ['$scope', '$http', '$base64', '$cookies', '$location', function($scope, $http, $base64, $cookies, $location) {
$scope.signUp = false;
$scope.signIn = false;
if ($cookies.jwt) {
console.log('redirecting');
$location.path('/');
}
$scope.logIn = function() {
$scope.errors = null;
$http.defaults.headers.common.Authorization = 'Basic ' + $base64.encode($scope.user.email + ':' + $scope.user.password);
$http({
method: 'GET',
url: '/api/users'
})
.success(function(data) {
$cookies.jwt = data.jwt;
$location.path('/');
})
.error(function(data) {
console.log('err', data);
$scope.errors = data;
});
};
$scope.signUp = function() {
$scope.errors = null;
if ($scope.newUser.password !== $scope.newUser.passwordConfirmation) $scope.errors = 'passwords did not match';
if (!$scope.newUser.email) $scope.errors = 'please specify an email';
if (!$scope.newUser.password) $scope.errors = 'invalid password';
if ($scope.errors !== null) return;
$http({
method: 'POST',
url: '/api/users',
data: $scope.newUser
})
.success(function(data) {
$cookies.jwt = data.jwt;
$location.path('/');
})
.error(function(data) {
console.log('err', data);
$scope.errors = data;
});
};
}]);
};