May-04-2024, 06:51 PM
OK, and it is in the file users.db, which was defined by yourself
Flask role-based authorization
|
May-04-2024, 06:51 PM
OK, and it is in the file users.db, which was defined by yourself
May-04-2024, 07:02 PM
Yes, that is correct.
I welcome all feedback.
The only dumb question, is one that doesn't get asked. My Github How to post code using bbtags Download my project scripts
May-04-2024, 07:08 PM
I've edited the database.py with the database creation. It will add a default user of admin, password admin, and role of admin
After the app.secret_key in app.py I added db = Database() db.create() database.py import sqlite3 class Database: def __init__(self): self.connection = sqlite3.connect('users.db') self.cursor = self.connection.cursor() def getuser(self, user, passwd): query = f'select user, password, role from users where user="{user}" and password="{passwd}"' return self.cursor.execute(query).fetchone() def adduser(self, user, password, role): pass def edituser(self, id): pass def deleteuser(self, id): pass def create(self): query = ''' create table if not exists users ( id integer primary key, user text, password text, role text ) ''' self.connection.execute(query) self.connection.commit() query = ''' insert into users (user, password, role) values ("admin", "admin", "admin") ''' self.connection.execute(query) self.connection.commit()
I welcome all feedback.
The only dumb question, is one that doesn't get asked. My Github How to post code using bbtags Download my project scripts
May-04-2024, 07:26 PM
Thanks a lot for all the info..
|
|
Possibly Related Threads… | |||||
Thread | Author | Replies | Views | Last Post | |
Flask with paramiko based ssh client gives gevent LoopExit exception | hbknjr | 3 | 6,043 |
Dec-25-2018, 07:48 AM Last Post: hbknjr |