예제 #1
0
 def getUserById(self, person_id):
     cursor = self.connection.cursor()
     cursor.execute("SELECT * FROM person WHERE person_id=%s", [person_id])
     row = cursor.fetchall()
     user = Person()
     user.set_fields(row[0][0], row[0][1], row[0][2], row[0][3], row[0][4],
                     row[0][5])
     user.set_password_hash(row[0][6])
     return user
예제 #2
0
 def getUserByLogin(self, login):
     cursor = self.connection.cursor()
     print(login)
     cursor.execute("SELECT * FROM person WHERE login=%(str)s",
                    {"str": login})
     row = cursor.fetchall()
     if len(row) == 0:
         return None
     user = Person()
     user.set_fields(row[0][0], row[0][1], row[0][2], row[0][3], row[0][4],
                     row[0][5])
     user.set_password_hash(row[0][6])
     print(user.name + " " + user.login + " " + user.password_hash)
     return user
예제 #3
0
 def post(self):
     parser = reqparse.RequestParser()
     parser.add_argument('login')
     parser.add_argument('password')
     parser.add_argument('name')
     parser.add_argument('surname')
     parser.add_argument('patronymic')
     parser.add_argument('bday')
     args = parser.parse_args()
     login = str(args['login'])
     password = str(args['password'])
     name = str(args["name"])
     surname = str(args["surname"])
     patronymic = str(args["patronymic"])
     bday = str(args["bday"])
     user = database_controller.getUserByLogin(login)
     if user is None:
         user = Person()
         user.set_fields(None, name, surname, patronymic, bday, login)
         user.set_password(password)
         database_controller.insert_person(user)
         user = database_controller.getUserByLogin(login)
     login_user(user, remember=True)
     return json.dumps("Login success")