Commit 943ad869 authored by Nick Stenning's avatar Nick Stenning

Remove client-side auth/registration form code

This commit removes all of the client-side code for handling the
following forms:

- registration
- forgot password
- reset password

The login form remains, as it is of course very convenient to be able to
log into Hypothesis from the sidebar.
parent ebd343dc
...@@ -144,4 +144,4 @@ function AccountController($scope, $filter, auth, flash, formRespond, identity, ...@@ -144,4 +144,4 @@ function AccountController($scope, $filter, auth, flash, formRespond, identity,
}; };
} }
angular.module('h').controller('AccountController', AccountController); module.exports = AccountController;
var angular = require('angular');
// @ngInject
function AuthAppController($location, $scope, $timeout, $window, session) {
function onlogin() {
window.location.href = '/stream';
};
$scope.account = {};
$scope.model = {};
$scope.account.tab = $location.path().split('/')[1];
$scope.$on('auth', function(event, err, data) {
if (data != null ? data.userid : void 0) {
$timeout(onlogin, 1000);
}
});
$scope.$watch('account.tab', function(tab, old) {
if (tab !== old) {
$location.path('/' + tab);
}
});
// TODO: We should be calling identity.beginProvisioning() here in order to
// move toward become a federated BrowserID provider.
session.load(function(data) {
if (data.userid) {
onlogin();
}
});
}
// @ngInject
function AuthPageController($routeParams, $scope) {
$scope.model.code = $routeParams.code;
$scope.hasActivationCode = !!$routeParams.code;
}
// @ngInject
function configure($httpProvider, $locationProvider, $routeProvider) {
// Use the Pyramid XSRF header name
$httpProvider.defaults.xsrfHeaderName = 'X-CSRF-Token';
$locationProvider.html5Mode(true);
$routeProvider.when('/login', {
controller: 'AuthPageController',
templateUrl: 'auth.html'
});
$routeProvider.when('/register', {
controller: 'AuthPageController',
templateUrl: 'auth.html'
});
$routeProvider.when('/forgot_password', {
controller: 'AuthPageController',
templateUrl: 'auth.html'
});
$routeProvider.when('/reset_password/:code?', {
controller: 'AuthPageController',
templateUrl: 'auth.html'
});
}
angular.module('h')
.config(configure)
.controller('AuthAppController', AuthAppController)
.controller('AuthPageController', AuthPageController);
require('./account-controller');
require('./auth-controller');
...@@ -98,8 +98,10 @@ module.exports = angular.module('h', [ ...@@ -98,8 +98,10 @@ module.exports = angular.module('h', [
]) ])
.controller('AppController', require('./app-controller')) .controller('AppController', require('./app-controller'))
.controller('AccountController', require('./account-controller'))
.controller('AnnotationUIController', require('./annotation-ui-controller')) .controller('AnnotationUIController', require('./annotation-ui-controller'))
.controller('AnnotationViewerController', require('./annotation-viewer-controller')) .controller('AnnotationViewerController', require('./annotation-viewer-controller'))
.controller('AuthController', require('./auth-controller'))
.controller('StreamController', require('./stream-controller')) .controller('StreamController', require('./stream-controller'))
.controller('WidgetController', require('./widget-controller')) .controller('WidgetController', require('./widget-controller'))
......
...@@ -7,19 +7,6 @@ function AuthController($scope, $timeout, flash, session, formRespond) { ...@@ -7,19 +7,6 @@ function AuthController($scope, $timeout, flash, session, formRespond) {
$scope.$emit('auth', null, data); $scope.$emit('auth', null, data);
} }
$scope.account.tab = (function() {
switch ($scope.account.tab) {
case 'register':
return 'login';
case 'forgot_password':
return 'reset_password';
case 'reset_password':
return 'login';
default:
return $scope.account.tab;
}
})();
angular.copy({}, $scope.model); angular.copy({}, $scope.model);
if ($scope.form != null) { if ($scope.form != null) {
...@@ -78,12 +65,6 @@ function AuthController($scope, $timeout, flash, session, formRespond) { ...@@ -78,12 +65,6 @@ function AuthController($scope, $timeout, flash, session, formRespond) {
}); });
}; };
if ($scope.account == null) {
$scope.account = {
tab: 'login'
};
}
if ($scope.model == null) { if ($scope.model == null) {
$scope.model = {}; $scope.model = {};
} }
...@@ -106,4 +87,4 @@ function AuthController($scope, $timeout, flash, session, formRespond) { ...@@ -106,4 +87,4 @@ function AuthController($scope, $timeout, flash, session, formRespond) {
}); });
} }
angular.module('h').controller('AuthController', AuthController); module.exports = AuthController;
...@@ -8,9 +8,6 @@ var CACHE_TTL = 5 * 60 * 1000; // 5 minutes ...@@ -8,9 +8,6 @@ var CACHE_TTL = 5 * 60 * 1000; // 5 minutes
var ACCOUNT_ACTIONS = [ var ACCOUNT_ACTIONS = [
['login', 'POST'], ['login', 'POST'],
['logout', 'POST'], ['logout', 'POST'],
['register', 'POST'],
['forgot_password', 'POST'],
['reset_password', 'POST'],
['profile', 'GET'], ['profile', 'GET'],
['edit_profile', 'POST'], ['edit_profile', 'POST'],
['disable_user', 'POST'] ['disable_user', 'POST']
......
...@@ -15,7 +15,7 @@ describe 'h:AccountController', -> ...@@ -15,7 +15,7 @@ describe 'h:AccountController', ->
before -> before ->
angular.module('h', []) angular.module('h', [])
require('../account-controller') .controller('AccountController', require('../account-controller'))
beforeEach module('h') beforeEach module('h')
...@@ -241,7 +241,7 @@ describe "h:AccountController", -> ...@@ -241,7 +241,7 @@ describe "h:AccountController", ->
# The h module hasn't been defined yet, so we need to define it # The h module hasn't been defined yet, so we need to define it
# (this happens when it.only() is used in this describe()). # (this happens when it.only() is used in this describe()).
angular.module("h", []) angular.module("h", [])
require("../account-controller") .controller('AccountController', require('../account-controller'))
) )
beforeEach module('h') beforeEach module('h')
...@@ -379,7 +379,7 @@ describe "h:AccountController", -> ...@@ -379,7 +379,7 @@ describe "h:AccountController", ->
} }
{$scope} = createAccountController( {$scope} = createAccountController(
formRespond: require("../../form-respond")() formRespond: require("../form-respond")()
session: getStubSession( session: getStubSession(
edit_profile: -> {$promise: Promise.reject(server_response)} edit_profile: -> {$promise: Promise.reject(server_response)}
) )
...@@ -451,7 +451,7 @@ describe "h:AccountController", -> ...@@ -451,7 +451,7 @@ describe "h:AccountController", ->
} }
{$scope} = createAccountController( {$scope} = createAccountController(
formRespond: require("../../form-respond")() formRespond: require("../form-respond")()
session: getStubSession( session: getStubSession(
edit_profile: -> {$promise: Promise.reject(server_response)} edit_profile: -> {$promise: Promise.reject(server_response)}
) )
......
...@@ -27,7 +27,7 @@ describe 'h:AuthController', -> ...@@ -27,7 +27,7 @@ describe 'h:AuthController', ->
before -> before ->
angular.module('h', []) angular.module('h', [])
require('../auth-controller') .controller('AuthController', require('../auth-controller'))
beforeEach module('h') beforeEach module('h')
beforeEach module('h.templates') beforeEach module('h.templates')
......
This diff is collapsed.
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment