Skip to content

Commit

Permalink
update examples and use name key
Browse files Browse the repository at this point in the history
  • Loading branch information
zemirco committed Apr 11, 2014
1 parent 698a8e0 commit 87ddf3c
Show file tree
Hide file tree
Showing 7 changed files with 28 additions and 28 deletions.
2 changes: 1 addition & 1 deletion examples/angular/app.js
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ if (app.get('env') === 'development') {

app.get('/rest/whoami', utls.restrict(config), function(req, res) {
res.json({
username: req.session.username
name: req.session.name
});
});

Expand Down
20 changes: 10 additions & 10 deletions examples/angular/public/js/controllers.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,9 @@ var app = angular.module('myApp.controllers', []);
* Main / Root controller
*/
app.controller('MainCtrl', function ($scope, user) {

$scope.user = user.get();

$scope.logout = function() {
user.logout().then(function() {
$scope.user = null;
Expand All @@ -20,10 +20,10 @@ app.controller('MainCtrl', function ($scope, user) {
});

/**
* Login controller
* Login controller
*/
app.controller('LoginCtrl', function ($scope, $window, user) {

// submit form
$scope.submit = function() {

Expand All @@ -33,9 +33,9 @@ app.controller('LoginCtrl', function ($scope, $window, user) {
}, function(error) {
$scope.error = error;
})

};

});

/**
Expand All @@ -46,7 +46,7 @@ app.controller('SignupCtrl', function ($scope, user) {
// submit form
$scope.submit = function() {

user.signup($scope.username, $scope.email, $scope.password)
user.signup($scope.name, $scope.email, $scope.password)
.success(function(data, status) {
$scope.error = false;
$scope.success = 'Great! Check your inbox.'
Expand All @@ -65,14 +65,14 @@ app.controller('SignupCtrl', function ($scope, user) {
app.controller('SignupTokenCtrl', function ($scope, $routeParams, $http) {

var token = $routeParams.token;

$http.get('/rest/signup/' + token)
.success(function(data, status) {
$scope.success = true;
})
.error(function(data, status) {
$scope.error = true
});


});

});
6 changes: 3 additions & 3 deletions examples/angular/public/js/services.js
Original file line number Diff line number Diff line change
Expand Up @@ -32,9 +32,9 @@ services.factory('user', function($http, $cookies, $q){
});
return deferred.promise;
},
signup: function(username, email, password) {
signup: function(name, email, password) {
return $http.post('/rest/signup', {
username: username,
name: name,
email: email,
password: password
});
Expand All @@ -44,4 +44,4 @@ services.factory('user', function($http, $cookies, $q){
}
}

});
});
2 changes: 1 addition & 1 deletion examples/angular/public/views/index.html
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@

<div ng-show="user">
<p>Welcome {{user.username}}</p>
<p>Welcome {{user.name}}</p>
</div>

<div ng-hide="user">
Expand Down
4 changes: 2 additions & 2 deletions examples/angular/public/views/signup.html
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ <h3 class="panel-title">Signup</h3>
<form ng-submit="submit()">
<div class="form-group">
<label for="login">Username</label>
<input type="text" class="form-control" id="username" ng-model="username" placeholder="Username">
<input type="text" class="form-control" id="name" ng-model="name" placeholder="Username">
</div>
<div class="form-group">
<label for="email">Email</label>
Expand All @@ -26,4 +26,4 @@ <h3 class="panel-title">Signup</h3>
<input type="submit" class="btn btn-primary" value="Submit">
</form>
</div>
</div>
</div>
18 changes: 9 additions & 9 deletions examples/gravatar/app.js
Original file line number Diff line number Diff line change
Expand Up @@ -48,27 +48,27 @@ http.createServer(app).listen(app.get('port'), function(){
// get the gravatar image url for every new user
// signup.handleResponse is 'false' in 'config.js'
lockit.on('signup', function(user, res) {

// get email from user object
var email = user.email;

// generate hash and url for gravatar api
var hash = crypto.createHash('md5').update(email).digest('hex');
var url = 'http://www.gravatar.com/avatar/' + hash;

// update user information
user.gravatar = url;

// save updated user to db
adapter.update(user, function(err, user) {
if (err) console.log(err);

// now send a response to the client
res.render('gravatar', {
username: user.username,
name: user.name,
gravatar: url
});

});
});

});
4 changes: 2 additions & 2 deletions examples/gravatar/views/gravatar.jade
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
extends layout

block content
h1 Hey #{username}
h1 Hey #{name}
p This is you!
img(src=gravatar)
img(src=gravatar)

0 comments on commit 87ddf3c

Please sign in to comment.