This commit is contained in:
darthsandmann
2016-10-16 21:53:15 +02:00
parent 0d10f8b9dc
commit c9f3117da1
412 changed files with 137942 additions and 0 deletions

View File

@ -0,0 +1,54 @@
# coding: utf-8
import json
import os
import codecs
import cherrypy
from app import database
# Method-Dispatching!
# (beachte: / relativ zu /login, siehe Konfiguration Server!)
#----------------------------------------------------------
class Login_cl(object):
#----------------------------------------------------------
exposed = True # gilt für alle Methoden
#-------------------------------------------------------
def __init__(self):
#-------------------------------------------------------
self.db_o = database.Database_cl()
#**********************REST ANSATZ**********************
#-------------------------------------------------------
def GET(self, **data_o):
#-------------------------------------------------------
authenticated = False
users = self.db_o.getUsers_px();
if data_o['username'] in users and data_o['password'] == users[data_o['username']]:
authenticated = True
return json.dumps(authenticated)
#-------------------------------------------------------
def PUT(self, **data_o):
#-------------------------------------------------------
success = False
users = self.db_o.getUsers_px();
if data_o['username'] not in users:
users[data_o['username']] = data_o['password']
self.db_o.saveUsers_px(users);
success = True
return json.dumps(success)
#*******************************************************
# EOF