http://git-wip-us.apache.org/repos/asf/rave/blob/277e58a4/rave-portal-ng/src/subapps/auth/create-account/controllers/create-account.js ---------------------------------------------------------------------- diff --git a/rave-portal-ng/src/subapps/auth/create-account/controllers/create-account.js b/rave-portal-ng/src/subapps/auth/create-account/controllers/create-account.js index 44fcab5..5cbbd8a 100644 --- a/rave-portal-ng/src/subapps/auth/create-account/controllers/create-account.js +++ b/rave-portal-ng/src/subapps/auth/create-account/controllers/create-account.js @@ -1,9 +1,11 @@ -define(function(require) { - var auth = require('../../auth'); - require('../providers/create-account-api'); +/* + * createAccountController + * Passes our form off to the createAccountApi when the form is submitted + * + */ - auth.controller('createAccountController', [ - '$scope', 'createAccountApi', +define(function(require) { + return ['$scope', 'createAccountApi', function($scope, createAccountApi) { // We call this method when they submit the form. @@ -24,5 +26,5 @@ define(function(require) { }); }; } - ]); + ]; });
http://git-wip-us.apache.org/repos/asf/rave/blob/277e58a4/rave-portal-ng/src/subapps/auth/create-account/create-account.html ---------------------------------------------------------------------- diff --git a/rave-portal-ng/src/subapps/auth/create-account/create-account.html b/rave-portal-ng/src/subapps/auth/create-account/create-account.html deleted file mode 100644 index ab55c20..0000000 --- a/rave-portal-ng/src/subapps/auth/create-account/create-account.html +++ /dev/null @@ -1,136 +0,0 @@ -<div class="row-fluid" ng-controller="createAccountController"> - <div class="span10 offset1"> - <a ui-sref="portal.login">« Return to Login</a> - <h1>Create New Account</h1> - <form class="form-horizontal well create-account-form" name="createAccountForm" ng-submit="submit(accountInfo)" ng-if="!success"> - <h2> - Account Information - </h2> - <div class="alert"> - Fields marked with * are required. - </div> - <fieldset> - <div class="control-group" ng-class="{error: submitted && createAccountForm.username.$error.required}"> - <label class="control-label" for="username">*Username:</label> - <div class="controls"> - <input id="username" name="username" autofocus="autofocus" autocorrect="off" required autocapitalize="off" type="text" class="valid" ng-model="accountInfo.username"> - <span id="inline-help" ng-show="submitted && createAccountForm.username.$error.required"> - A username is required. - </span> - </div> - </div> - <div class="control-group" ng-class="{error: submitted && createAccountForm.accountPassword.$error.required}"> - <label class="control-label" for="accountPassword">*Password:</label> - <div class="controls"> - <input id="accountPassword" name="accountPassword" required type="password" ng-model="accountInfo.password"> - <span id="inline-help" ng-show="submitted && createAccountForm.accountPassword.$error.required"> - A password is required. - </span> - </div> - </div> - <div class="control-group" ng-class="{error: submitted && createAccountForm.confirmPassword.$error.required || createAccountForm.confirmPassword.$error.pwmatch}"> - <label class="control-label" for="confirm-password">*Confirm password:</label> - <div class="controls"> - <input id="confirm-password" name="confirmPassword" required type="password" ng-model="accountInfo.confirmPassword" pw-check="accountPassword"> - <span id="inline-help" ng-show="submitted && createAccountForm.confirmPassword.$error.required"> - Please confirm your password. - </span> - <span id="inline-help" ng-show="createAccountForm.confirmPassword.$error.pwmatch"> - The passwords don't match. - </span> - </div> - </div> - <div class="control-group" ng-class="{error: submitted && createAccountForm.email.$error.required}"> - <label class="control-label" for="email">*Email address:</label> - <div class="controls"> - <input type="email" id="email" name="email" required ng-model="accountInfo.email"> - <span id="inline-help" ng-show="submitted && createAccountForm.email.$error.required"> - An email is required. - </span> - </div> - </div> - <div class="control-group"> - <label class="control-label" for="open-id">OpenID URL:</label> - <div class="controls"> - <input id="open-id" name="openId" type="text" ng-model="accountInfo.openIdUrl"> - </div> - </div> - <div class="control-group"> - <label class="control-label" for="page-layout">Default page layout:</label> - <div class="controls"> - <select id="page-layout" name="default-page-layout" ng-model="accountInfo.defaultPageLayout"> - <option id="columns_1" value="columns_1">One Column</option> - <option id="columns_2" value="columns_2">Two Columns</option> - <option id="columns_2wn" value="columns_2wn">Two Columns (wide/narrow)</option> - <option id="columns_3" value="columns_3">Three Columns</option> - <option id="columns_3nwn" value="columns_3nwn">Three Columns (narrow/wide/narrow)</option> - <option id="columns_4" value="columns_4">Four Columns</option> - <option id="columns_3nwn_1_bottom" value="columns_3nwn_1_bottom">Four Columns (narrow/wide/narrow/bottom)</option> - </select> - </div> - </div> - </fieldset> - <fieldset> - <div class="control-group"> - <div class="controls"></div> - </div> - </fieldset> - <h2>Personal Information</h2> - <div class="alert alert-info"> - Don't want to include personal information? Don't worry â it's all optional. - </div> - <fieldset> - <div class="control-group"> - <label class="control-label" for="first-name">First name:</label> - <div class="controls"> - <input id="first-name" name="first-name" type="text" ng-model="accountInfo.firstName"> - </div> - </div> - <div class="control-group"> - <label class="control-label" for="last-name">Last name:</label> - <div class="controls"> - <input id="last-name" name="last-name" type="text" ng-model="accountInfo.lastName"> - </div> - </div> - <div class="control-group"> - <label class="control-label" for="display-name">Display name:</label> - <div class="controls"> - <input id="display-name" name="display-name" type="text" ng-model="accountInfo.displayName"> - </div> - </div> - <div class="control-group"> - <label class="control-label" for="status">Relationship status:</label> - <div class="controls"> - <select id="status" name="status" ng-model="accountInfo.relationshipStatus"> - <option id="single" value="Single" selected>Single</option> - <option id="committed" value="Committed">Committed</option> - <option id="married" value="Married">Married</option> - <option id="other" value="Other">Other</option> - </select> - </div> - </div> - <div class="control-group"> - <label class="control-label" for="about-me">Describe yourself:</label> - <div class="controls"> - <textarea id="about-me" name="about-me" ng-model="accountInfo.aboutMe"></textarea> - </div> - </div> - </fieldset> - <fieldset> - <div class="control-group" ng-class="{error: invalid}"> - <button class="btn btn-primary" ng-click="submitted=true"> - Create Account - </button> - <span class="help-inline" ng-show="invalid"> - {{ error }} - </span> - </div> - </fieldset> - </form> - <div ng-if="success" class="alert alert-success"> - Success! Your account was created, {{ username }}. - <br>You should receive the confirmation email that was sent to {{ email }} shortly. - </div> - </div> - -</div> http://git-wip-us.apache.org/repos/asf/rave/blob/277e58a4/rave-portal-ng/src/subapps/auth/create-account/create-account.js ---------------------------------------------------------------------- diff --git a/rave-portal-ng/src/subapps/auth/create-account/create-account.js b/rave-portal-ng/src/subapps/auth/create-account/create-account.js new file mode 100644 index 0000000..a204759 --- /dev/null +++ b/rave-portal-ng/src/subapps/auth/create-account/create-account.js @@ -0,0 +1,45 @@ +/* + * createAccount + * The module that manages everything for the creation of a new + * account. + * + */ + +define(function(require) { + var ng = require('angular'); + + // Ensure that our dependencies are loaded + require('uiRouter'); + var authApi = require('../api/api'); + + // Put our dependencies into an array for Angular's dependency injection + var createAccountDependencies = [ + 'ui.router', + authApi.name + ]; + + // Create our subapp as a module + var createAccount = ng.module('createAccount', createAccountDependencies); + + // Controllers + var createAccountCtrl = require('./controllers/create-account'); + createAccount.controller('createAccountController', createAccountCtrl); + + // Directives + var passwordCheckDirective = require('./directives/password-check'); + createAccount.directive('pwCheck', passwordCheckDirective); + + // Services + var createAccountApiRoutes = require('./services/create-account-api-routes'); + createAccount.factory('createAccountApiRoutes', createAccountApiRoutes); + + var createAccountApi = require('./services/create-account-api'); + createAccount.factory('createAccountApi', createAccountApi); + + // Register our routes for this subapp + var routes = require('./routes'); + createAccount.config(routes); + + // Return the module + return createAccount; +}); http://git-wip-us.apache.org/repos/asf/rave/blob/277e58a4/rave-portal-ng/src/subapps/auth/create-account/create-account.less ---------------------------------------------------------------------- diff --git a/rave-portal-ng/src/subapps/auth/create-account/create-account.less b/rave-portal-ng/src/subapps/auth/create-account/create-account.less deleted file mode 100644 index e69de29..0000000 http://git-wip-us.apache.org/repos/asf/rave/blob/277e58a4/rave-portal-ng/src/subapps/auth/create-account/directives/password-check.js ---------------------------------------------------------------------- diff --git a/rave-portal-ng/src/subapps/auth/create-account/directives/password-check.js b/rave-portal-ng/src/subapps/auth/create-account/directives/password-check.js new file mode 100644 index 0000000..4d3b8d4 --- /dev/null +++ b/rave-portal-ng/src/subapps/auth/create-account/directives/password-check.js @@ -0,0 +1,31 @@ +/* + * pwCheck + * A little directive for custom error handling on the account creation form. + * + */ + +define(function(require) { + var $ = require('jquery'); + + return function () { + return { + require: 'ngModel', + link: function (scope, elem, attrs, ctrl) { + var firstPasswordEl = $('#' + attrs.pwCheck); + elem = $(elem); + var els = elem.add(firstPasswordEl); + els.on('keyup', function () { + scope.$apply(function () { + var validity; + if (!firstPasswordEl.val() || !elem.val()) { + validity = true; + } else { + validity = elem.val() === firstPasswordEl.val(); + } + ctrl.$setValidity('pwmatch', validity); + }); + }); + } + }; + }; +}); http://git-wip-us.apache.org/repos/asf/rave/blob/277e58a4/rave-portal-ng/src/subapps/auth/create-account/less/create-account.less ---------------------------------------------------------------------- diff --git a/rave-portal-ng/src/subapps/auth/create-account/less/create-account.less b/rave-portal-ng/src/subapps/auth/create-account/less/create-account.less new file mode 100644 index 0000000..e69de29 http://git-wip-us.apache.org/repos/asf/rave/blob/277e58a4/rave-portal-ng/src/subapps/auth/create-account/providers/create-account-api-routes.js ---------------------------------------------------------------------- diff --git a/rave-portal-ng/src/subapps/auth/create-account/providers/create-account-api-routes.js b/rave-portal-ng/src/subapps/auth/create-account/providers/create-account-api-routes.js deleted file mode 100644 index 53c9322..0000000 --- a/rave-portal-ng/src/subapps/auth/create-account/providers/create-account-api-routes.js +++ /dev/null @@ -1,20 +0,0 @@ -/* - * auth-api-routes - * Defines our API routes in a single location. - * - */ - -define(function(require) { - var auth = require('../../auth'); - require('../../services/auth-api-base'); - - auth.factory('createAccountApiRoutes', [ - 'apiRoute', 'authApiBase', - function(apiRoute, authApiBase) { - var base = apiRoute + authApiBase; - return { - createAccount: base + 'create-account', - }; - } - ]); -}); http://git-wip-us.apache.org/repos/asf/rave/blob/277e58a4/rave-portal-ng/src/subapps/auth/create-account/providers/create-account-api.js ---------------------------------------------------------------------- diff --git a/rave-portal-ng/src/subapps/auth/create-account/providers/create-account-api.js b/rave-portal-ng/src/subapps/auth/create-account/providers/create-account-api.js deleted file mode 100644 index 390488a..0000000 --- a/rave-portal-ng/src/subapps/auth/create-account/providers/create-account-api.js +++ /dev/null @@ -1,27 +0,0 @@ -/* - * api - * Exposes high-level methods for interacting with the remote API for authentication. - * All methods defer to $http and, consequently, return an HttpPromise. - * - * There is NEVER a need to use this service directly. Instead, all external auth-related - * activities should go through the securityService. - * - */ - -define(function(require) { - var auth = require('../../auth'); - require('./create-account-api-routes'); - - auth.factory('createAccountApi', [ - '$http', 'createAccountApiRoutes', - function($http, apiRoutes) { - - // Each of our auth routes. - return { - createAccount: function(accountInfo) { - return $http.post(apiRoutes.createAccount, accountInfo); - } - }; - } - ]); -}); http://git-wip-us.apache.org/repos/asf/rave/blob/277e58a4/rave-portal-ng/src/subapps/auth/create-account/routes.js ---------------------------------------------------------------------- diff --git a/rave-portal-ng/src/subapps/auth/create-account/routes.js b/rave-portal-ng/src/subapps/auth/create-account/routes.js index f9157cf..f5a81c4 100644 --- a/rave-portal-ng/src/subapps/auth/create-account/routes.js +++ b/rave-portal-ng/src/subapps/auth/create-account/routes.js @@ -1,15 +1,17 @@ -define(function(require) { - require('../auth'); - var angular = require('angular'); +/* + * routes + * The Angular UI-Router states for this section of the application. + * + */ - angular.module('auth').config([ - '$stateProvider', '$urlRouterProvider', +define(function(require) { + return ['$stateProvider', '$urlRouterProvider', function($stateProvider, $urlRouterProvider) { $stateProvider.state('portal.createAccount', { url: '/create-account', - templateUrl: '/subapps/auth/create-account/create-account.html', + templateUrl: '/subapps/auth/create-account/templates/create-account.html', authenticate: 'no' }); } - ]); + ]; }); http://git-wip-us.apache.org/repos/asf/rave/blob/277e58a4/rave-portal-ng/src/subapps/auth/create-account/services/create-account-api-routes.js ---------------------------------------------------------------------- diff --git a/rave-portal-ng/src/subapps/auth/create-account/services/create-account-api-routes.js b/rave-portal-ng/src/subapps/auth/create-account/services/create-account-api-routes.js new file mode 100644 index 0000000..995fbf9 --- /dev/null +++ b/rave-portal-ng/src/subapps/auth/create-account/services/create-account-api-routes.js @@ -0,0 +1,16 @@ +/* + * createAccountApiRoutes + * Defines our API routes in a single location. + * + */ + +define(function(require) { + return ['apiRoute', 'authApiBase', + function(apiRoute, authApiBase) { + var base = apiRoute + authApiBase; + return { + createAccount: base + 'create-account', + }; + } + ]; +}); http://git-wip-us.apache.org/repos/asf/rave/blob/277e58a4/rave-portal-ng/src/subapps/auth/create-account/services/create-account-api.js ---------------------------------------------------------------------- diff --git a/rave-portal-ng/src/subapps/auth/create-account/services/create-account-api.js b/rave-portal-ng/src/subapps/auth/create-account/services/create-account-api.js new file mode 100644 index 0000000..520da8b --- /dev/null +++ b/rave-portal-ng/src/subapps/auth/create-account/services/create-account-api.js @@ -0,0 +1,19 @@ +/* + * createAccountApi + * Our client-side API for interacting with the server-side API + * + */ + +define(function(require) { + return ['$http', 'createAccountApiRoutes', + function($http, apiRoutes) { + + // Each of our auth routes. + return { + createAccount: function(accountInfo) { + return $http.post(apiRoutes.createAccount, accountInfo); + } + }; + } + ]; +}); http://git-wip-us.apache.org/repos/asf/rave/blob/277e58a4/rave-portal-ng/src/subapps/auth/create-account/templates/create-account.html ---------------------------------------------------------------------- diff --git a/rave-portal-ng/src/subapps/auth/create-account/templates/create-account.html b/rave-portal-ng/src/subapps/auth/create-account/templates/create-account.html new file mode 100644 index 0000000..ab55c20 --- /dev/null +++ b/rave-portal-ng/src/subapps/auth/create-account/templates/create-account.html @@ -0,0 +1,136 @@ +<div class="row-fluid" ng-controller="createAccountController"> + <div class="span10 offset1"> + <a ui-sref="portal.login">« Return to Login</a> + <h1>Create New Account</h1> + <form class="form-horizontal well create-account-form" name="createAccountForm" ng-submit="submit(accountInfo)" ng-if="!success"> + <h2> + Account Information + </h2> + <div class="alert"> + Fields marked with * are required. + </div> + <fieldset> + <div class="control-group" ng-class="{error: submitted && createAccountForm.username.$error.required}"> + <label class="control-label" for="username">*Username:</label> + <div class="controls"> + <input id="username" name="username" autofocus="autofocus" autocorrect="off" required autocapitalize="off" type="text" class="valid" ng-model="accountInfo.username"> + <span id="inline-help" ng-show="submitted && createAccountForm.username.$error.required"> + A username is required. + </span> + </div> + </div> + <div class="control-group" ng-class="{error: submitted && createAccountForm.accountPassword.$error.required}"> + <label class="control-label" for="accountPassword">*Password:</label> + <div class="controls"> + <input id="accountPassword" name="accountPassword" required type="password" ng-model="accountInfo.password"> + <span id="inline-help" ng-show="submitted && createAccountForm.accountPassword.$error.required"> + A password is required. + </span> + </div> + </div> + <div class="control-group" ng-class="{error: submitted && createAccountForm.confirmPassword.$error.required || createAccountForm.confirmPassword.$error.pwmatch}"> + <label class="control-label" for="confirm-password">*Confirm password:</label> + <div class="controls"> + <input id="confirm-password" name="confirmPassword" required type="password" ng-model="accountInfo.confirmPassword" pw-check="accountPassword"> + <span id="inline-help" ng-show="submitted && createAccountForm.confirmPassword.$error.required"> + Please confirm your password. + </span> + <span id="inline-help" ng-show="createAccountForm.confirmPassword.$error.pwmatch"> + The passwords don't match. + </span> + </div> + </div> + <div class="control-group" ng-class="{error: submitted && createAccountForm.email.$error.required}"> + <label class="control-label" for="email">*Email address:</label> + <div class="controls"> + <input type="email" id="email" name="email" required ng-model="accountInfo.email"> + <span id="inline-help" ng-show="submitted && createAccountForm.email.$error.required"> + An email is required. + </span> + </div> + </div> + <div class="control-group"> + <label class="control-label" for="open-id">OpenID URL:</label> + <div class="controls"> + <input id="open-id" name="openId" type="text" ng-model="accountInfo.openIdUrl"> + </div> + </div> + <div class="control-group"> + <label class="control-label" for="page-layout">Default page layout:</label> + <div class="controls"> + <select id="page-layout" name="default-page-layout" ng-model="accountInfo.defaultPageLayout"> + <option id="columns_1" value="columns_1">One Column</option> + <option id="columns_2" value="columns_2">Two Columns</option> + <option id="columns_2wn" value="columns_2wn">Two Columns (wide/narrow)</option> + <option id="columns_3" value="columns_3">Three Columns</option> + <option id="columns_3nwn" value="columns_3nwn">Three Columns (narrow/wide/narrow)</option> + <option id="columns_4" value="columns_4">Four Columns</option> + <option id="columns_3nwn_1_bottom" value="columns_3nwn_1_bottom">Four Columns (narrow/wide/narrow/bottom)</option> + </select> + </div> + </div> + </fieldset> + <fieldset> + <div class="control-group"> + <div class="controls"></div> + </div> + </fieldset> + <h2>Personal Information</h2> + <div class="alert alert-info"> + Don't want to include personal information? Don't worry â it's all optional. + </div> + <fieldset> + <div class="control-group"> + <label class="control-label" for="first-name">First name:</label> + <div class="controls"> + <input id="first-name" name="first-name" type="text" ng-model="accountInfo.firstName"> + </div> + </div> + <div class="control-group"> + <label class="control-label" for="last-name">Last name:</label> + <div class="controls"> + <input id="last-name" name="last-name" type="text" ng-model="accountInfo.lastName"> + </div> + </div> + <div class="control-group"> + <label class="control-label" for="display-name">Display name:</label> + <div class="controls"> + <input id="display-name" name="display-name" type="text" ng-model="accountInfo.displayName"> + </div> + </div> + <div class="control-group"> + <label class="control-label" for="status">Relationship status:</label> + <div class="controls"> + <select id="status" name="status" ng-model="accountInfo.relationshipStatus"> + <option id="single" value="Single" selected>Single</option> + <option id="committed" value="Committed">Committed</option> + <option id="married" value="Married">Married</option> + <option id="other" value="Other">Other</option> + </select> + </div> + </div> + <div class="control-group"> + <label class="control-label" for="about-me">Describe yourself:</label> + <div class="controls"> + <textarea id="about-me" name="about-me" ng-model="accountInfo.aboutMe"></textarea> + </div> + </div> + </fieldset> + <fieldset> + <div class="control-group" ng-class="{error: invalid}"> + <button class="btn btn-primary" ng-click="submitted=true"> + Create Account + </button> + <span class="help-inline" ng-show="invalid"> + {{ error }} + </span> + </div> + </fieldset> + </form> + <div ng-if="success" class="alert alert-success"> + Success! Your account was created, {{ username }}. + <br>You should receive the confirmation email that was sent to {{ email }} shortly. + </div> + </div> + +</div> http://git-wip-us.apache.org/repos/asf/rave/blob/277e58a4/rave-portal-ng/src/subapps/auth/directives/password-check.js ---------------------------------------------------------------------- diff --git a/rave-portal-ng/src/subapps/auth/directives/password-check.js b/rave-portal-ng/src/subapps/auth/directives/password-check.js deleted file mode 100644 index 78da6a2..0000000 --- a/rave-portal-ng/src/subapps/auth/directives/password-check.js +++ /dev/null @@ -1,26 +0,0 @@ -define(function(require) { - var $ = require('jquery'); - var auth = require('../auth'); - - auth.directive('pwCheck', function () { - return { - require: 'ngModel', - link: function (scope, elem, attrs, ctrl) { - var firstPasswordEl = $('#' + attrs.pwCheck); - elem = $(elem); - var els = elem.add(firstPasswordEl); - els.on('keyup', function () { - scope.$apply(function () { - var validity; - if (!firstPasswordEl.val() || !elem.val()) { - validity = true; - } else { - validity = elem.val() === firstPasswordEl.val(); - } - ctrl.$setValidity('pwmatch', validity); - }); - }); - } - }; - }); -}); http://git-wip-us.apache.org/repos/asf/rave/blob/277e58a4/rave-portal-ng/src/subapps/auth/forgot-password/controllers/forgot-password.js ---------------------------------------------------------------------- diff --git a/rave-portal-ng/src/subapps/auth/forgot-password/controllers/forgot-password.js b/rave-portal-ng/src/subapps/auth/forgot-password/controllers/forgot-password.js index 49d744c..9f2ec45 100644 --- a/rave-portal-ng/src/subapps/auth/forgot-password/controllers/forgot-password.js +++ b/rave-portal-ng/src/subapps/auth/forgot-password/controllers/forgot-password.js @@ -1,9 +1,11 @@ -define(function(require) { - var auth = require('../../auth'); - require('../providers/forgot-password-api'); +/* + * forgotPasswordController + * Sends off a completed form to our forgotPasswordApi + * + */ - auth.controller('forgotPasswordController', [ - '$scope', 'forgotPasswordApi', +define(function(require) { + return ['$scope', 'forgotPasswordApi', function($scope, forgotPasswordApi) { // We call this method when they submit the form. @@ -22,5 +24,5 @@ define(function(require) { }); }; } - ]); + ]; }); http://git-wip-us.apache.org/repos/asf/rave/blob/277e58a4/rave-portal-ng/src/subapps/auth/forgot-password/forgot-password.html ---------------------------------------------------------------------- diff --git a/rave-portal-ng/src/subapps/auth/forgot-password/forgot-password.html b/rave-portal-ng/src/subapps/auth/forgot-password/forgot-password.html deleted file mode 100644 index 3fe7768..0000000 --- a/rave-portal-ng/src/subapps/auth/forgot-password/forgot-password.html +++ /dev/null @@ -1,32 +0,0 @@ -<div class="row-fluid" ng-controller="forgotPasswordController"> - <div class="span10 offset1"> - <a ui-sref="portal.login">« Return to Login</a> - <h1>Request new password</h1> - <form name="requestPasswordForm" class="form-horizontal well forgot-password-form" ng-submit="submit(email)" ng-if="!success"> - <fieldset> - <div class="control-group" ng-class="{error: submitted && requestPasswordForm.email.$error.required}"> - <label class="control-label" for="email">Email address:</label> - <div class="controls"> - <input type="email" name="email" id="email" autofocus="autofocus" ng-model="email" required> - <span class="help-inline" ng-show="submitted && requestPasswordForm.email.$error.required"> - An email is required. - </span> - </div> - </div> - </fieldset> - <fieldset> - <div class="control-group" ng-class="{error: invalid}"> - <button class="btn btn-primary" ng-click="submitted=true"> - Request new password - </button> - <span class="help-inline" ng-show="invalid"> - No user with that email exists. - </span> - </div> - </fieldset> - </form> - <div ng-if="success" class="alert alert-success"> - An email was sent to {{ email }} with instructions on how to reset your password. - </div> - </div> -</div> http://git-wip-us.apache.org/repos/asf/rave/blob/277e58a4/rave-portal-ng/src/subapps/auth/forgot-password/forgot-password.js ---------------------------------------------------------------------- diff --git a/rave-portal-ng/src/subapps/auth/forgot-password/forgot-password.js b/rave-portal-ng/src/subapps/auth/forgot-password/forgot-password.js new file mode 100644 index 0000000..f938ad9 --- /dev/null +++ b/rave-portal-ng/src/subapps/auth/forgot-password/forgot-password.js @@ -0,0 +1,41 @@ +/* + * forgotPassword + * The module that manages everything for the forgot password section + * of the app. + * + */ + +define(function(require) { + var ng = require('angular'); + + // Ensure that our dependencies are loaded + require('uiRouter'); + var authApi = require('../api/api'); + + // Put our dependencies into an array for Angular's dependency injection + var forgotPasswordDependencies = [ + 'ui.router', + authApi.name + ]; + + // Create our subapp as a module + var forgotPassword = ng.module('forgotPassword', forgotPasswordDependencies); + + // Controllers + var forgotPasswordCtrl = require('./controllers/forgot-password'); + forgotPassword.controller('forgotPasswordController', forgotPasswordCtrl); + + // Services (the API) + var forgotPasswordApiRoutes = require('./services/forgot-password-api-routes'); + forgotPassword.factory('forgotPasswordApiRoutes', forgotPasswordApiRoutes); + + var forgotPasswordApi = require('./services/forgot-password-api'); + forgotPassword.factory('forgotPasswordApi', forgotPasswordApi); + + // Register our routes for this subapp + var routes = require('./routes'); + forgotPassword.config(routes); + + // Return the module + return forgotPassword; +}); http://git-wip-us.apache.org/repos/asf/rave/blob/277e58a4/rave-portal-ng/src/subapps/auth/forgot-password/providers/forgot-password-api-routes.js ---------------------------------------------------------------------- diff --git a/rave-portal-ng/src/subapps/auth/forgot-password/providers/forgot-password-api-routes.js b/rave-portal-ng/src/subapps/auth/forgot-password/providers/forgot-password-api-routes.js deleted file mode 100644 index 0555562..0000000 --- a/rave-portal-ng/src/subapps/auth/forgot-password/providers/forgot-password-api-routes.js +++ /dev/null @@ -1,20 +0,0 @@ -/* - * auth-api-routes - * Defines our API routes in a single location. - * - */ - -define(function(require) { - var auth = require('../../auth'); - require('../../services/auth-api-base'); - - auth.factory('forgotPasswordApiRoutes', [ - 'apiRoute', 'authApiBase', - function(apiRoute, authApiBase) { - var base = apiRoute + authApiBase; - return { - forgotPassword: base + 'forgot-password', - }; - } - ]); -}); http://git-wip-us.apache.org/repos/asf/rave/blob/277e58a4/rave-portal-ng/src/subapps/auth/forgot-password/providers/forgot-password-api.js ---------------------------------------------------------------------- diff --git a/rave-portal-ng/src/subapps/auth/forgot-password/providers/forgot-password-api.js b/rave-portal-ng/src/subapps/auth/forgot-password/providers/forgot-password-api.js deleted file mode 100644 index a6405b2..0000000 --- a/rave-portal-ng/src/subapps/auth/forgot-password/providers/forgot-password-api.js +++ /dev/null @@ -1,27 +0,0 @@ -/* - * api - * Exposes high-level methods for interacting with the remote API for authentication. - * All methods defer to $http and, consequently, return an HttpPromise. - * - * There is NEVER a need to use this service directly. Instead, all external auth-related - * activities should go through the securityService. - * - */ - -define(function(require) { - var auth = require('../../auth'); - require('./forgot-password-api-routes'); - - auth.factory('forgotPasswordApi', [ - '$http', 'forgotPasswordApiRoutes', - function($http, apiRoutes) { - - // Each of our auth routes. - return { - forgotPassword: function(email) { - return $http.post(apiRoutes.forgotPassword, {email:email}); - } - }; - } - ]); -}); http://git-wip-us.apache.org/repos/asf/rave/blob/277e58a4/rave-portal-ng/src/subapps/auth/forgot-password/routes.js ---------------------------------------------------------------------- diff --git a/rave-portal-ng/src/subapps/auth/forgot-password/routes.js b/rave-portal-ng/src/subapps/auth/forgot-password/routes.js index 72a7f85..ef344b8 100644 --- a/rave-portal-ng/src/subapps/auth/forgot-password/routes.js +++ b/rave-portal-ng/src/subapps/auth/forgot-password/routes.js @@ -1,15 +1,17 @@ -define(function(require) { - require('../auth'); - var angular = require('angular'); +/* + * routes + * The Angular UI-Router states for this section of the application. + * + */ - angular.module('auth').config([ - '$stateProvider', '$urlRouterProvider', +define(function(require) { + return ['$stateProvider', '$urlRouterProvider', function($stateProvider, $urlRouterProvider) { $stateProvider.state('portal.forgotPassword', { url: '/forgot-password', - templateUrl: '/subapps/auth/forgot-password/forgot-password.html', + templateUrl: '/subapps/auth/forgot-password/templates/forgot-password.html', authenticate: 'no' }); } - ]); + ]; }); http://git-wip-us.apache.org/repos/asf/rave/blob/277e58a4/rave-portal-ng/src/subapps/auth/forgot-password/services/forgot-password-api-routes.js ---------------------------------------------------------------------- diff --git a/rave-portal-ng/src/subapps/auth/forgot-password/services/forgot-password-api-routes.js b/rave-portal-ng/src/subapps/auth/forgot-password/services/forgot-password-api-routes.js new file mode 100644 index 0000000..998e71c --- /dev/null +++ b/rave-portal-ng/src/subapps/auth/forgot-password/services/forgot-password-api-routes.js @@ -0,0 +1,16 @@ +/* + * forgotPasswordApiRoutes + * The server-side API routes for forgotten passwords + * + */ + +define(function(require) { + return ['apiRoute', 'authApiBase', + function(apiRoute, authApiBase) { + var base = apiRoute + authApiBase; + return { + forgotPassword: base + 'forgot-password', + }; + } + ]; +}); http://git-wip-us.apache.org/repos/asf/rave/blob/277e58a4/rave-portal-ng/src/subapps/auth/forgot-password/services/forgot-password-api.js ---------------------------------------------------------------------- diff --git a/rave-portal-ng/src/subapps/auth/forgot-password/services/forgot-password-api.js b/rave-portal-ng/src/subapps/auth/forgot-password/services/forgot-password-api.js new file mode 100644 index 0000000..4adef5d --- /dev/null +++ b/rave-portal-ng/src/subapps/auth/forgot-password/services/forgot-password-api.js @@ -0,0 +1,19 @@ +/* + * forgotPasswordApi + * Our client-side API for our server-side API + * + */ + +define(function(require) { + return ['$http', 'forgotPasswordApiRoutes', + function($http, apiRoutes) { + + // Each of our auth routes. + return { + forgotPassword: function(email) { + return $http.post(apiRoutes.forgotPassword, {email:email}); + } + }; + } + ]; +}); http://git-wip-us.apache.org/repos/asf/rave/blob/277e58a4/rave-portal-ng/src/subapps/auth/forgot-password/templates/forgot-password.html ---------------------------------------------------------------------- diff --git a/rave-portal-ng/src/subapps/auth/forgot-password/templates/forgot-password.html b/rave-portal-ng/src/subapps/auth/forgot-password/templates/forgot-password.html new file mode 100644 index 0000000..3fe7768 --- /dev/null +++ b/rave-portal-ng/src/subapps/auth/forgot-password/templates/forgot-password.html @@ -0,0 +1,32 @@ +<div class="row-fluid" ng-controller="forgotPasswordController"> + <div class="span10 offset1"> + <a ui-sref="portal.login">« Return to Login</a> + <h1>Request new password</h1> + <form name="requestPasswordForm" class="form-horizontal well forgot-password-form" ng-submit="submit(email)" ng-if="!success"> + <fieldset> + <div class="control-group" ng-class="{error: submitted && requestPasswordForm.email.$error.required}"> + <label class="control-label" for="email">Email address:</label> + <div class="controls"> + <input type="email" name="email" id="email" autofocus="autofocus" ng-model="email" required> + <span class="help-inline" ng-show="submitted && requestPasswordForm.email.$error.required"> + An email is required. + </span> + </div> + </div> + </fieldset> + <fieldset> + <div class="control-group" ng-class="{error: invalid}"> + <button class="btn btn-primary" ng-click="submitted=true"> + Request new password + </button> + <span class="help-inline" ng-show="invalid"> + No user with that email exists. + </span> + </div> + </fieldset> + </form> + <div ng-if="success" class="alert alert-success"> + An email was sent to {{ email }} with instructions on how to reset your password. + </div> + </div> +</div> http://git-wip-us.apache.org/repos/asf/rave/blob/277e58a4/rave-portal-ng/src/subapps/auth/forgot-username/controllers/forgot-username.js ---------------------------------------------------------------------- diff --git a/rave-portal-ng/src/subapps/auth/forgot-username/controllers/forgot-username.js b/rave-portal-ng/src/subapps/auth/forgot-username/controllers/forgot-username.js index 77c8eec..59177ba 100644 --- a/rave-portal-ng/src/subapps/auth/forgot-username/controllers/forgot-username.js +++ b/rave-portal-ng/src/subapps/auth/forgot-username/controllers/forgot-username.js @@ -1,9 +1,13 @@ -define(function(require) { - var auth = require('../../auth'); - require('../providers/forgot-username-api'); +/* + * forgotUsernameController + * Processes the forgot username form by making requests + * through the forgotUsernameApi + * + */ + - auth.controller('forgotUsernameController', [ - '$scope', 'forgotUsernameApi', +define(function(require) { + return ['$scope', 'forgotUsernameApi', function($scope, forgotUsernameApi) { // We call this method when they submit the form. @@ -29,5 +33,5 @@ define(function(require) { }); }; } - ]); + ]; }); http://git-wip-us.apache.org/repos/asf/rave/blob/277e58a4/rave-portal-ng/src/subapps/auth/forgot-username/forgot-username.html ---------------------------------------------------------------------- diff --git a/rave-portal-ng/src/subapps/auth/forgot-username/forgot-username.html b/rave-portal-ng/src/subapps/auth/forgot-username/forgot-username.html deleted file mode 100644 index 71dc39b..0000000 --- a/rave-portal-ng/src/subapps/auth/forgot-username/forgot-username.html +++ /dev/null @@ -1,32 +0,0 @@ -<div class="row-fluid" ng-controller="forgotUsernameController"> - <div class="span10 offset1"> - <a ui-sref="portal.login">« Return to Login</a> - <h1>Request username</h1> - <form name="requestUsernameForm" class="form-horizontal well forgot-username-form" ng-if="!success" ng-submit="submit(email)"> - <fieldset> - <div class="control-group" ng-class="{error: submitted && requestUsernameForm.email.$error.required}"> - <label class="control-label" for="email">Email address:</label> - <div class="controls"> - <input type="email" name="email" id="email" autofocus="autofocus" ng-model="email" required> - <span class="help-inline" ng-show="submitted && requestUsernameForm.email.$error.required"> - An email is required. - </span> - </div> - </div> - </fieldset> - <fieldset> - <div class="control-group" ng-class="{error: invalid}"> - <button class="btn btn-primary" ng-click="submitted=true"> - Request username - </button> - <span class="help-inline" ng-show="invalid"> - No user with that email exists. - </span> - </div> - </fieldset> - </form> - <div ng-if="success" class="alert alert-success"> - An email was sent to {{ email }} that includes your username. - </div> - </div> -</div> http://git-wip-us.apache.org/repos/asf/rave/blob/277e58a4/rave-portal-ng/src/subapps/auth/forgot-username/forgot-username.js ---------------------------------------------------------------------- diff --git a/rave-portal-ng/src/subapps/auth/forgot-username/forgot-username.js b/rave-portal-ng/src/subapps/auth/forgot-username/forgot-username.js new file mode 100644 index 0000000..57274bd --- /dev/null +++ b/rave-portal-ng/src/subapps/auth/forgot-username/forgot-username.js @@ -0,0 +1,41 @@ +/* + * forgotUsername + * The module that manages everything for the forgot username section + * of the app. + * + */ + +define(function(require) { + var ng = require('angular'); + + // Ensure that our dependencies are loaded + require('uiRouter'); + var authApi = require('../api/api'); + + // Put our dependencies into an array for Angular's dependency injection + var forgotUsernameDependencies = [ + 'ui.router', + authApi.name + ]; + + // Create our subapp as a module + var forgotUsername = ng.module('forgotUsername', forgotUsernameDependencies); + + // Controllers + var forgotUsernameCtrl = require('./controllers/forgot-username'); + forgotUsername.controller('forgotUsernameController', forgotUsernameCtrl); + + // Services (the API) + var forgotUsernameApiRoutes = require('./services/forgot-username-api-routes'); + forgotUsername.factory('forgotUsernameApiRoutes', forgotUsernameApiRoutes); + + var forgotUsernameApi = require('./services/forgot-username-api'); + forgotUsername.factory('forgotUsernameApi', forgotUsernameApi); + + // Register our routes for this subapp + var routes = require('./routes'); + forgotUsername.config(routes); + + // Return the module + return forgotUsername; +}); http://git-wip-us.apache.org/repos/asf/rave/blob/277e58a4/rave-portal-ng/src/subapps/auth/forgot-username/forgot-username.less ---------------------------------------------------------------------- diff --git a/rave-portal-ng/src/subapps/auth/forgot-username/forgot-username.less b/rave-portal-ng/src/subapps/auth/forgot-username/forgot-username.less deleted file mode 100644 index 73dd88c..0000000 --- a/rave-portal-ng/src/subapps/auth/forgot-username/forgot-username.less +++ /dev/null @@ -1,10 +0,0 @@ -.forgot-username-form { - &.form-horizontal - .control-label { - width: auto; - margin-right: 20px; - } - .controls { - margin-left: 0; - } -} http://git-wip-us.apache.org/repos/asf/rave/blob/277e58a4/rave-portal-ng/src/subapps/auth/forgot-username/less/forgot-username.less ---------------------------------------------------------------------- diff --git a/rave-portal-ng/src/subapps/auth/forgot-username/less/forgot-username.less b/rave-portal-ng/src/subapps/auth/forgot-username/less/forgot-username.less new file mode 100644 index 0000000..73dd88c --- /dev/null +++ b/rave-portal-ng/src/subapps/auth/forgot-username/less/forgot-username.less @@ -0,0 +1,10 @@ +.forgot-username-form { + &.form-horizontal + .control-label { + width: auto; + margin-right: 20px; + } + .controls { + margin-left: 0; + } +} http://git-wip-us.apache.org/repos/asf/rave/blob/277e58a4/rave-portal-ng/src/subapps/auth/forgot-username/providers/forgot-username-api-routes.js ---------------------------------------------------------------------- diff --git a/rave-portal-ng/src/subapps/auth/forgot-username/providers/forgot-username-api-routes.js b/rave-portal-ng/src/subapps/auth/forgot-username/providers/forgot-username-api-routes.js deleted file mode 100644 index 72fe87f..0000000 --- a/rave-portal-ng/src/subapps/auth/forgot-username/providers/forgot-username-api-routes.js +++ /dev/null @@ -1,20 +0,0 @@ -/* - * auth-api-routes - * Defines our API routes in a single location. - * - */ - -define(function(require) { - var auth = require('../../auth'); - require('../../services/auth-api-base'); - - auth.factory('forgotUsernameApiRoutes', [ - 'apiRoute', 'authApiBase', - function(apiRoute, authApiBase) { - var base = apiRoute + authApiBase; - return { - forgotUsername: base + 'forgot-username', - }; - } - ]); -}); http://git-wip-us.apache.org/repos/asf/rave/blob/277e58a4/rave-portal-ng/src/subapps/auth/forgot-username/providers/forgot-username-api.js ---------------------------------------------------------------------- diff --git a/rave-portal-ng/src/subapps/auth/forgot-username/providers/forgot-username-api.js b/rave-portal-ng/src/subapps/auth/forgot-username/providers/forgot-username-api.js deleted file mode 100644 index e435365..0000000 --- a/rave-portal-ng/src/subapps/auth/forgot-username/providers/forgot-username-api.js +++ /dev/null @@ -1,27 +0,0 @@ -/* - * api - * Exposes high-level methods for interacting with the remote API for authentication. - * All methods defer to $http and, consequently, return an HttpPromise. - * - * There is NEVER a need to use this service directly. Instead, all external auth-related - * activities should go through the securityService. - * - */ - -define(function(require) { - var auth = require('../../auth'); - require('./forgot-username-api-routes'); - - auth.factory('forgotUsernameApi', [ - '$http', 'forgotUsernameApiRoutes', - function($http, apiRoutes) { - - // Each of our auth routes. - return { - forgotUsername: function(email) { - return $http.post(apiRoutes.forgotUsername, {email:email}); - } - }; - } - ]); -}); http://git-wip-us.apache.org/repos/asf/rave/blob/277e58a4/rave-portal-ng/src/subapps/auth/forgot-username/routes.js ---------------------------------------------------------------------- diff --git a/rave-portal-ng/src/subapps/auth/forgot-username/routes.js b/rave-portal-ng/src/subapps/auth/forgot-username/routes.js index 09e39e3..dc94207 100644 --- a/rave-portal-ng/src/subapps/auth/forgot-username/routes.js +++ b/rave-portal-ng/src/subapps/auth/forgot-username/routes.js @@ -1,15 +1,17 @@ -define(function(require) { - require('../auth'); - var angular = require('angular'); +/* + * routes + * The Angular UI-Router states for this section of the application. + * + */ - angular.module('auth').config([ - '$stateProvider', '$urlRouterProvider', +define(function(require) { + return ['$stateProvider', '$urlRouterProvider', function($stateProvider, $urlRouterProvider) { $stateProvider.state('portal.forgotUsername', { url: '/forgot-username', - templateUrl: '/subapps/auth/forgot-username/forgot-username.html', + templateUrl: '/subapps/auth/forgot-username/templates/forgot-username.html', authenticate: 'no' }); } - ]); + ]; }); http://git-wip-us.apache.org/repos/asf/rave/blob/277e58a4/rave-portal-ng/src/subapps/auth/forgot-username/services/forgot-username-api-routes.js ---------------------------------------------------------------------- diff --git a/rave-portal-ng/src/subapps/auth/forgot-username/services/forgot-username-api-routes.js b/rave-portal-ng/src/subapps/auth/forgot-username/services/forgot-username-api-routes.js new file mode 100644 index 0000000..d540775 --- /dev/null +++ b/rave-portal-ng/src/subapps/auth/forgot-username/services/forgot-username-api-routes.js @@ -0,0 +1,16 @@ +/* + * forgotUsernameApiRoutes + * Define our API routes here. Consumed by the API itself. + * + */ + +define(function(require) { + return ['apiRoute', 'authApiBase', + function(apiRoute, authApiBase) { + var base = apiRoute + authApiBase; + return { + forgotUsername: base + 'forgot-username', + }; + } + ]; +}); http://git-wip-us.apache.org/repos/asf/rave/blob/277e58a4/rave-portal-ng/src/subapps/auth/forgot-username/services/forgot-username-api.js ---------------------------------------------------------------------- diff --git a/rave-portal-ng/src/subapps/auth/forgot-username/services/forgot-username-api.js b/rave-portal-ng/src/subapps/auth/forgot-username/services/forgot-username-api.js new file mode 100644 index 0000000..85758be --- /dev/null +++ b/rave-portal-ng/src/subapps/auth/forgot-username/services/forgot-username-api.js @@ -0,0 +1,19 @@ +/* + * forgotUsernameApi + * Posts to the server that the user forgot their username! + * + */ + +define(function(require) { + return ['$http', 'forgotUsernameApiRoutes', + function($http, apiRoutes) { + + // There's just a single route for the forgot username section + return { + forgotUsername: function(email) { + return $http.post(apiRoutes.forgotUsername, {email:email}); + } + }; + } + ]; +}); http://git-wip-us.apache.org/repos/asf/rave/blob/277e58a4/rave-portal-ng/src/subapps/auth/forgot-username/templates/forgot-username.html ---------------------------------------------------------------------- diff --git a/rave-portal-ng/src/subapps/auth/forgot-username/templates/forgot-username.html b/rave-portal-ng/src/subapps/auth/forgot-username/templates/forgot-username.html new file mode 100644 index 0000000..71dc39b --- /dev/null +++ b/rave-portal-ng/src/subapps/auth/forgot-username/templates/forgot-username.html @@ -0,0 +1,32 @@ +<div class="row-fluid" ng-controller="forgotUsernameController"> + <div class="span10 offset1"> + <a ui-sref="portal.login">« Return to Login</a> + <h1>Request username</h1> + <form name="requestUsernameForm" class="form-horizontal well forgot-username-form" ng-if="!success" ng-submit="submit(email)"> + <fieldset> + <div class="control-group" ng-class="{error: submitted && requestUsernameForm.email.$error.required}"> + <label class="control-label" for="email">Email address:</label> + <div class="controls"> + <input type="email" name="email" id="email" autofocus="autofocus" ng-model="email" required> + <span class="help-inline" ng-show="submitted && requestUsernameForm.email.$error.required"> + An email is required. + </span> + </div> + </div> + </fieldset> + <fieldset> + <div class="control-group" ng-class="{error: invalid}"> + <button class="btn btn-primary" ng-click="submitted=true"> + Request username + </button> + <span class="help-inline" ng-show="invalid"> + No user with that email exists. + </span> + </div> + </fieldset> + </form> + <div ng-if="success" class="alert alert-success"> + An email was sent to {{ email }} that includes your username. + </div> + </div> +</div> http://git-wip-us.apache.org/repos/asf/rave/blob/277e58a4/rave-portal-ng/src/subapps/auth/index.js ---------------------------------------------------------------------- diff --git a/rave-portal-ng/src/subapps/auth/index.js b/rave-portal-ng/src/subapps/auth/index.js deleted file mode 100644 index d9c458e..0000000 --- a/rave-portal-ng/src/subapps/auth/index.js +++ /dev/null @@ -1,33 +0,0 @@ -define(function(require) { - require('./auth'); - - require('./directives/password-check'); - - require('./controllers/login-form'); - - require('./services/security'); - require('./services/auth-token'); - require('./services/location-cache'); - require('./services/auth-cache'); - require('./services/auth-api'); - require('./services/auth-api-base'); - require('./services/auth-api-routes'); - - require('./forgot-password/providers/forgot-password-api-routes'); - require('./forgot-password/providers/forgot-password-api'); - require('./forgot-password/controllers/forgot-password'); - - require('./forgot-username/providers/forgot-username-api-routes'); - require('./forgot-username/providers/forgot-username-api'); - require('./forgot-username/controllers/forgot-username'); - - require('./create-account/providers/create-account-api-routes'); - require('./create-account/providers/create-account-api'); - require('./create-account/controllers/create-account'); - - require('./route-intercept'); - require('./routes'); - require('./create-account/routes'); - require('./forgot-password/routes'); - require('./forgot-username/routes'); -}); http://git-wip-us.apache.org/repos/asf/rave/blob/277e58a4/rave-portal-ng/src/subapps/auth/login.html ---------------------------------------------------------------------- diff --git a/rave-portal-ng/src/subapps/auth/login.html b/rave-portal-ng/src/subapps/auth/login.html deleted file mode 100644 index ea25bc6..0000000 --- a/rave-portal-ng/src/subapps/auth/login.html +++ /dev/null @@ -1,75 +0,0 @@ -<div class="row-fluid login-page"> - <div class="span10 offset1"> - <div class="row-fluid"> - <h1 class="span12"> - Login - </h1> - </div> - <div class="row-fluid"> - <div class="alert alert-info span12"> - You can login using either your Rave credentials or with OpenID identity. - </div> - </div> - <div class="row-fluid"> - <form class="form well span6" name="loginForm" ng-controller="loginController" ng-submit="submit(credentials)"> - <div class="row-fluid"> - <div class="control-group span12" ng-class="{error: submitted && loginForm.username.$error.required}"> - <label for="username">Username</label> - <input id="username" type="text" class="input-block-level" name="username" autofocus="autofocus" autocapitalize="off" autocorrect="off" ng-model="credentials.username" required> - <div class="help-inline" ng-show="submitted && loginForm.username.$error.required"> - A username is required. - </div> - </div> - </div> - <div class="row-fluid"> - <div class="control-group span12" ng-class="{error: submitted && loginForm.password.$error.required}"> - <label for="password">Password</label> - <input id="password" type="password" class="input-block-level" name="password" ng-model="credentials.password" required> - <div class="help-inline" ng-show="submitted && loginForm.password.$error.required"> - A password is required. - </div> - </div> - </div> - <div class="row-fluid form-horizontal"> - <div class="control-group span12"> - <label class="control-label" for="zip-code">Remember me:</label> - <div class="controls"> - <input type="checkbox" name="remember-me" value="true" ng-model="credentials.remember"> - </div> - </div> - </div> - <div class="form-actions"> - <div class="control-group" ng-class="{error: invalid}"> - <button class="btn btn-primary" ng-click="submitted=true"> - Log In - </button> - <div ng-show="invalid"> - The username or password was incorrect. - </div> - </div> - </div> - </form> - <form class="form well span6" name="openIdLoginForm" ng-submit="submit(credentials)" action="j_spring_openid_security_check" method="post"> - <div class="row-fluid"> - <div class="control-group span12"> - <label for="first-name">Identity</label> - <input id="first-name" type="text" class="input-block-level"> - </div> - </div> - <div class="row-fluid form-horizontal"> - <div class="control-group span12"> - <label class="control-label" for="zip-code">Remember me:</label> - <div class="controls"> - <input type="checkbox" name="remember-me" value="true" ng-model="credentials.remember"> - </div> - </div> - </div> - <div class="form-actions"> - <div class="control-group"> - <input class="btn btn-primary" name="commit" type="submit"> - </div> - </div> - </form> - </div> - </div> -</div> http://git-wip-us.apache.org/repos/asf/rave/blob/277e58a4/rave-portal-ng/src/subapps/auth/login.less ---------------------------------------------------------------------- diff --git a/rave-portal-ng/src/subapps/auth/login.less b/rave-portal-ng/src/subapps/auth/login.less deleted file mode 100644 index a03f98a..0000000 --- a/rave-portal-ng/src/subapps/auth/login.less +++ /dev/null @@ -1,18 +0,0 @@ -.login-page { - .form-horizontal { - .control-label { - width: auto; - margin-right: 5px; - } - .controls { - margin-left: 0; - } - } - .form { - min-height: 375px; - } - - .btn { - margin-bottom: 8px; - } -} http://git-wip-us.apache.org/repos/asf/rave/blob/277e58a4/rave-portal-ng/src/subapps/auth/login/controllers/login-form.js ---------------------------------------------------------------------- diff --git a/rave-portal-ng/src/subapps/auth/login/controllers/login-form.js b/rave-portal-ng/src/subapps/auth/login/controllers/login-form.js new file mode 100644 index 0000000..a72ee09 --- /dev/null +++ b/rave-portal-ng/src/subapps/auth/login/controllers/login-form.js @@ -0,0 +1,27 @@ +/* + * loginForm + * Processes our login form by delegating to the security module + * + */ + + +define(function(require) { + return ['$scope', 'security', + function($scope, security) { + + // We call this method when they submit the form. + $scope.submit = function(credentials) { + + // Otherwise, we attempt to log them in by delegating to the + // securityService. If it's successful, the security service + // handles the rest for us. + security.login(credentials) + + // And if it errors, we catch it here. + .catch(function() { + $scope.invalid = true; + }); + }; + } + ]; +}); http://git-wip-us.apache.org/repos/asf/rave/blob/277e58a4/rave-portal-ng/src/subapps/auth/login/less/login.less ---------------------------------------------------------------------- diff --git a/rave-portal-ng/src/subapps/auth/login/less/login.less b/rave-portal-ng/src/subapps/auth/login/less/login.less new file mode 100644 index 0000000..a03f98a --- /dev/null +++ b/rave-portal-ng/src/subapps/auth/login/less/login.less @@ -0,0 +1,18 @@ +.login-page { + .form-horizontal { + .control-label { + width: auto; + margin-right: 5px; + } + .controls { + margin-left: 0; + } + } + .form { + min-height: 375px; + } + + .btn { + margin-bottom: 8px; + } +} http://git-wip-us.apache.org/repos/asf/rave/blob/277e58a4/rave-portal-ng/src/subapps/auth/login/login.js ---------------------------------------------------------------------- diff --git a/rave-portal-ng/src/subapps/auth/login/login.js b/rave-portal-ng/src/subapps/auth/login/login.js new file mode 100644 index 0000000..4e6040c --- /dev/null +++ b/rave-portal-ng/src/subapps/auth/login/login.js @@ -0,0 +1,33 @@ +/* + * login + * A module that registers the login section of the app. + * + */ + +define(function(require) { + var ng = require('angular'); + + // Ensure that our dependencies are loaded + require('uiRouter'); + var security = require('../security/security'); + + // Put our dependencies into an array for Angular's dependency injection + var loginDependencies = [ + 'ui.router', + security.name + ]; + + // Create our subapp as a module + var login = ng.module('login', loginDependencies); + + // Register our services + var loginCtrl = require('./controllers/login-form'); + login.controller('loginController', loginCtrl); + + // Register our routes for this subapp + var routes = require('./routes'); + login.config(routes); + + // Return the module + return login; +}); http://git-wip-us.apache.org/repos/asf/rave/blob/277e58a4/rave-portal-ng/src/subapps/auth/login/routes.js ---------------------------------------------------------------------- diff --git a/rave-portal-ng/src/subapps/auth/login/routes.js b/rave-portal-ng/src/subapps/auth/login/routes.js new file mode 100644 index 0000000..b01d099 --- /dev/null +++ b/rave-portal-ng/src/subapps/auth/login/routes.js @@ -0,0 +1,21 @@ +/* + * routes + * The base route for the Rave project. This makes /portal + * the root location to access the app from. + * + */ + +define(function(require) { + return['$stateProvider', '$urlRouterProvider', + function($stateProvider, $urlRouterProvider) { + + // Our login page. + // We don't allow you to access this page if you're authenticated. + $stateProvider.state('portal.login', { + url: '/login', + templateUrl: '/subapps/auth/login/templates/login.html', + authenticate: 'no' + }); + } + ]; +}); http://git-wip-us.apache.org/repos/asf/rave/blob/277e58a4/rave-portal-ng/src/subapps/auth/login/templates/login.html ---------------------------------------------------------------------- diff --git a/rave-portal-ng/src/subapps/auth/login/templates/login.html b/rave-portal-ng/src/subapps/auth/login/templates/login.html new file mode 100644 index 0000000..ea25bc6 --- /dev/null +++ b/rave-portal-ng/src/subapps/auth/login/templates/login.html @@ -0,0 +1,75 @@ +<div class="row-fluid login-page"> + <div class="span10 offset1"> + <div class="row-fluid"> + <h1 class="span12"> + Login + </h1> + </div> + <div class="row-fluid"> + <div class="alert alert-info span12"> + You can login using either your Rave credentials or with OpenID identity. + </div> + </div> + <div class="row-fluid"> + <form class="form well span6" name="loginForm" ng-controller="loginController" ng-submit="submit(credentials)"> + <div class="row-fluid"> + <div class="control-group span12" ng-class="{error: submitted && loginForm.username.$error.required}"> + <label for="username">Username</label> + <input id="username" type="text" class="input-block-level" name="username" autofocus="autofocus" autocapitalize="off" autocorrect="off" ng-model="credentials.username" required> + <div class="help-inline" ng-show="submitted && loginForm.username.$error.required"> + A username is required. + </div> + </div> + </div> + <div class="row-fluid"> + <div class="control-group span12" ng-class="{error: submitted && loginForm.password.$error.required}"> + <label for="password">Password</label> + <input id="password" type="password" class="input-block-level" name="password" ng-model="credentials.password" required> + <div class="help-inline" ng-show="submitted && loginForm.password.$error.required"> + A password is required. + </div> + </div> + </div> + <div class="row-fluid form-horizontal"> + <div class="control-group span12"> + <label class="control-label" for="zip-code">Remember me:</label> + <div class="controls"> + <input type="checkbox" name="remember-me" value="true" ng-model="credentials.remember"> + </div> + </div> + </div> + <div class="form-actions"> + <div class="control-group" ng-class="{error: invalid}"> + <button class="btn btn-primary" ng-click="submitted=true"> + Log In + </button> + <div ng-show="invalid"> + The username or password was incorrect. + </div> + </div> + </div> + </form> + <form class="form well span6" name="openIdLoginForm" ng-submit="submit(credentials)" action="j_spring_openid_security_check" method="post"> + <div class="row-fluid"> + <div class="control-group span12"> + <label for="first-name">Identity</label> + <input id="first-name" type="text" class="input-block-level"> + </div> + </div> + <div class="row-fluid form-horizontal"> + <div class="control-group span12"> + <label class="control-label" for="zip-code">Remember me:</label> + <div class="controls"> + <input type="checkbox" name="remember-me" value="true" ng-model="credentials.remember"> + </div> + </div> + </div> + <div class="form-actions"> + <div class="control-group"> + <input class="btn btn-primary" name="commit" type="submit"> + </div> + </div> + </form> + </div> + </div> +</div> http://git-wip-us.apache.org/repos/asf/rave/blob/277e58a4/rave-portal-ng/src/subapps/auth/logout/logout.js ---------------------------------------------------------------------- diff --git a/rave-portal-ng/src/subapps/auth/logout/logout.js b/rave-portal-ng/src/subapps/auth/logout/logout.js new file mode 100644 index 0000000..0672728 --- /dev/null +++ b/rave-portal-ng/src/subapps/auth/logout/logout.js @@ -0,0 +1,30 @@ +/* + * logout + * A module that registers our logout route. All this does is defer to the security + * provider to destroy our cookie and redirect us to the login page. + * + */ + +define(function(require) { + var ng = require('angular'); + + // Ensure that our dependencies are loaded + require('uiRouter'); + var security = require('../security/security'); + + // Put our dependencies into an array for Angular's dependency injection + var logoutDependencies = [ + 'ui.router', + security.name + ]; + + // Create our subapp as a module + var logout = ng.module('logout', logoutDependencies); + + // Register our routes for this subapp + var routes = require('./routes'); + logout.config(routes); + + // Return the module + return logout; +}); http://git-wip-us.apache.org/repos/asf/rave/blob/277e58a4/rave-portal-ng/src/subapps/auth/logout/routes.js ---------------------------------------------------------------------- diff --git a/rave-portal-ng/src/subapps/auth/logout/routes.js b/rave-portal-ng/src/subapps/auth/logout/routes.js new file mode 100644 index 0000000..77662bb --- /dev/null +++ b/rave-portal-ng/src/subapps/auth/logout/routes.js @@ -0,0 +1,25 @@ +/* + * routes + * The Angular UI-Router states for this section of the application. + * + */ + +define(function(require) { + return['$stateProvider', '$urlRouterProvider', + function($stateProvider, $urlRouterProvider) { + + // The logout page. All this + // does is delegate to our securityService to + // perform the actual act of logging out. + $stateProvider.state('portal.logout', { + url: '/logout', + template: '<ui-view/>', + onEnter: ['security', + function(security) { + security.logout(); + } + ] + }); + } + ]; +}); http://git-wip-us.apache.org/repos/asf/rave/blob/277e58a4/rave-portal-ng/src/subapps/auth/route-intercept.js ---------------------------------------------------------------------- diff --git a/rave-portal-ng/src/subapps/auth/route-intercept.js b/rave-portal-ng/src/subapps/auth/route-intercept.js deleted file mode 100644 index ddae604..0000000 --- a/rave-portal-ng/src/subapps/auth/route-intercept.js +++ /dev/null @@ -1,58 +0,0 @@ - -/* - * route-intercept - * Intercepts our state changes and checks our authenticity rules. - * - */ - -define(function(require) { - var auth = require('./auth'); - - require('./services/security'); - require('./services/location-cache'); - - return auth.run([ - '$rootScope', '$state', 'security', 'locationCache', - function($rootScope, $state, security, locationCache) { - - // Intercept every $stateChangeStart event. This is fired by the router - // whenever the user attempts to change the state. - $rootScope.$on('$stateChangeStart', function(event, toState, toParams){ - - // If there's nothing specified for auth, then we do nothing. By default - // they're always allowed to proceed to the next state. - if (toState.authenticate === undefined) { - return; - } - - // However, if authenticate **is** set then we need to ask security if - // we're verified. - security.verify() - - // If we *are* verified, *and* the state isn't allowed when you're verified, - // then we take you home. A common state to say 'no' on is the login page. - .then(function() { - if (toState.authenticate === 'no') { - $state.transitionTo('portal.home'); - event.preventDefault(); - } - }) - - // The most common case. We're not verified and we need to be. In this situation, - // we set the page they were trying to access in a cache, then send them to the login - // page. Later, when they login, we'll take them back to the location they intended to go - // to. - .catch(function() { - if (toState.authenticate === true) { - - locationCache.put('toState', toState); - locationCache.put('toParams', toParams); - - $state.transitionTo('portal.login'); - event.preventDefault(); - } - }); - }); - } - ]); -}); http://git-wip-us.apache.org/repos/asf/rave/blob/277e58a4/rave-portal-ng/src/subapps/auth/routes.js ---------------------------------------------------------------------- diff --git a/rave-portal-ng/src/subapps/auth/routes.js b/rave-portal-ng/src/subapps/auth/routes.js deleted file mode 100644 index e439ae6..0000000 --- a/rave-portal-ng/src/subapps/auth/routes.js +++ /dev/null @@ -1,34 +0,0 @@ -define(function(require) { - var auth = require('./auth'); - - require('./services/security'); - - auth.config([ - '$stateProvider', '$urlRouterProvider', - function($stateProvider, $urlRouterProvider) { - $stateProvider - - // Our login page. - // We don't allow you to access this page if you're authenticated. - .state('portal.login', { - url: '/login', - templateUrl: '/subapps/auth/login.html', - authenticate: 'no' - }) - - // The logout page. All this - // does is delegate to our securityService to - // perform the actual act of logging out. - .state('portal.logout', { - url: '/logout', - template: '<ui-view/>', - onEnter: [ - 'security', - function(security) { - security.logout(); - } - ] - }); - } - ]); -}); http://git-wip-us.apache.org/repos/asf/rave/blob/277e58a4/rave-portal-ng/src/subapps/auth/security/route-intercept.js ---------------------------------------------------------------------- diff --git a/rave-portal-ng/src/subapps/auth/security/route-intercept.js b/rave-portal-ng/src/subapps/auth/security/route-intercept.js new file mode 100644 index 0000000..8c08e0b --- /dev/null +++ b/rave-portal-ng/src/subapps/auth/security/route-intercept.js @@ -0,0 +1,52 @@ + +/* + * routeIntercept + * Intercepts our state changes and checks our authenticity rules. + * + */ + +define(function(require) { + return ['$rootScope', '$state', 'security', 'locationCache', + function($rootScope, $state, security, locationCache) { + + // Intercept every $stateChangeStart event. This is fired by the router + // whenever the user attempts to change the state. + $rootScope.$on('$stateChangeStart', function(event, toState, toParams){ + + // If there's nothing specified for auth, then we do nothing. By default + // they're always allowed to proceed to the next state. + if (toState.authenticate === undefined) { + return; + } + + // However, if authenticate **is** set then we need to ask security if + // we're verified. + security.verify() + + // If we *are* verified, *and* the state isn't allowed when you're verified, + // then we take you home. A common state to say 'no' on is the login page. + .then(function() { + if (toState.authenticate === 'no') { + $state.transitionTo('portal.home'); + event.preventDefault(); + } + }) + + // // The most common case. We're not verified and we need to be. In this situation, + // // we set the page they were trying to access in a cache, then send them to the login + // // page. Later, when they login, we'll take them back to the location they intended to go + // // to. + .catch(function() { + if (toState.authenticate === true) { + + locationCache.put('toState', toState); + locationCache.put('toParams', toParams); + + $state.transitionTo('portal.login'); + event.preventDefault(); + } + }); + }); + } + ]; +}); http://git-wip-us.apache.org/repos/asf/rave/blob/277e58a4/rave-portal-ng/src/subapps/auth/security/security.js ---------------------------------------------------------------------- diff --git a/rave-portal-ng/src/subapps/auth/security/security.js b/rave-portal-ng/src/subapps/auth/security/security.js new file mode 100644 index 0000000..84feacd --- /dev/null +++ b/rave-portal-ng/src/subapps/auth/security/security.js @@ -0,0 +1,38 @@ +/* + * security + * A module for security-related features + * + */ + +define(function(require) { + var ng = require('angular'); + + var api = require('../api/api'); + + var securityDependencies = [ + api.name + ]; + + // Create the Security module + var security = ng.module('security', securityDependencies); + + // Register our services + var authCache = require('./services/auth-cache'); + security.factory('authCache', authCache); + + var authToken = require('./services/auth-token'); + security.factory('authToken', authToken); + + var locationCache = require('./services/location-cache'); + security.factory('locationCache', locationCache); + + var securityService = require('./services/security'); + security.factory('security', securityService); + + // Configure route interception + var routeIntercept = require('./route-intercept'); + security.run(routeIntercept); + + // Return the module + return security; +}); http://git-wip-us.apache.org/repos/asf/rave/blob/277e58a4/rave-portal-ng/src/subapps/auth/security/services/auth-cache.js ---------------------------------------------------------------------- diff --git a/rave-portal-ng/src/subapps/auth/security/services/auth-cache.js b/rave-portal-ng/src/subapps/auth/security/services/auth-cache.js new file mode 100644 index 0000000..53bfa4b --- /dev/null +++ b/rave-portal-ng/src/subapps/auth/security/services/auth-cache.js @@ -0,0 +1,29 @@ + +/* + * authCache + * The auth cache stores a single value: whether our authenticity has been approved by the server + * for this session. + * + * This is important because the user must be authenticated before they can take any secure actions. + * This includes navigating to secure sections of the webapp, in addition to taking secure actions + * like deleting a resource. It goes without saying that the server verifies these actions, too, but + * we don't always want to check with our server. That'd be a waste of bandwidth and a slower user + * experience. Instead, we check with the server a single time to ensure that our token (a cookie) + * is valid. If it is, we assume it is **on the client** for the rest of the user's session. + * This way, the user gets to navigate around the app as if they were authenticated, without + * requiring server approval. But, of course, whenever they take an action (requesting or posting secure + * information) the server will once again be called in to verify their authenticity. + * + * There is NEVER a need to use this service directly. Instead, all external auth-related + * activities should go through the securityService. + * + * + */ + +define(function(require) { + return ['$cacheFactory', + function($cacheFactory) { + return $cacheFactory('auth-cache'); + } + ]; +}); http://git-wip-us.apache.org/repos/asf/rave/blob/277e58a4/rave-portal-ng/src/subapps/auth/security/services/auth-token.js ---------------------------------------------------------------------- diff --git a/rave-portal-ng/src/subapps/auth/security/services/auth-token.js b/rave-portal-ng/src/subapps/auth/security/services/auth-token.js new file mode 100644 index 0000000..f763503 --- /dev/null +++ b/rave-portal-ng/src/subapps/auth/security/services/auth-token.js @@ -0,0 +1,44 @@ +/* + * token + * Manages our authentication token, which is stored + * in a cookie. + * + */ + +define(function(require) { + // The name of our cookie + var COOKIE_NAME = 'raveToken'; + + // If they choose to be remembered, it will + // last for 20 years. + var EXPIRE_DAYS = 20 * 365; + + // Checks if we're registered or not with the API. + // It only checks on the first request to save on bandwidth. + // One day we'll make an HTTP request in here + return ['ipCookie', '$rootScope', + function(ipCookie, $rootScope) { + + return { + + // Gets your token from the cookies + get: function() { + return ipCookie(COOKIE_NAME); + }, + + // Sets the new token value, then emits an associated event + set: function(newValue, persist) { + var expireDays = persist ? EXPIRE_DAYS : undefined; + ipCookie(COOKIE_NAME, newValue, {expires: expireDays}); + $rootScope.$emit('set:' + COOKIE_NAME, newValue, persist); + }, + + // Destroys the token, then emits an associated event + destroy: function() { + ipCookie.remove(COOKIE_NAME); + $rootScope.$emit('destroy:' + COOKIE_NAME); + } + }; + } + ]; +}); http://git-wip-us.apache.org/repos/asf/rave/blob/277e58a4/rave-portal-ng/src/subapps/auth/security/services/location-cache.js ---------------------------------------------------------------------- diff --git a/rave-portal-ng/src/subapps/auth/security/services/location-cache.js b/rave-portal-ng/src/subapps/auth/security/services/location-cache.js new file mode 100644 index 0000000..180377b --- /dev/null +++ b/rave-portal-ng/src/subapps/auth/security/services/location-cache.js @@ -0,0 +1,13 @@ +/* + * locationCache + * Creates a cache for our location + * + */ + +define(function(require) { + return ['$cacheFactory', + function($cacheFactory) { + return $cacheFactory('location-cache'); + } + ]; +}); http://git-wip-us.apache.org/repos/asf/rave/blob/277e58a4/rave-portal-ng/src/subapps/auth/security/services/security.js ---------------------------------------------------------------------- diff --git a/rave-portal-ng/src/subapps/auth/security/services/security.js b/rave-portal-ng/src/subapps/auth/security/services/security.js new file mode 100644 index 0000000..4ee0591 --- /dev/null +++ b/rave-portal-ng/src/subapps/auth/security/services/security.js @@ -0,0 +1,92 @@ +/* + * securityService + * This is our single point-of-entry for authentication in our app. It exposes + * all of the methods our app needs to handle authentication. + * + * Given the nature of authentication these services are typically related to routing. + * + * It provides three services + * + * 1. Attempts to log the user in with the given credentials + * 2. Determines if our user is verified (with a cached server response) + * 3. Logs out the user + * + */ + +define(function(require) { + return ['$rootScope', 'authToken', '$q', 'authApi', 'authCache', '$state', 'locationCache', + function($rootScope, authToken, $q, authApi, authCache, $state, locationCache) { + return { + + // Returns a promise that resolves true or rejects false. + // This promise represents whether the user is currently verified. + // If the token is stored in a cookie, it checks if we've been verified + // with the server for this session. If we have, it resolves true. + // If we haven't, it checks the token with the server. If the server returns + // false, then the token is destroyed. + verify: function() { + var myToken = authToken.get(); + var response = $q.defer(); + + // If we're verified, then we can move along. + if (myToken && authCache.get('verified') === true) { + response.resolve(true); + } + + // If we have no token or aren't verified, then we reject it. + else if (myToken === null || authCache.get('verified') === false) { + response.reject(false); + } + + // Lastly, we verify with the server using our token + else { + authApi.verify(myToken) + .then(function(res) { + $rootScope.authenticated = true; + authCache.put('verified', true); + response.resolve(true); + }) + .catch(function(err) { + authToken.destroy(); + response.reject(false); + }); + } + return response.promise; + }, + + // Log us in with the credentials + // Returns the XHR result of the login attempt. + // Errors aren't handled within this method. + login: function(credentials) { + + return authApi.login(credentials) + + // On success, we do quite a few things. We set that we're + // verified on the $rootScope, we cache our verification, + // we set our token, and lastly we + .then(function(res) { + var user = res.data.user; + $rootScope.authenticated = true; + authCache.put('verified', true); + authToken.set(user.token, credentials.remember); + + var toState = locationCache.get('toState') || 'portal.home'; + var toParams = locationCache.get('toParams') || undefined; + + locationCache.removeAll(); + + $state.transitionTo(toState, toParams); + }); + }, + + // Logs us out. + logout: function() { + $rootScope.authenticated = false; + authCache.put('verified', false); + authToken.destroy(); + $state.transitionTo('portal.login'); + }, + }; + } + ]; +}); http://git-wip-us.apache.org/repos/asf/rave/blob/277e58a4/rave-portal-ng/src/subapps/auth/services/auth-api-base.js ---------------------------------------------------------------------- diff --git a/rave-portal-ng/src/subapps/auth/services/auth-api-base.js b/rave-portal-ng/src/subapps/auth/services/auth-api-base.js deleted file mode 100644 index 596ad5d..0000000 --- a/rave-portal-ng/src/subapps/auth/services/auth-api-base.js +++ /dev/null @@ -1,11 +0,0 @@ -/* - * auth-api-base - * The base route for API routes - * - */ - -define(function(require) { - var auth = require('../auth'); - - auth.value('authApiBase', 'auth/'); -}); http://git-wip-us.apache.org/repos/asf/rave/blob/277e58a4/rave-portal-ng/src/subapps/auth/services/auth-api-routes.js ---------------------------------------------------------------------- diff --git a/rave-portal-ng/src/subapps/auth/services/auth-api-routes.js b/rave-portal-ng/src/subapps/auth/services/auth-api-routes.js deleted file mode 100644 index 7cac2d5..0000000 --- a/rave-portal-ng/src/subapps/auth/services/auth-api-routes.js +++ /dev/null @@ -1,22 +0,0 @@ -/* - * auth-api-routes - * Defines our API routes in a single location. - * - */ - -define(function(require) { - var auth = require('../auth'); - require('./auth-api-base'); - - auth.factory('authApiRoutes', [ - 'apiRoute', 'authApiBase', - function(apiRoute, authApiBase) { - var base = apiRoute + authApiBase; - return { - login: base + 'login', - logout: base + 'logout', - verify: base + 'verify' - }; - } - ]); -}); http://git-wip-us.apache.org/repos/asf/rave/blob/277e58a4/rave-portal-ng/src/subapps/auth/services/auth-api.js ---------------------------------------------------------------------- diff --git a/rave-portal-ng/src/subapps/auth/services/auth-api.js b/rave-portal-ng/src/subapps/auth/services/auth-api.js deleted file mode 100644 index 118ee24..0000000 --- a/rave-portal-ng/src/subapps/auth/services/auth-api.js +++ /dev/null @@ -1,33 +0,0 @@ -/* - * api - * Exposes high-level methods for interacting with the remote API for authentication. - * All methods defer to $http and, consequently, return an HttpPromise. - * - * There is NEVER a need to use this service directly. Instead, all external auth-related - * activities should go through the securityService. - * - */ - -define(function(require) { - var auth = require('../auth'); - require('./auth-api-routes'); - - auth.factory('authApi', [ - '$http', 'authApiRoutes', - function($http, authApiRoutes) { - - // Each of our auth routes. - return { - login: function(credentials) { - return $http.post(authApiRoutes.login, credentials); - }, - logout: function() { - return $http.post(authApiRoutes.logout); - }, - verify: function(token) { - return $http.post(authApiRoutes.verify, {token: token}); - } - }; - } - ]); -}); http://git-wip-us.apache.org/repos/asf/rave/blob/277e58a4/rave-portal-ng/src/subapps/auth/services/auth-cache.js ---------------------------------------------------------------------- diff --git a/rave-portal-ng/src/subapps/auth/services/auth-cache.js b/rave-portal-ng/src/subapps/auth/services/auth-cache.js deleted file mode 100644 index d0fbc5b..0000000 --- a/rave-portal-ng/src/subapps/auth/services/auth-cache.js +++ /dev/null @@ -1,32 +0,0 @@ - -/* - * auth-cache - * The auth cache stores a single value: whether our authenticity has been approved by the server - * for this session. - * - * This is important because the user must be authenticated before they can take any secure actions. - * This includes navigating to secure sections of the webapp, in addition to taking secure actions - * like deleting a resource. It goes without saying that the server verifies these actions, too, but - * we don't always want to check with our server. That'd be a waste of bandwidth and a slower user - * experience. Instead, we check with the server a single time to ensure that our token (a cookie) - * is valid. If it is, we assume it is **on the client** for the rest of the user's session. - * This way, the user gets to navigate around the app as if they were authenticated, without - * requiring server approval. But, of course, whenever they take an action (requesting or posting secure - * information) the server will once again be called in to verify their authenticity. - * - * There is NEVER a need to use this service directly. Instead, all external auth-related - * activities should go through the securityService. - * - * - */ - -define(function(require) { - var auth = require('../auth'); - - auth.factory('authCache', [ - '$cacheFactory', - function($cacheFactory) { - return $cacheFactory('auth-cache'); - } - ]); -});
