def __init__(self): super(MainWindow, self).__init__() self.setWindowTitle('MainWindow') self.wt = forms.WaitWindow() self.menu = forms.MainMenu(self.show_psw, self.wt, second.start, second.start, second.start) self.psw = forms.Password(self.menu) self.psw.show()
def lock(previous_page): form = forms.Password() password_model = models.PasswordForAdd.select().get() if password_model.locked == True: if form.validate_on_submit(): if check_password_hash(password_model.password, form.password.data): password_model.locked = False password_model.save() flash("Add features unlocked!", "success") else: flash("Incorrect Password", "fail") return redirect(url_for(previous_page)) return render_template("unlock.html", form=form) else: return render_template("lock.html")
def password_post(): form = forms.Password(request.form) if form.validate(): current_user.set_password(form.data['password']) # Expire all stored keys, so this can't be used as an attack vector for key in current_user.keys: key.access_token = '' key.refresh_token = '' key.secret = '' key.service_user_id = '' key.expires = datetime.datetime.now() models.db.session.add(current_user) models.db.session.commit() return redirect(url_for('services')) else: return render_template('password.html', form=form)
def delete(entry_id, slug): chosen_entry = models.JournalEntry.select().where( models.JournalEntry.journal_id == entry_id).get() if chosen_entry.has_password: entry_password = models.JournalPassword.select().where( models.JournalPassword.journal_entry == chosen_entry).get().password password_form = forms.Password() if password_form.validate_on_submit(): if check_password_hash(entry_password, password_form.password.data): flash("Correct Password Entered!", "success") entry_title = chosen_entry.title entry_date = chosen_entry.date.strftime('%B %d, %Y') tag_list = [] for tag in models.TagToJournal.select().where( models.TagToJournal.journal == chosen_entry): tag_list.append(tag.tag_label) session_bool = models.SessionBool.select().get() session_bool.switch = True session_bool.save() return render_template('delete.html', entry_title=entry_title, entry_date=entry_date, tag_list=tag_list, entry_id=entry_id) else: flash("Incorrect Password", "fail") return redirect( url_for('redirect_details', entry_id=chosen_entry.journal_id)) return render_template("entry_password.html", form=password_form) else: entry_title = chosen_entry.title entry_date = chosen_entry.date.strftime('%B %d, %Y') tag_list = [] for tag in models.TagToJournal.select().where( models.TagToJournal.journal == chosen_entry): tag_list.append(tag.tag_label) return render_template('delete.html', entry_title=entry_title, entry_date=entry_date, tag_list=tag_list, entry_id=entry_id)
def __init__(self): if session.user_id: self.user_id = session.user_id self.form = forms.Password()
def edit(tags_or_details, entry_id, slug): chosen_entry = models.JournalEntry.select().where( models.JournalEntry.journal_id == entry_id).get() if chosen_entry.has_password: entry_password = models.JournalPassword.select().where( models.JournalPassword.journal_entry == chosen_entry).get().password password_form = forms.Password() if password_form.validate_on_submit(): if check_password_hash(entry_password, password_form.password.data): flash("Correct Password Entered!", "success") if tags_or_details == "tags": return redirect( url_for('set_tag', entry_id=entry_id, slug=slugify_title(chosen_entry.title))) elif tags_or_details == "details": session_bool = models.SessionBool.select().get() # the session bool protects the details edit page from # being accessed by simply typing the url session_bool.switch = True session_bool.save() return redirect( url_for('editdetails', entry_id=entry_id, slug=slugify_title(chosen_entry.title))) else: flash("Incorrect Password", "fail") return redirect( url_for('redirect_details', entry_id=chosen_entry.journal_id)) return render_template("entry_password.html", form=password_form) else: if tags_or_details == "tags": return redirect( url_for('set_tag', entry_id=entry_id, slug=slugify_title(chosen_entry.title))) elif tags_or_details == "details": class EditEntry(Form): """Form with dynamic select fields to set defaults""" pass setattr( EditEntry, "title", StringField(u'Title', validators=[DataRequired()], default=chosen_entry.title)) setattr( EditEntry, "date", DateField(u'Date', validators=[DataRequired()], default=chosen_entry.date)) setattr( EditEntry, "time_spent_hours", IntegerField(u'Hours', default=chosen_entry.time_spent_hours)) setattr( EditEntry, "time_spent_minutes", IntegerField(u'Minutes', default=chosen_entry.time_spent_minutes)) setattr( EditEntry, "what_i_learned", TextAreaField(u'What I Learned', validators=[DataRequired()], default=chosen_entry.what_i_learned)) setattr( EditEntry, "resources_to_remember", TextAreaField(u'Resources to Remember', validators=[DataRequired()], default=chosen_entry.resources_to_remember)) setattr( EditEntry, "password", PasswordField(u'Password', validators=[ EqualTo('password2', message='Passwords must match') ])) setattr(EditEntry, "password2", PasswordField(u'Password2')) form = EditEntry() if form.validate_on_submit(): if form.password.data: chosen_entry.title = form.title.data chosen_entry.date = form.date.data chosen_entry.time_spent_hours = form.time_spent_hours.data chosen_entry.time_spent_minutes = form.time_spent_minutes.data chosen_entry.what_i_learned = form.what_i_learned.data chosen_entry.resources_to_remember = form.resources_to_remember.data chosen_entry.has_password = True chosen_entry.save() password_model = models.JournalPassword.select().where( models.JournalPassword.journal_entry == chosen_entry).get() password_model.password = generate_password_hash( form.password.data) password_model.save() else: chosen_entry.title = form.title.data chosen_entry.date = form.date.data chosen_entry.time_spent_hours = form.time_spent_hours.data chosen_entry.time_spent_minutes = form.time_spent_minutes.data chosen_entry.what_i_learned = form.what_i_learned.data chosen_entry.resources_to_remember = form.resources_to_remember.data chosen_entry.has_password = False chosen_entry.save() flash("Details Updated!", "success") return redirect( url_for('redirect_details', entry_id=chosen_entry.journal_id)) return render_template("edit.html", form=form, chosen_entry=chosen_entry) else: return redirect(url_for(index))
def password(): return render_template('password.html', form=forms.Password())