Client - disable registration - fix #36
This commit is contained in:
		@@ -1,8 +1,8 @@
 | 
				
			|||||||
export REACT_APP_API_URL = http://$(HOST):$(API_PORT)
 | 
					export REACT_APP_API_URL = http://$(HOST):$(API_PORT)
 | 
				
			||||||
export REACT_APP_THUNDERFOREST_API_KEY=
 | 
					export REACT_APP_THUNDERFOREST_API_KEY=
 | 
				
			||||||
export REACT_APP_GPX_LIMIT_IMPORT=10
 | 
					export REACT_APP_GPX_LIMIT_IMPORT=10
 | 
				
			||||||
 | 
					export REACT_APP_ALLOW_REGISTRATION=true
 | 
				
			||||||
export WEATHER_API=
 | 
					export WEATHER_API=
 | 
				
			||||||
export FT_ALLOW_REGISTRATION=true
 | 
					 | 
				
			||||||
 | 
					
 | 
				
			||||||
# for dev env
 | 
					# for dev env
 | 
				
			||||||
export CODACY_PROJECT_TOKEN=
 | 
					export CODACY_PROJECT_TOKEN=
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -1,8 +1,8 @@
 | 
				
			|||||||
Features
 | 
					Features
 | 
				
			||||||
########
 | 
					########
 | 
				
			||||||
 | 
					
 | 
				
			||||||
Features list
 | 
					List
 | 
				
			||||||
~~~~~~~~~~~~~
 | 
					~~~~
 | 
				
			||||||
- Account creation (only standard user, not admin)
 | 
					- Account creation (only standard user, not admin)
 | 
				
			||||||
- 6 sports supported:
 | 
					- 6 sports supported:
 | 
				
			||||||
     - Cycling (Sport)
 | 
					     - Cycling (Sport)
 | 
				
			||||||
@@ -22,6 +22,7 @@ Features list
 | 
				
			|||||||
    - longest duration
 | 
					    - longest duration
 | 
				
			||||||
    - maximum speed
 | 
					    - maximum speed
 | 
				
			||||||
- Activities list and filter
 | 
					- Activities list and filter
 | 
				
			||||||
 | 
					- User registration can be disabled.
 | 
				
			||||||
 | 
					
 | 
				
			||||||
**Notes:**
 | 
					**Notes:**
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -46,7 +46,8 @@ Dev environment
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
-  Update **Makefile.config** file if needed and copy/paste the
 | 
					-  Update **Makefile.config** file if needed and copy/paste the
 | 
				
			||||||
   **ThunderForest** and **Dark Sky** API keys value in
 | 
					   **ThunderForest** and **Dark Sky** API keys value in
 | 
				
			||||||
   **Makefile.custom.config** file (see example)
 | 
					   **Makefile.custom.config** file (see example). User registration can
 | 
				
			||||||
 | 
					   also be disabled in **Makefile.custom.config**.
 | 
				
			||||||
 | 
					
 | 
				
			||||||
-  Install Python virtualenv, React and all related packages and
 | 
					-  Install Python virtualenv, React and all related packages and
 | 
				
			||||||
   initialize the database:
 | 
					   initialize the database:
 | 
				
			||||||
@@ -82,7 +83,8 @@ Prod environment
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
-  Update **Makefile.config** file if needed and copy/paste the
 | 
					-  Update **Makefile.config** file if needed and copy/paste the
 | 
				
			||||||
   **ThunderForest** and **Dark Sky** API keys value in
 | 
					   **ThunderForest** and **Dark Sky** API keys value in
 | 
				
			||||||
   **Makefile.custom.config** file (see example)
 | 
					   **Makefile.custom.config** file (see example). User registration can
 | 
				
			||||||
 | 
					   also be disabled in **Makefile.custom.config**.
 | 
				
			||||||
 | 
					
 | 
				
			||||||
-  Install Python virtualenv, React and all related packages and
 | 
					-  Install Python virtualenv, React and all related packages and
 | 
				
			||||||
   initialize the database:
 | 
					   initialize the database:
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -75,7 +75,7 @@
 | 
				
			|||||||
      role="menu"
 | 
					      role="menu"
 | 
				
			||||||
      aria-labelledby="dLabelLocalToc"><ul>
 | 
					      aria-labelledby="dLabelLocalToc"><ul>
 | 
				
			||||||
<li><a class="reference internal" href="#">Features</a><ul>
 | 
					<li><a class="reference internal" href="#">Features</a><ul>
 | 
				
			||||||
<li><a class="reference internal" href="#features-list">Features list</a></li>
 | 
					<li><a class="reference internal" href="#list">List</a></li>
 | 
				
			||||||
<li><a class="reference internal" href="#dashboard">Dashboard</a></li>
 | 
					<li><a class="reference internal" href="#dashboard">Dashboard</a></li>
 | 
				
			||||||
<li><a class="reference internal" href="#activity-workout-detail">Activity/workout detail</a></li>
 | 
					<li><a class="reference internal" href="#activity-workout-detail">Activity/workout detail</a></li>
 | 
				
			||||||
<li><a class="reference internal" href="#activities-workouts-list">Activities/workouts list</a></li>
 | 
					<li><a class="reference internal" href="#activities-workouts-list">Activities/workouts list</a></li>
 | 
				
			||||||
@@ -131,8 +131,8 @@
 | 
				
			|||||||
      
 | 
					      
 | 
				
			||||||
  <div class="section" id="features">
 | 
					  <div class="section" id="features">
 | 
				
			||||||
<h1>Features<a class="headerlink" href="#features" title="Permalink to this headline">¶</a></h1>
 | 
					<h1>Features<a class="headerlink" href="#features" title="Permalink to this headline">¶</a></h1>
 | 
				
			||||||
<div class="section" id="features-list">
 | 
					<div class="section" id="list">
 | 
				
			||||||
<h2>Features list<a class="headerlink" href="#features-list" title="Permalink to this headline">¶</a></h2>
 | 
					<h2>List<a class="headerlink" href="#list" title="Permalink to this headline">¶</a></h2>
 | 
				
			||||||
<ul class="simple">
 | 
					<ul class="simple">
 | 
				
			||||||
<li><p>Account creation (only standard user, not admin)</p></li>
 | 
					<li><p>Account creation (only standard user, not admin)</p></li>
 | 
				
			||||||
<li><dl class="simple">
 | 
					<li><dl class="simple">
 | 
				
			||||||
@@ -163,6 +163,7 @@
 | 
				
			|||||||
</dl>
 | 
					</dl>
 | 
				
			||||||
</li>
 | 
					</li>
 | 
				
			||||||
<li><p>Activities list and filter</p></li>
 | 
					<li><p>Activities list and filter</p></li>
 | 
				
			||||||
 | 
					<li><p>User registration can be disabled.</p></li>
 | 
				
			||||||
</ul>
 | 
					</ul>
 | 
				
			||||||
<p><strong>Notes:</strong></p>
 | 
					<p><strong>Notes:</strong></p>
 | 
				
			||||||
<ul class="simple">
 | 
					<ul class="simple">
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -160,7 +160,7 @@ Map</a>.</div>
 | 
				
			|||||||
</ul>
 | 
					</ul>
 | 
				
			||||||
</li>
 | 
					</li>
 | 
				
			||||||
<li class="toctree-l1"><a class="reference internal" href="features.html">Features</a><ul>
 | 
					<li class="toctree-l1"><a class="reference internal" href="features.html">Features</a><ul>
 | 
				
			||||||
<li class="toctree-l2"><a class="reference internal" href="features.html#features-list">Features list</a></li>
 | 
					<li class="toctree-l2"><a class="reference internal" href="features.html#list">List</a></li>
 | 
				
			||||||
<li class="toctree-l2"><a class="reference internal" href="features.html#dashboard">Dashboard</a></li>
 | 
					<li class="toctree-l2"><a class="reference internal" href="features.html#dashboard">Dashboard</a></li>
 | 
				
			||||||
<li class="toctree-l2"><a class="reference internal" href="features.html#activity-workout-detail">Activity/workout detail</a></li>
 | 
					<li class="toctree-l2"><a class="reference internal" href="features.html#activity-workout-detail">Activity/workout detail</a></li>
 | 
				
			||||||
<li class="toctree-l2"><a class="reference internal" href="features.html#activities-workouts-list">Activities/workouts list</a></li>
 | 
					<li class="toctree-l2"><a class="reference internal" href="features.html#activities-workouts-list">Activities/workouts list</a></li>
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -191,7 +191,8 @@ $ <span class="nb">cd</span> FitTrackee
 | 
				
			|||||||
<ul class="simple">
 | 
					<ul class="simple">
 | 
				
			||||||
<li><p>Update <strong>Makefile.config</strong> file if needed and copy/paste the
 | 
					<li><p>Update <strong>Makefile.config</strong> file if needed and copy/paste the
 | 
				
			||||||
<strong>ThunderForest</strong> and <strong>Dark Sky</strong> API keys value in
 | 
					<strong>ThunderForest</strong> and <strong>Dark Sky</strong> API keys value in
 | 
				
			||||||
<strong>Makefile.custom.config</strong> file (see example)</p></li>
 | 
					<strong>Makefile.custom.config</strong> file (see example). User registration can
 | 
				
			||||||
 | 
					also be disabled in <strong>Makefile.custom.config</strong>.</p></li>
 | 
				
			||||||
<li><p>Install Python virtualenv, React and all related packages and
 | 
					<li><p>Install Python virtualenv, React and all related packages and
 | 
				
			||||||
initialize the database:</p></li>
 | 
					initialize the database:</p></li>
 | 
				
			||||||
</ul>
 | 
					</ul>
 | 
				
			||||||
@@ -226,7 +227,8 @@ $ <span class="nb">cd</span> FitTrackee
 | 
				
			|||||||
<ul class="simple">
 | 
					<ul class="simple">
 | 
				
			||||||
<li><p>Update <strong>Makefile.config</strong> file if needed and copy/paste the
 | 
					<li><p>Update <strong>Makefile.config</strong> file if needed and copy/paste the
 | 
				
			||||||
<strong>ThunderForest</strong> and <strong>Dark Sky</strong> API keys value in
 | 
					<strong>ThunderForest</strong> and <strong>Dark Sky</strong> API keys value in
 | 
				
			||||||
<strong>Makefile.custom.config</strong> file (see example)</p></li>
 | 
					<strong>Makefile.custom.config</strong> file (see example). User registration can
 | 
				
			||||||
 | 
					also be disabled in <strong>Makefile.custom.config</strong>.</p></li>
 | 
				
			||||||
<li><p>Install Python virtualenv, React and all related packages and
 | 
					<li><p>Install Python virtualenv, React and all related packages and
 | 
				
			||||||
initialize the database:</p></li>
 | 
					initialize the database:</p></li>
 | 
				
			||||||
</ul>
 | 
					</ul>
 | 
				
			||||||
 
 | 
				
			|||||||
										
											
												File diff suppressed because one or more lines are too long
											
										
									
								
							@@ -1,8 +1,8 @@
 | 
				
			|||||||
Features
 | 
					Features
 | 
				
			||||||
########
 | 
					########
 | 
				
			||||||
 | 
					
 | 
				
			||||||
Features list
 | 
					List
 | 
				
			||||||
~~~~~~~~~~~~~
 | 
					~~~~
 | 
				
			||||||
- Account creation (only standard user, not admin)
 | 
					- Account creation (only standard user, not admin)
 | 
				
			||||||
- 6 sports supported:
 | 
					- 6 sports supported:
 | 
				
			||||||
     - Cycling (Sport)
 | 
					     - Cycling (Sport)
 | 
				
			||||||
@@ -22,6 +22,7 @@ Features list
 | 
				
			|||||||
    - longest duration
 | 
					    - longest duration
 | 
				
			||||||
    - maximum speed
 | 
					    - maximum speed
 | 
				
			||||||
- Activities list and filter
 | 
					- Activities list and filter
 | 
				
			||||||
 | 
					- User registration can be disabled.
 | 
				
			||||||
 | 
					
 | 
				
			||||||
**Notes:**
 | 
					**Notes:**
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -46,7 +46,8 @@ Dev environment
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
-  Update **Makefile.config** file if needed and copy/paste the
 | 
					-  Update **Makefile.config** file if needed and copy/paste the
 | 
				
			||||||
   **ThunderForest** and **Dark Sky** API keys value in
 | 
					   **ThunderForest** and **Dark Sky** API keys value in
 | 
				
			||||||
   **Makefile.custom.config** file (see example)
 | 
					   **Makefile.custom.config** file (see example). User registration can
 | 
				
			||||||
 | 
					   also be disabled in **Makefile.custom.config**.
 | 
				
			||||||
 | 
					
 | 
				
			||||||
-  Install Python virtualenv, React and all related packages and
 | 
					-  Install Python virtualenv, React and all related packages and
 | 
				
			||||||
   initialize the database:
 | 
					   initialize the database:
 | 
				
			||||||
@@ -82,7 +83,8 @@ Prod environment
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
-  Update **Makefile.config** file if needed and copy/paste the
 | 
					-  Update **Makefile.config** file if needed and copy/paste the
 | 
				
			||||||
   **ThunderForest** and **Dark Sky** API keys value in
 | 
					   **ThunderForest** and **Dark Sky** API keys value in
 | 
				
			||||||
   **Makefile.custom.config** file (see example)
 | 
					   **Makefile.custom.config** file (see example). User registration can
 | 
				
			||||||
 | 
					   also be disabled in **Makefile.custom.config**.
 | 
				
			||||||
 | 
					
 | 
				
			||||||
-  Install Python virtualenv, React and all related packages and
 | 
					-  Install Python virtualenv, React and all related packages and
 | 
				
			||||||
   initialize the database:
 | 
					   initialize the database:
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -17,7 +17,7 @@ class BaseConfig:
 | 
				
			|||||||
    PICTURE_ALLOWED_EXTENSIONS = {'jpg', 'png', 'gif'}
 | 
					    PICTURE_ALLOWED_EXTENSIONS = {'jpg', 'png', 'gif'}
 | 
				
			||||||
    ACTIVITY_ALLOWED_EXTENSIONS = {'gpx', 'zip'}
 | 
					    ACTIVITY_ALLOWED_EXTENSIONS = {'gpx', 'zip'}
 | 
				
			||||||
    REGISTRATION_ALLOWED = (
 | 
					    REGISTRATION_ALLOWED = (
 | 
				
			||||||
        False if os.getenv('FT_ALLOW_REGISTRATION') == "false" else True
 | 
					        False if os.getenv('REACT_APP_ALLOW_REGISTRATION') == "false" else True
 | 
				
			||||||
    )
 | 
					    )
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -13,6 +13,7 @@ os.environ["APP_SETTINGS"] = 'fittrackee_api.config.TestingConfig'
 | 
				
			|||||||
@pytest.fixture
 | 
					@pytest.fixture
 | 
				
			||||||
def app():
 | 
					def app():
 | 
				
			||||||
    app = create_app()
 | 
					    app = create_app()
 | 
				
			||||||
 | 
					    app.config['REGISTRATION_ALLOWED'] = True
 | 
				
			||||||
    with app.app_context():
 | 
					    with app.app_context():
 | 
				
			||||||
        db.create_all()
 | 
					        db.create_all()
 | 
				
			||||||
        yield app
 | 
					        yield app
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -1,6 +1,9 @@
 | 
				
			|||||||
import React from 'react'
 | 
					import React from 'react'
 | 
				
			||||||
import { Helmet } from 'react-helmet'
 | 
					import { Helmet } from 'react-helmet'
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					import { history } from '../../index'
 | 
				
			||||||
 | 
					import { isRegistrationAllowed } from '../../utils'
 | 
				
			||||||
 | 
					
 | 
				
			||||||
export default function Form (props) {
 | 
					export default function Form (props) {
 | 
				
			||||||
  return (
 | 
					  return (
 | 
				
			||||||
    <div>
 | 
					    <div>
 | 
				
			||||||
@@ -15,6 +18,19 @@ export default function Form (props) {
 | 
				
			|||||||
          <div className="col-md-3" />
 | 
					          <div className="col-md-3" />
 | 
				
			||||||
          <div className="col-md-6">
 | 
					          <div className="col-md-6">
 | 
				
			||||||
            <hr /><br />
 | 
					            <hr /><br />
 | 
				
			||||||
 | 
					            {props.formType === 'register' && !isRegistrationAllowed ? (
 | 
				
			||||||
 | 
					              <div className="card">
 | 
				
			||||||
 | 
					                <div className="card-body">Registration is disabled.</div>
 | 
				
			||||||
 | 
					                <div className="card-body">
 | 
				
			||||||
 | 
					                  <button
 | 
				
			||||||
 | 
					                    type="submit"
 | 
				
			||||||
 | 
					                    className="btn btn-secondary btn-lg btn-block"
 | 
				
			||||||
 | 
					                    onClick={() => history.go(-1)}
 | 
				
			||||||
 | 
					                  >Back
 | 
				
			||||||
 | 
					                  </button>
 | 
				
			||||||
 | 
					                </div>
 | 
				
			||||||
 | 
					              </div>
 | 
				
			||||||
 | 
					            ) : (
 | 
				
			||||||
              <form onSubmit={event =>
 | 
					              <form onSubmit={event =>
 | 
				
			||||||
                props.handleUserFormSubmit(event, props.formType)}
 | 
					                props.handleUserFormSubmit(event, props.formType)}
 | 
				
			||||||
              >
 | 
					              >
 | 
				
			||||||
@@ -72,6 +88,7 @@ export default function Form (props) {
 | 
				
			|||||||
                  value="Submit"
 | 
					                  value="Submit"
 | 
				
			||||||
                />
 | 
					                />
 | 
				
			||||||
              </form>
 | 
					              </form>
 | 
				
			||||||
 | 
					            )}
 | 
				
			||||||
          </div>
 | 
					          </div>
 | 
				
			||||||
          <div className="col-md-3" />
 | 
					          <div className="col-md-3" />
 | 
				
			||||||
        </div>
 | 
					        </div>
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -7,6 +7,8 @@ export const thunderforestApiKey = `${
 | 
				
			|||||||
  process.env.REACT_APP_THUNDERFOREST_API_KEY
 | 
					  process.env.REACT_APP_THUNDERFOREST_API_KEY
 | 
				
			||||||
  }`
 | 
					  }`
 | 
				
			||||||
export const gpxLimit = `${process.env.REACT_APP_GPX_LIMIT_IMPORT}`
 | 
					export const gpxLimit = `${process.env.REACT_APP_GPX_LIMIT_IMPORT}`
 | 
				
			||||||
 | 
					export const isRegistrationAllowed =
 | 
				
			||||||
 | 
					  process.env.REACT_APP_ALLOW_REGISTRATION !== 'false'
 | 
				
			||||||
 | 
					
 | 
				
			||||||
export const isLoggedIn = () => !!window.localStorage.authToken
 | 
					export const isLoggedIn = () => !!window.localStorage.authToken
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -1,2 +1,4 @@
 | 
				
			|||||||
[pytest]
 | 
					[pytest]
 | 
				
			||||||
norecursedirs = fittrackee_api/.venv
 | 
					norecursedirs = fittrackee_api/.venv
 | 
				
			||||||
 | 
					filterwarnings =
 | 
				
			||||||
 | 
					  ignore::DeprecationWarning
 | 
				
			||||||
 
 | 
				
			|||||||
		Reference in New Issue
	
	Block a user