def showPassword(id): account = Account.query.get(id).getDict(modelAttribute.attributeList) attributes = modelAttribute attributes['attributeList'] = modelAttribute.attributeList[:-1] pageValues = DictObj(header='Account mit Passwort', account=account, modelAttribute=attributes) return render_template('ShowPassword.html', pageValues=pageValues)
def addNewAccount(): form = EditForm() if request.method == 'POST' and form.validate(): id = Account.insertAccount(form.data) return showPassword(id) pageValues = DictObj(header='Neues Account Objekt erstellen', form=form, ngApp='GeneratePwd', ngCtrl='PostCtrl') return render_template('AddNewAccount.html', pageValues=pageValues)
def editAccount(id): form = EditForm() account = Account.getDictOf(id, modelAttribute.attributeList[:-1]) if request.method == 'POST': account.update(form.data) if form.validate(): Account.modifyDBAccount(account) return showPassword(id) else: form = EditForm(data=account) pageValues = DictObj(header='Edit Account', form=form, account=account, modelAttribute=modelAttribute) return render_template('EditAccount.html', pageValues=pageValues)
def deleteAccount(id): if request.method == 'POST': print("Post request: get_json()") obj = request.get_json() print(obj) Account.deleteAccount(obj['id']) return jsonify(dict(success=True, text='Der Eintrag wurde gelöscht.')) pageValues = DictObj(header='Account löschen') pageValues.attributeList = ['id', 'provider', 'username', 'lastmodify'] pageValues.account = Account.getDictOf(id, pageValues.attributeList) pageValues.id = id pageValues.modelAttribute = modelAttribute return render_template('DeleteAccount.html', pageValues=pageValues)
def generatePwd(id): form = GeneratePwdForm() account = Account.getDictOf(id, modelAttribute.attributeList[:-1]) if request.method == 'POST': account.update(form.data) if form.validate(): Account.modifyDBAccount(account) return showPassword(account['id']) else: form = GeneratePwdForm(data=account) attributeList = [ 'id', 'provider', 'username', 'question', 'answer', 'lastmodify' ] pageValues = DictObj(header='Passwort generieren', modelAttribute=modelAttribute, account=account, form=form, attributeList=attributeList, ngApp='GenerateCtrl', ngCtrl='FormCtrl') return render_template('GeneratePwd.html', pageValues=pageValues)
def start(): pageValues = DictObj(header='Liste aller Accounts', ngApp='PwdManager', ngCtrl='ListCtrl', list=True) return render_template('AccountList.html', pageValues=pageValues)
def security_login_processor(): return dict(pageValues=DictObj(header='Anmelden'))
def security_register_processor(): return dict(pageValues=DictObj(header='Benutzer registrieren', login=True))
from Application import db, credentials from flask_security import RoleMixin, UserMixin, current_user from Utility.DictObj import DictObj import datetime modelAttribute = DictObj(id='Id', provider='Anbieter', username='******', password='******', passwordlength='Passwortlänge', definedcharacter='Zulässige Zeichen', question='Sicherheitsfrage', answer='Antwort Sicherheitsfrage', lastmodify='Letzte Änderung', userid='Eigentümer', attributeList=[ 'id', 'provider', 'username', 'password', 'passwordlength', 'definedcharacter', 'question', 'answer', 'lastmodify', 'userid' ]) class Account(db.Model): __tablename__ = credentials.tablename id = db.Column(db.Integer, primary_key=True) provider = db.Column(db.String) username = db.Column(db.String) password = db.Column(db.String) passwordlength = db.Column(db.Integer) definedcharacter = db.Column(db.String) question = db.Column(db.String)