Commit 570f2b16 authored by Sean Hammond's avatar Sean Hammond

Merge pull request #2582 from hypothesis/replace-accounts-forms

Server-rendered accounts forms
parents c36acd9d 8a46ae38
......@@ -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', [
])
.controller('AppController', require('./app-controller'))
.controller('AccountController', require('./account-controller'))
.controller('AnnotationUIController', require('./annotation-ui-controller'))
.controller('AnnotationViewerController', require('./annotation-viewer-controller'))
.controller('AuthController', require('./auth-controller'))
.controller('StreamController', require('./stream-controller'))
.controller('WidgetController', require('./widget-controller'))
......
......@@ -7,19 +7,6 @@ function AuthController($scope, $timeout, flash, session, formRespond) {
$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);
if ($scope.form != null) {
......@@ -78,12 +65,6 @@ function AuthController($scope, $timeout, flash, session, formRespond) {
});
};
if ($scope.account == null) {
$scope.account = {
tab: 'login'
};
}
if ($scope.model == null) {
$scope.model = {};
}
......@@ -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
var ACCOUNT_ACTIONS = [
['login', 'POST'],
['logout', 'POST'],
['register', 'POST'],
['forgot_password', 'POST'],
['reset_password', 'POST'],
['profile', 'GET'],
['edit_profile', 'POST'],
['disable_user', 'POST']
......
......@@ -15,7 +15,7 @@ describe 'h:AccountController', ->
before ->
angular.module('h', [])
require('../account-controller')
.controller('AccountController', require('../account-controller'))
beforeEach module('h')
......@@ -241,7 +241,7 @@ describe "h:AccountController", ->
# The h module hasn't been defined yet, so we need to define it
# (this happens when it.only() is used in this describe()).
angular.module("h", [])
require("../account-controller")
.controller('AccountController', require('../account-controller'))
)
beforeEach module('h')
......@@ -379,7 +379,7 @@ describe "h:AccountController", ->
}
{$scope} = createAccountController(
formRespond: require("../../form-respond")()
formRespond: require("../form-respond")()
session: getStubSession(
edit_profile: -> {$promise: Promise.reject(server_response)}
)
......@@ -451,7 +451,7 @@ describe "h:AccountController", ->
}
{$scope} = createAccountController(
formRespond: require("../../form-respond")()
formRespond: require("../form-respond")()
session: getStubSession(
edit_profile: -> {$promise: Promise.reject(server_response)}
)
......
......@@ -27,7 +27,7 @@ describe 'h:AuthController', ->
before ->
angular.module('h', [])
require('../auth-controller')
.controller('AuthController', require('../auth-controller'))
beforeEach module('h')
beforeEach module('h.templates')
......
......@@ -125,6 +125,13 @@ html {
.form-inline .control-group { margin-bottom: 0; }
.form-vertical {
legend {
font-size: $body1-font-size;
line-height: $body1-line-height;
margin-top: 1.5em;
margin-bottom: 1.5em;
}
select, textarea, input, button {
display: block;
// margin-top: .75em;
......
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