Skip to content

Commit

Permalink
Merge pull request #26 from DannyDelott/master
Browse files Browse the repository at this point in the history
Redirect user to login page
  • Loading branch information
sdwebster committed Mar 27, 2015
2 parents a6241f2 + 238c0bc commit 260cbfe
Showing 1 changed file with 7 additions and 1 deletion.
8 changes: 7 additions & 1 deletion client/app/ideaDetail/ideaDetail.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

// The pattern we're using here is the pattern we're using across all our controllers: the controllerAs syntax. This syntax is for Angular versions 1.2 and up, and means you don't have to use `$scope` anymore. Instead, inside of your HTML, you declare your controller with `ng-controller="IdeasCtrl as ictrl"` and reference your variables within that controlled scope as `ictrl.<varname>`. Additionally, instead of setting your properties within your controller to `$scope`, assign your controller's `this` to a variable called self and set your properties to that.
angular.module( 'glint.ideaDetail', [] )
.controller( 'IdeaCollaboratorsCtrl', function( $stateParams, IdeaDetail, UserInfo, Ideas, $filter, $route ) {
.controller( 'IdeaCollaboratorsCtrl', function( $stateParams, IdeaDetail, UserInfo, Ideas, $filter, $route, $location ) {
var self = this;

self.newCollaborator = {};
Expand Down Expand Up @@ -51,6 +51,9 @@ angular.module( 'glint.ideaDetail', [] )
// Escape user input.

self.newCollaborator.username = UserInfo.getUsername();
if ( self.newCollaborator.username === 'not available' ) {
$location.path( '/login' );
}
self.newCollaborator.idea_id = self._id;
self.newCollaborator.role = _.escape( self.newCollaborator.role );
var collab = JSON.stringify( self.newCollaborator );
Expand All @@ -73,6 +76,9 @@ angular.module( 'glint.ideaDetail', [] )

// Escape user input.
self.newComment.created_by = UserInfo.getUsername();
if ( self.newComment.created_by === 'not available' ) {
$location.path( '/login' );
}
self.newComment.idea_id = self._id;
self.newComment.text = _.escape( self.newComment.text );
var comm = JSON.stringify( self.newComment );
Expand Down

0 comments on commit 260cbfe

Please sign in to comment.