@@ -31,34 +31,6 @@ function checkAccountExists (accountManager) {
3131 }
3232}
3333
34- /**
35- * Returns an Express middleware handler for intercepting any GET requests
36- * for first time users (in single user mode), and redirecting them to the
37- * signup page.
38- *
39- * @param accountManager {AccountManager}
40- *
41- * @return {Function }
42- */
43- function firstTimeSignupRedirect ( accountManager ) {
44- return ( req , res , next ) => {
45- // Only redirect browser (HTML) requests to first-time signup
46- if ( ! req . accepts ( 'text/html' ) ) { return next ( ) }
47-
48- accountManager . accountExists ( )
49- . then ( found => {
50- if ( ! found ) {
51- debug ( '(single user mode) Redirecting to account creation' )
52-
53- res . redirect ( 302 , '/signup.html' )
54- } else {
55- next ( )
56- }
57- } )
58- . catch ( next )
59- }
60- }
61-
6234/**
6335 * Returns an Express middleware handler for adding a new certificate to an
6436 * existing account (POST to /api/accounts/cert).
@@ -88,22 +60,7 @@ function newCertificate (accountManager) {
8860function middleware ( accountManager ) {
8961 let router = express . Router ( '/' )
9062
91- if ( accountManager . multiUser ) {
92- router . get ( '/' , checkAccountExists ( accountManager ) )
93- } else {
94- // In single user mode, if account has not yet been created, intercept
95- // all GET requests and redirect to the Signup form
96- accountManager . accountExists ( )
97- . then ( found => {
98- if ( ! found ) {
99- router . use ( '/signup.html' , express . static ( './static/signup.html' ) )
100- router . get ( '/*' , firstTimeSignupRedirect ( accountManager ) )
101- }
102- } )
103- . catch ( error => {
104- debug ( 'Error during accountExists(): ' , error )
105- } )
106- }
63+ router . get ( '/' , checkAccountExists ( accountManager ) )
10764
10865 router . post ( '/api/accounts/new' , bodyParser , CreateAccountRequest . post )
10966 router . get ( [ '/register' , '/api/accounts/new' ] , CreateAccountRequest . get )
@@ -116,6 +73,5 @@ function middleware (accountManager) {
11673module . exports = {
11774 middleware,
11875 checkAccountExists,
119- firstTimeSignupRedirect,
12076 newCertificate
12177}
0 commit comments