mirror of
https://gitlab2.federez.net/re2o/re2o
synced 2024-11-09 03:16:25 +00:00
59 lines
2 KiB
Python
59 lines
2 KiB
Python
# Re2o est un logiciel d'administration développé initiallement au rezometz. Il
|
|
# se veut agnostique au réseau considéré, de manière à être installable en
|
|
# quelques clics.
|
|
#
|
|
# Copyright © 2017 Gabriel Détraz
|
|
# Copyright © 2017 Goulven Kermarec
|
|
# Copyright © 2017 Augustin Lemesle
|
|
#
|
|
# This program is free software; you can redistribute it and/or modify
|
|
# it under the terms of the GNU General Public License as published by
|
|
# the Free Software Foundation; either version 2 of the License, or
|
|
# (at your option) any later version.
|
|
#
|
|
# This program is distributed in the hope that it will be useful,
|
|
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
# GNU General Public License for more details.
|
|
#
|
|
# You should have received a copy of the GNU General Public License along
|
|
# with this program; if not, write to the Free Software Foundation, Inc.,
|
|
# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
|
|
|
|
import os, sys
|
|
|
|
proj_path = "/var/www/re2o/"
|
|
# This is so Django knows where to find stuff.
|
|
os.environ.setdefault("DJANGO_SETTINGS_MODULE", "re2o.settings")
|
|
sys.path.append(proj_path)
|
|
|
|
# This is so my local_settings.py gets loaded.
|
|
os.chdir(proj_path)
|
|
|
|
# This is so models get loaded.
|
|
from django.core.wsgi import get_wsgi_application
|
|
application = get_wsgi_application()
|
|
|
|
import argparse
|
|
|
|
from django.contrib.auth import authenticate
|
|
from users.models import User
|
|
|
|
|
|
def authorize_user(user, password):
|
|
user = authenticate(username=user, password=password)
|
|
if user:
|
|
if User.objects.get(pseudo=user):
|
|
return "TRUE"
|
|
else:
|
|
return "FALSE"
|
|
else:
|
|
return "FALSE"
|
|
|
|
if __name__ == '__main__':
|
|
parser = argparse.ArgumentParser(description='Authorize user')
|
|
parser.add_argument('user', action="store")
|
|
parser.add_argument('password', action="store")
|
|
args = parser.parse_args()
|
|
print(authorize_user(args.user, args.password))
|
|
|