File tree Expand file tree Collapse file tree 7 files changed +20
-3
lines changed
Expand file tree Collapse file tree 7 files changed +20
-3
lines changed Original file line number Diff line number Diff line change @@ -5,6 +5,9 @@ const modal = require('./modal');
55const intro = require ( './intro' ) ;
66
77module . exports = function ( state , emit ) {
8+ if ( state . user . loginRequired && ! state . user . loggedIn ) {
9+ emit ( 'signup-cta' , 'required' ) ;
10+ }
811 const archives = state . storage . files
912 . filter ( archive => ! archive . expired )
1013 . map ( archive => archiveTile ( state , emit , archive ) ) ;
Original file line number Diff line number Diff line change @@ -94,6 +94,10 @@ export default class User {
9494 : this . limits . ANON . MAX_DOWNLOADS ;
9595 }
9696
97+ get loginRequired ( ) {
98+ return this . authConfig . fxa_required ;
99+ }
100+
97101 async metricId ( ) {
98102 return this . loggedIn ? hashId ( this . info . uid ) : undefined ;
99103 }
Original file line number Diff line number Diff line change 2323 "release" : " npm-run-all contributors changelog" ,
2424 "test" : " npm-run-all test:*" ,
2525 "test:backend" : " nyc --reporter=lcovonly mocha --reporter=min test/backend" ,
26- "test:frontend" : " cross-env NODE_ENV=development node test/frontend/runner.js" ,
26+ "test:frontend" : " cross-env NODE_ENV=development FXA_REQUIRED=false node test/frontend/runner.js" ,
2727 "test:report" : " nyc report --reporter=html" ,
2828 "test-integration" : " cross-env NODE_ENV=development wdio test/wdio.docker.conf.js" ,
2929 "circleci-test-integration" : " echo 'webdriverio tests need to be updated to node 12'" ,
Original file line number Diff line number Diff line change @@ -155,6 +155,11 @@ const conf = convict({
155155 default : `${ tmpdir ( ) } ${ path . sep } send-${ randomBytes ( 4 ) . toString ( 'hex' ) } ` ,
156156 env : 'FILE_DIR'
157157 } ,
158+ fxa_required : {
159+ format : Boolean ,
160+ default : true ,
161+ env : 'FXA_REQUIRED'
162+ } ,
158163 fxa_url : {
159164 format : 'url' ,
160165 default : 'http://localhost:3030' ,
Original file line number Diff line number Diff line change @@ -117,7 +117,7 @@ module.exports = function(app) {
117117 app . get ( `/api/metadata/:id${ ID_REGEX } ` , auth . hmac , require ( './metadata' ) ) ;
118118 app . get ( '/api/filelist/:id([\\w-]{16})' , auth . fxa , filelist . get ) ;
119119 app . post ( '/api/filelist/:id([\\w-]{16})' , auth . fxa , filelist . post ) ;
120- app . post ( '/api/upload' , auth . fxa , require ( './upload' ) ) ;
120+ // app.post('/api/upload', auth.fxa, require('./upload'));
121121 app . post ( `/api/delete/:id${ ID_REGEX } ` , auth . owner , require ( './delete' ) ) ;
122122 app . post ( `/api/password/:id${ ID_REGEX } ` , auth . owner , require ( './password' ) ) ;
123123 app . post (
Original file line number Diff line number Diff line change @@ -46,7 +46,8 @@ module.exports = function(ws, req) {
4646 ! auth ||
4747 timeLimit <= 0 ||
4848 timeLimit > maxExpireSeconds ||
49- dlimit > maxDownloads
49+ dlimit > maxDownloads ||
50+ ( config . fxa_required && ! user )
5051 ) {
5152 ws . send (
5253 JSON . stringify ( {
Original file line number Diff line number Diff line change @@ -15,7 +15,11 @@ module.exports = async function(req) {
1515 try {
1616 authConfig = await getFxaConfig ( ) ;
1717 authConfig . client_id = config . fxa_client_id ;
18+ authConfig . fxa_required = config . fxa_required ;
1819 } catch ( e ) {
20+ if ( config . auth_required ) {
21+ throw new Error ( 'fxa_required is set but no config was found' ) ;
22+ }
1923 // continue without accounts
2024 }
2125 }
You can’t perform that action at this time.
0 commit comments