[
  {
    "path": "README.md",
    "content": "# Authentication on AngularJS with JWTs\n\nIn this demo we'll show step by step how to add Authentication to your AngularJS app with an API that uses JWTs.\n\n## Running the example\n\nThis application has an AngularJS Frontend and a NodeJS backend\n\n### Frontend\n\nIn order to run the the AngularJS app, all you need to do is to start a server at that folder. I recommend using `serve` for that. Just run:\n\n* `npm install -g serve`\n* `bower install`\n* `serve`\n\nThen go to [http://localhost:3000](http://localhost:3000) and see the Frontend app running\n\n### Backend\n\nThe backend is made with `node`, so you must have `node` and `npm` installed.\n\nThen, just run `node server.js` to start the server on the port `3001`.\n\n## Branches\n\nIn this repository you'll find several branches. Each of the branches represents one step taken to implement the Authentication.\n\n### 1 - Start Branch\n\nThis is the starting point for the application.\n\nIf you go to [http://localhost:3000/#/](http://localhost:3000/#/) you'll see the main page of the demo.\n\nIn there, you'll see 2 buttons to do 2 API calls:\n\n* The first one, does an API call that **doesn't** require Authentication\n* The second one does an API call that **does** require authentication\n\nTry clicking both to see what happens.\n\n### 2 - Authentication implemented in the Backend and UI in the FrontEnd\n\nIn this branch, we've added the UI for both the [Signup](https://github.com/auth0/ngeurope-demo/tree/2-user-on-front-ui/frontend/signup) and [Login](https://github.com/auth0/ngeurope-demo/tree/2-user-on-front-ui/frontend/login). \n\nAlso, we've implemented the [Login](https://github.com/auth0/ngeurope-demo/blob/2-user-on-front-ui/backend/user-routes.js#L37-L54) and [Signup](https://github.com/auth0/ngeurope-demo/blob/2-user-on-front-ui/backend/user-routes.js#L19-L35) on the Backend. It returns the [JWT](https://docs.auth0.com/jwt) to the user.\n\n### 3 - User Authentication Finished\n\nIn this branch, user Authentication works in the Frontend. You can see the [Login](https://github.com/auth0/ngeurope-demo/blob/3-user-signin-finished/frontend/login/login.js) and [Signup](https://github.com/auth0/ngeurope-demo/blob/3-user-signin-finished/frontend/signup/signup.js) implemented and working.\n\nGo to [http://localhost:3000/#/login](http://localhost:3000/#/login) to see the Login page and login. You'll see that if you click on the `Call secure API` button, it'll still throw an error. That's because we need to send the `JWT` on the `Authorization` header. Let's do that!\n\n### 4 - Sending JWTs on requests\n\nNow, we've implemented sending the JWT on the `Authorization` header on every request. Check it out [here](https://github.com/auth0/ngeurope-demo/blob/4-sending-jwt-on-requests/frontend/app.js#L10-L14)\n\nNow, before logging in, try going to [http://localhost:3000/#/](http://localhost:3000/#/). You should still see this page even though you're not logged in. Try clicking on the `Call secure API` button and check that you still get the Unauthorized error. Now, go to the [Login page](http://localhost:3000/#/login) and log in. Try clicking again on `Call secure API`. Check that it's not returning a correct response since the `Authorization` header is sent in every request.\n\n### 5 - Restrict access to routes\n\nIn this section, we've restricted access to routes that require authentintication for anonymous users. Go to [http://localhost:3000/#/](http://localhost:3000/#/) without being logged in and you'll see that you're redirected to the Login page. You can see the implementation for that [here](https://github.com/auth0/ngeurope-demo/blob/5-restrict-access-to-routes/frontend/app.js#L18-L25).\n"
  },
  {
    "path": "backend/.gitignore",
    "content": "node_modules/\n.env"
  },
  {
    "path": "backend/README.md",
    "content": "# NODE TODO API\n\nThis is a NodeJS full API that you can use to test with your SPAs or Mobile apps.\n\n## How to use it\n\nThis service is deployed in Heroku and saves the TODOs in memory, so once the dyno dies, all the todos are removed.\n\nIt's deployed on [http://auth0-todo-test-api.herokuapp.com/](http://auth0-todo-test-api.herokuapp.com/)\n\n## Available APIs\n\n### Open API\n\nThe Open API lets anyone do CRUD operation on a set of TODOs. This means that you can add a TODO and then John Doe can delete it.\n\nAvailable methods:\n\n* **POST /api/open/todos**: Adds a new TODO\n* **PUT /api/open/todos/:id**: Updates the TODO with id `id`\n* **GET /api/open/todos/:id**: Returns the TODO with id `id`\n* **DELETE /api/open/todos/:id**: Deletes the TODO with id `id`\n* **GET /api/open/todos**: Gets all fo the TODOs\n\n### User based API\n\nYou can use this API to save TODO items for a particular user. For that, you need to use Auth0 to get the `id_token` (JWT) and send it in every request as part of the `Authorization` header.\n\nThis server validates JWT from the following account:\n\n* **Domain**: `samples.auth0.com`\n* **ClientID**: `BUIJSW9x60sIHBw8Kd9EmCbj8eDIFxDC`\n\nAvailable methods:\n\n* **POST /api/todos**: Adds a new TODO\n* **PUT /api/todos/:id**: Updates the TODO with id `id`\n* **GET /api/todos/:id**: Returns the TODO with id `id`\n* **DELETE /api/todos/:id**: Deletes the TODO with id `id`\n* **GET /api/todos**: Gets all fo the TODOs\n\n## Running this for your Auth0 account\n\nIf you want, you can run this server for YOUR Auth0 account. For that, you just need to create a `.env` file and set the `AUTH0_CLIENT_ID` and `AUTH0_CLIENT_SECRET` variables with the information from your account:\n\n````bash\nAUTH0_CLIENT_ID=YourClientId\nAUTH0_CLIENT_SECRET=YourClientSecret\n````\n\n"
  },
  {
    "path": "backend/anonymous-routes.js",
    "content": "var express = require('express'),\n    quoter  = require('./quoter');\n\nvar app = module.exports = express.Router();\n\napp.get('/api/random-quote', function(req, res) {\n  res.status(200).send(quoter.getRandomOne());\n});\n"
  },
  {
    "path": "backend/config.json",
    "content": "{\n  \"secret\": \"ngEurope rocks!\"\n}\n"
  },
  {
    "path": "backend/package.json",
    "content": "{\n  \"name\": \"in-memory-todo\",\n  \"version\": \"0.1.0\",\n  \"description\": \"An In memory todo for Logged in and not Logged in users\",\n  \"main\": \"server.js\",\n  \"scripts\": {\n    \"test\": \"echo \\\"Error: no test specified\\\" && exit 1\"\n  },\n  \"repository\": {\n    \"type\": \"git\",\n    \"url\": \"https://github.com/auth0/in-memory-todo.git\"\n  },\n  \"keywords\": [\n    \"todo\",\n    \"in\",\n    \"memory\",\n    \"jwt\",\n    \"auth0\"\n  ],\n  \"author\": \"Martin Gontovnikas\",\n  \"license\": \"MIT\",\n  \"bugs\": {\n    \"url\": \"https://github.com/auth0/in-memory-todo/issues\"\n  },\n  \"homepage\": \"https://github.com/auth0/in-memory-todo\",\n  \"dependencies\": {\n    \"body-parser\": \"^1.6.5\",\n    \"compression\": \"^1.0.11\",\n    \"cors\": \"^2.4.1\",\n    \"dotenv\": \"^0.4.0\",\n    \"errorhandler\": \"^1.1.1\",\n    \"express\": \"^4.8.5\",\n    \"express-jwt\": \"^0.3.1\",\n    \"jsonwebtoken\": \"^1.1.2\",\n    \"lodash\": \"^2.4.1\",\n    \"morgan\": \"^1.2.3\"\n  }\n}\n"
  },
  {
    "path": "backend/protected-routes.js",
    "content": "var express = require('express'),\n    jwt     = require('express-jwt'),\n    config  = require('./config'),\n    quoter  = require('./quoter');\n\nvar app = module.exports = express.Router();\n\nvar jwtCheck = jwt({\n  secret: config.secret\n});\n\napp.use('/api/protected', jwtCheck);\n\napp.get('/api/protected/random-quote', function(req, res) {\n  res.status(200).send(quoter.getRandomOne());\n});\n"
  },
  {
    "path": "backend/quoter.js",
    "content": "var quotes = require('./quotes.json');\n\nexports.getRandomOne = function() {\n  var totalAmount = quotes.length;\n  var rand = Math.ceil(Math.random() * totalAmount);\n  return quotes[rand];\n}\n"
  },
  {
    "path": "backend/quotes.json",
    "content": "[\"Chuck Norris doesn't call the wrong number. You answer the wrong phone.\",\n\"Chuck Norris has already been to Mars; that's why there are no signs of life.\",\n\"Chuck Norris and Superman once fought each other on a bet. The loser had to start wearing his underwear on the outside of his pants.\",\n\"Some magicans can walk on water, Chuck Norris can swim through land.\",\n\"Chuck Norris once urinated in a semi truck's gas tank as a joke....that truck is now known as Optimus Prime.\",\n\"Chuck Norris doesn't flush the toilet, he scares the sh*t out of it\",\n\"Chuck Norris counted to infinity - twice.\",\n\"Chuck Norris can cut through a hot knife with butter\",\n\"Chuck Norris is the reason why Waldo is hiding.\",\n\"Death once had a near-Chuck Norris experience\",\n\"When the Boogeyman goes to sleep every night, he checks his closet for Chuck Norris.\",\n\"Chuck Norris can slam a revolving door.\",\n\"Chuck Norris once kicked a horse in the chin. Its decendants are known today as Giraffes.\",\n\"Chuck Norris will never have a heart attack. His heart isn't nearly foolish enough to attack him.\",\n\"Chuck Norris once got bit by a rattle snake........ After three days of pain and agony ..................the rattle snake died\",\n\"Chuck Norris can win a game of Connect Four in only three moves.\",\n\"When Chuck Norris does a pushup, he isn't lifting himself up, he's pushing the Earth down.\",\n\"There is no theory of evolution. Just a list of animals Chuck Norris allows to live.\",\n\"Chuck Norris can light a fire by rubbing two ice-cubes together.\",\n\"Chuck Norris doesn’t wear a watch. HE decides what time it is.\",\n\"The original title for Alien vs. Predator was Alien and Predator vs Chuck Norris.\",\n\"The film was cancelled shortly after going into preproduction. No one would pay nine dollars to see a movie fourteen seconds long.\",\n\"Chuck Norris doesn't read books. He stares them down until he gets the information he wants.\",\n\"Chuck Norris made a Happy Meal cry.\",\n\"Outer space exists because it's afraid to be on the same planet with Chuck Norris.\",\n\"If you spell Chuck Norris in Scrabble, you win. Forever.\",\n\"Chuck Norris can make snow angels on a concrete slab.\",\n\"Chuck Norris destroyed the periodic table, because Chuck Norris only recognizes the element of surprise.\",\n\"Chuck Norris has to use a stunt double when he does crying scenes.\",\n\"Chuck Norris' hand is the only hand that can beat a Royal Flush.\",\n\"There is no theory of evolution. Just a list of creatures Chuck Norris has allowed to live.\",\n\"Chuck Norris does not sleep. He waits.\",\n\"Chuck Norris tells a GPS which way to go.\",\n\"Some people wear Superman pajamas. Superman wears Chuck Norris pajamas.\",\n\"Chuck Norris's tears cure cancer ..... to bad he has never cried\",\n\"Chuck Norris doesn't breathe, he holds air hostage.\",\n\"Chuck Norris had a staring contest with Medusa, and won.\",\n\"When life hands Chuck Norris lemons, he makes orange juice.\",\n\"When Chuck Norris goes on a picnic, the ants bring him food.\",\n\"Chuck Norris gives Freddy Krueger nightmares.\",\n\"They once made a Chuck Norris toilet paper, but there was a problem: It wouldn't take shit from anybody.\",\n\"Chuck Norris can punch a cyclops between the eyes.\",\n\"Chuck Norris doesn't mow his lawn, he stands on the porch and dares it to grow\",\n\"Chuck Norris put out a forest fire. using only gasoline\",\n\"Chuck Norris CAN believe it's not butter.\",\n\"Custom t-shirts provided by Spreadshirt\"]\n"
  },
  {
    "path": "backend/server.js",
    "content": "var logger          = require('morgan'),\n    cors            = require('cors'),\n    http            = require('http'),\n    express         = require('express'),\n    errorhandler    = require('errorhandler'),\n    dotenv          = require('dotenv'),\n    bodyParser      = require('body-parser');\n\nvar app = express();\n\ndotenv.load();\n\n// Parsers\n// old version of line\n// app.use(bodyParser.urlencoded());\n// new version of line\napp.use(bodyParser.urlencoded({ extended: true }));\napp.use(bodyParser.json());\napp.use(cors());\n\napp.use(function(err, req, res, next) {\n  if (err.name === 'StatusError') {\n    res.send(err.status, err.message);\n  } else {\n    next(err);\n  }\n});\n\nif (process.env.NODE_ENV === 'development') {\n  app.use(express.logger('dev'));\n  app.use(errorhandler())\n}\n\napp.use(require('./anonymous-routes'));\napp.use(require('./protected-routes'));\napp.use(require('./user-routes'));\n\nvar port = process.env.PORT || 3001;\n\nhttp.createServer(app).listen(port, function (err) {\n  console.log('listening in http://localhost:' + port);\n});\n\n"
  },
  {
    "path": "backend/statusError.js",
    "content": "function StatusError(msg, status) {\n    var err = Error.call(this, msg);\n    err.status = status;\n    err.name = 'StatusError';\n    return err;\n}\n\n\nStatusError.prototype = Object.create(Error.prototype, {\n  constructor: { value: StatusError }\n});\n\nmodule.exports = StatusError;\n\n"
  },
  {
    "path": "backend/user-routes.js",
    "content": "var express = require('express'),\n    _       = require('lodash'),\n    config  = require('./config'),\n    jwt     = require('jsonwebtoken');\n\nvar app = module.exports = express.Router();\n\n// XXX: This should be a database of users :).\nvar users = [{\n  id: 1,\n  username: 'gonto',\n  password: 'gonto'\n}];\n\nfunction createToken(user) {\n  return jwt.sign(_.omit(user, 'password'), config.secret, { expiresInMinutes: 60*5 });\n}\n\napp.post('/users', function(req, res) {\n  if (!req.body.username || !req.body.password) {\n    return res.status(400).send(\"You must send the username and the password\");\n  }\n  if (_.find(users, {username: req.body.username})) {\n   return res.status(400).send(\"A user with that username already exists\");\n  }\n\n  var profile = _.pick(req.body, 'username', 'password', 'extra');\n  profile.id = _.max(users, 'id').id + 1;\n\n  users.push(profile);\n\n  res.status(201).send({\n    id_token: createToken(profile)\n  });\n});\n\napp.post('/sessions/create', function(req, res) {\n  if (!req.body.username || !req.body.password) {\n    return res.status(400).send(\"You must send the username and the password\");\n  }\n\n  var user = _.find(users, {username: req.body.username});\n  if (!user) {\n    return res.status(401).send(\"The username or password don't match\");\n  }\n\n  if (!user.password === req.body.password) {\n    return res.status(401).send(\"The username or password don't match\");\n  }\n\n  res.status(201).send({\n    id_token: createToken(user)\n  });\n});\n"
  },
  {
    "path": "frontend/.bowerrc",
    "content": "{\n  \"directory\": \"vendor\"\n}\n"
  },
  {
    "path": "frontend/.editorconfig",
    "content": "# http://editorconfig.org\nroot = true\n\n[*]\nindent_style = space\nindent_size = 2\ncharset = utf-8\ntrim_trailing_whitespace = true\ninsert_final_newline = true\n\n[*.md]\ntrim_trailing_whitespace = false\n"
  },
  {
    "path": "frontend/.gitignore",
    "content": "._*\n.~lock.*\n.buildpath\n.DS_Store\n.idea\n.project\n.settings\n\n# Ignore node stuff\nnode_modules/\nnpm-debug.log\nlibpeerconnection.log\n\n# OS-specific\n.DS_Store\n\n# Bower components\nvendor\n"
  },
  {
    "path": "frontend/README.md",
    "content": "# Auth0 + AngularJS + API Seed\n\nThis is the seed project you need to use if you're going to create an AngularJS app that will use Auth0 and an API that you're going to be developing. That API can be in any language.\n\nIf you want to connect to a third party API like Firebase or Amazon, please check [this other seed](https://github.com/auth0/auth0-angular/tree/master/examples/widget-with-thirdparty-api).\n\n## Running the example\n\nIn order to run the example you need to just start a server. What we suggest is doing the following:\n\n1. Install node\n1. run npm install -g serve\n1. run serve in the directory of this project.\n\nGo to [http://localhost:3000](http://localhost:3000) and you'll see the app running :).\n"
  },
  {
    "path": "frontend/app.css",
    "content": ""
  },
  {
    "path": "frontend/app.js",
    "content": "angular.module( 'sample', [\n  'sample.home',\n  'sample.login',\n  'sample.signup',\n  'angular-jwt',\n  'angular-storage'\n])\n.config( function myAppConfig ($urlRouterProvider, jwtInterceptorProvider, $httpProvider) {\n  $urlRouterProvider.otherwise('/');\n\n  jwtInterceptorProvider.tokenGetter = function(store) {\n    return store.get('jwt');\n  }\n\n  $httpProvider.interceptors.push('jwtInterceptor');\n})\n.run(function($rootScope, $state, store, jwtHelper) {\n  $rootScope.$on('$stateChangeStart', function(e, to) {\n    if (to.data && to.data.requiresLogin) {\n      if (!store.get('jwt') || jwtHelper.isTokenExpired(store.get('jwt'))) {\n        e.preventDefault();\n        $state.go('login');\n      }\n    }\n  });\n})\n.controller( 'AppCtrl', function AppCtrl ( $scope, $location ) {\n  $scope.$on('$routeChangeSuccess', function(e, nextRoute){\n    if ( nextRoute.$$route && angular.isDefined( nextRoute.$$route.pageTitle ) ) {\n      $scope.pageTitle = nextRoute.$$route.pageTitle + ' | ngEurope Sample' ;\n    }\n  });\n})\n\n;\n\n"
  },
  {
    "path": "frontend/auth0-variables.js",
    "content": "var AUTH0_CLIENT_ID='BUIJSW9x60sIHBw8Kd9EmCbj8eDIFxDC';\nvar AUTH0_DOMAIN='samples.auth0.com';\n"
  },
  {
    "path": "frontend/bower.json",
    "content": "{\n  \"name\": \"ngEurope\",\n  \"version\": \"0.0.0\",\n  \"homepage\": \"https://github.com/auth0/ngeurope-demo\",\n  \"authors\": [\n    \"Martin Gontovnikas <martin@gon.to>\"\n  ],\n  \"description\": \"ngEurope Auth0 sample\",\n  \"main\": \"app.js\",\n  \"keywords\": [\n    \"ngEurope\",\n    \"sample\",\n    \"angular\"\n  ],\n  \"license\": \"MIT\",\n  \"dependencies\": {\n    \"angularjs\": \"~1.3\",\n    \"bootstrap\": \"~3.2.0\",\n    \"font-awesome\": \"~4.2.0\",\n    \"ui-router\": \"~0.2.11\",\n    \"angular-jwt\": \"~0.0.4\",\n    \"a0-angular-storage\": \"~0.0.6\",\n    \"typekit-load\": \"~0.1.2\",\n    \"angular-ui-router\": \"~0.2.11\"\n  },\n  \"ignore\": [\n    \"**/.*\",\n    \"node_modules\",\n    \"bower_components\",\n    \"vendor\",\n    \"test\",\n    \"tests\"\n  ]\n}\n"
  },
  {
    "path": "frontend/home/home.css",
    "content": ".red {\n  color: red;\n}\n"
  },
  {
    "path": "frontend/home/home.html",
    "content": "<div class=\"home\">\n  <div class=\"jumbotron centered\">\n    <h1>Welcome to the ngEurope sample!</h1>\n    <h2 ng-show=\"jwt\">Your JWT is:</h2>\n    <pre ng-show=\"jwt\" class=\"jwt\"><code>{{jwt}}</code></pre>\n    <pre ng-show=\"jwt\" class=\"jwt\"><code>{{decodedJwt | json}}</code></pre>\n    <p>Click any of the buttons to call an API and get a response</p>\n    <p><a class=\"btn btn-primary btn-lg\" role=\"button\" ng-click=\"callAnonymousApi()\">Call Anonymous API</a></p>\n    <p><a class=\"btn btn-primary btn-lg\" role=\"button\" ng-click=\"callSecuredApi()\">Call Secure API</a></p>\n    <h2 ng-show=\"response\">The response of calling the <span class=\"red\">{{api}}</span> API is:</h2>\n    <h3 ng-show=\"response\">{{response}}</h3>\n  </div>\n\n\n\n</div>\n"
  },
  {
    "path": "frontend/home/home.js",
    "content": "angular.module( 'sample.home', [\n  'ui.router',\n  'angular-storage',\n  'angular-jwt'\n])\n.config(function($stateProvider) {\n  $stateProvider.state('home', {\n    url: '/',\n    controller: 'HomeCtrl',\n    templateUrl: 'home/home.html',\n    data: {\n      requiresLogin: true\n    }\n  });\n})\n.controller( 'HomeCtrl', function HomeController( $scope, $http, store, jwtHelper) {\n\n  $scope.jwt = store.get('jwt');\n  $scope.decodedJwt = $scope.jwt && jwtHelper.decodeToken($scope.jwt);\n\n  $scope.callAnonymousApi = function() {\n    // Just call the API as you'd do using $http\n    callApi('Anonymous', 'http://localhost:3001/api/random-quote');\n  }\n\n  $scope.callSecuredApi = function() {\n    callApi('Secured', 'http://localhost:3001/api/protected/random-quote');\n  }\n\n  function callApi(type, url) {\n    $scope.response = null;\n    $scope.api = type;\n    $http({\n      url: url,\n      method: 'GET'\n    }).then(function(quote) {\n      $scope.response = quote.data;\n    }, function(error) {\n      $scope.response = error.data;\n    });\n  }\n\n});\n"
  },
  {
    "path": "frontend/index.html",
    "content": "<!DOCTYPE html>\n<html ng-app=\"sample\" ng-controller=\"AppCtrl\">\n  <head>\n    <title ng-bind=\"pageTitle\"></title>\n\n    <meta name=\"viewport\" content=\"width=device-width, initial-scale=1\">\n\n    <!-- font awesome from BootstrapCDN -->\n    <link href=\"vendor/bootstrap/dist/css/bootstrap.css\" rel=\"stylesheet\">\n    <link href=\"vendor/font-awesome/css/font-awesome.css\" rel=\"stylesheet\">\n    <link rel=\"stylesheet\" type=\"text/css\" href=\"app.css\">\n    <link rel=\"stylesheet\" type=\"text/css\" href=\"home/home.css\">\n    <link rel=\"stylesheet\" type=\"text/css\" href=\"signup/signup.css\">\n    <link rel=\"stylesheet\" type=\"text/css\" href=\"login/login.css\">\n\n    <script type=\"text/javascript\" src=\"vendor/angularjs/angular.js\"></script>\n    <script type=\"text/javascript\" src=\"vendor/angular-ui-router/release/angular-ui-router.js\"></script>\n    <script src=\"vendor/a0-angular-storage/dist/angular-storage.js\" type=\"text/javascript\"> </script>\n    <script src=\"vendor/angular-jwt/dist/angular-jwt.js\" type=\"text/javascript\"> </script>\n\n    <script type=\"text/javascript\" src=\"app.js\"></script>\n    <script type=\"text/javascript\" src=\"home/home.js\"></script>\n    <script type=\"text/javascript\" src=\"login/login.js\"></script>\n    <script type=\"text/javascript\" src=\"signup/signup.js\"></script>\n\n  </head>\n  <body>\n    <div class=\"container\" ui-view></div>\n  </body>\n</html>\n"
  },
  {
    "path": "frontend/login/login.css",
    "content": ".login {\n  width: 40%;\n}\n"
  },
  {
    "path": "frontend/login/login.html",
    "content": "<div class=\"login jumbotron center-block\">\n  <h1>Login</h1>\n  <form role=\"form\">\n  <div class=\"form-group\">\n    <label for=\"username\">Username</label>\n    <input type=\"text\" class=\"form-control\" ng-model=\"user.username\" id=\"username\" placeholder=\"Username\">\n  </div>\n  <div class=\"form-group\">\n    <label for=\"password\">Password</label>\n    <input type=\"password\" class=\"form-control\" id=\"password\" ng-model=\"user.password\" placeholder=\"Password\">\n  </div>\n  <button type=\"submit\" class=\"btn btn-default\" ng-click=\"login()\">Submit</button>\n</form>\n<a ui-sref=\"signup()\">Click here to Signup</a>\n</div>\n"
  },
  {
    "path": "frontend/login/login.js",
    "content": "angular.module( 'sample.login', [\n  'ui.router',\n  'angular-storage'\n])\n.config(function($stateProvider) {\n  $stateProvider.state('login', {\n    url: '/login',\n    controller: 'LoginCtrl',\n    templateUrl: 'login/login.html'\n  });\n})\n.controller( 'LoginCtrl', function LoginController( $scope, $http, store, $state) {\n\n  $scope.user = {};\n\n  $scope.login = function() {\n    $http({\n      url: 'http://localhost:3001/sessions/create',\n      method: 'POST',\n      data: $scope.user\n    }).then(function(response) {\n      store.set('jwt', response.data.id_token);\n      $state.go('home');\n    }, function(error) {\n      alert(error.data);\n    });\n  }\n\n});\n"
  },
  {
    "path": "frontend/signup/signup.css",
    "content": ".signup {\n  width: 40%;\n}\n"
  },
  {
    "path": "frontend/signup/signup.html",
    "content": "\n<div class=\"signup center-block jumbotron\">\n  <form role=\"form\">\n  <h1>Signup</h1>\n  <div class=\"form-group\">\n    <label for=\"username\">Username</label>\n    <input type=\"text\" class=\"form-control\" id=\"username\" ng-model=\"user.username\" placeholder=\"Username\">\n  </div>\n  <div class=\"form-group\">\n    <label for=\"password\">Password</label>\n    <input type=\"password\" class=\"form-control\" id=\"password\" ng-model=\"user.password\" placeholder=\"Password\">\n  </div>\n  <div class=\"form-group\">\n    <label for=\"extra\">Extra</label>\n    <input type=\"text\" class=\"form-control\" id=\"extra\" ng-model=\"user.extra\" placeholder=\"Extra Information\">\n  </div>\n  <button type=\"submit\" class=\"btn btn-default\" ng-click=\"createUser()\">Submit</button>\n</form>\n<a ui-sref=\"login()\">Click here to Login</a>\n</div>\n"
  },
  {
    "path": "frontend/signup/signup.js",
    "content": "angular.module( 'sample.signup', [\n  'ui.router',\n  'angular-storage'\n])\n.config(function($stateProvider) {\n  $stateProvider.state('signup', {\n    url: '/signup',\n    controller: 'SignupCtrl',\n    templateUrl: 'signup/signup.html'\n  });\n})\n.controller( 'SignupCtrl', function SignupController( $scope, $http, store, $state) {\n\n  $scope.user = {};\n\n  $scope.createUser = function() {\n    $http({\n      url: 'http://localhost:3001/users',\n      method: 'POST',\n      data: $scope.user\n    }).then(function(response) {\n      store.set('jwt', response.data.id_token);\n      $state.go('home');\n    }, function(error) {\n      alert(error.data);\n    });\n  }\n\n});\n"
  }
]