1
0
mirror of https://github.com/spl0k/supysonic.git synced 2024-12-22 17:06:17 +00:00

Removed the ability to create the first user (admin) through the web interface

This commit is contained in:
spl0k 2013-09-23 11:46:06 +02:00
parent 9884fc10ea
commit 3ecd787895
3 changed files with 10 additions and 16 deletions

View File

@ -86,11 +86,13 @@ With that kind of configuration, the server address will look like *http://serve
Quickstart Quickstart
---------- ----------
The first time you run the server, open its URL to set the initial configuration. You'll be asked to create To start using Supysonic, you'll first have to specify where your music library is located and create a user
a first user. This user will be an admin of the server. to allow calls to the API.
Once the first user created, log in to the app. Then you can add other users or manage folders. Folders are Let's start by creating the user. To do so, use the
where your music is located. Add one, then hit the scan button. The scanning process might take some time on [command-line interface](https://github.com/spl0k/supysonic/wiki/Command-Line-Interface) (`cli.py`).
large libraries, so be patient. Your browser might even timeout even if the process is still running. Once For the folder(s) (music library) you can either use the CLI, or go to the web interface if you gave admin
scanning is done, you can enjoy your music with the client of your choice. rights to the user. Once the folder is created, don't forget to scan it to build the music database (it might
take a while depending on your library size, so be patient). Once scanning is done, you can enjoy your music
with the client of your choice.

View File

@ -14,9 +14,6 @@ def check_admin():
if not request.path.startswith('/user'): if not request.path.startswith('/user'):
return return
if request.endpoint == 'add_user' and User.query.filter(User.admin == True).count() == 0:
return
if request.endpoint in ('user_index', 'add_user', 'del_user', 'export_users', 'import_users', 'do_user_import') and not UserManager.get(session.get('userid'))[1].admin: if request.endpoint in ('user_index', 'add_user', 'del_user', 'export_users', 'import_users', 'do_user_import') and not UserManager.get(session.get('userid'))[1].admin:
return redirect(url_for('index')) return redirect(url_for('index'))

9
web.py
View File

@ -17,16 +17,11 @@ import db
from managers.user import UserManager from managers.user import UserManager
@app.before_request @app.before_request
def init_and_login_check(): def login_check():
if request.path.startswith('/rest/'): if request.path.startswith('/rest/'):
return return
admin_count = db.User.query.filter(db.User.admin == True).count() if request.endpoint != 'login':
if admin_count == 0 and request.endpoint != 'add_user':
flash('Not configured. Please create the first admin user')
return redirect(url_for('add_user'))
if not (admin_count == 0 and request.endpoint == 'add_user') and request.endpoint != 'login':
should_login = False should_login = False
if not session.get('userid'): if not session.get('userid'):
should_login = True should_login = True