def register_user(email, firstname, lastname, password): account = BankAccount() account.save() person = Person(email=email, firstname=firstname, lastname=lastname, password=password, accounts=[account]) person.save() return person
def show(user_id=None): person = Person.objects(id=ObjectId(user_id)).get() if user_id else\ get_current_user() if not person: return redirect('/') return render_template('profile.html', person=person)
def login(email, password): person = Person.objects(email=email).get() if not person: return False if password != person.password: return False session['user_id'] = str(person.id) return person
def show(user_id): person = Person.objects(id=ObjectId(user_id)).get() if not person: return redirect('/') return render_template('profile.html', person=person)
def get_current_user(): if not is_loggedin(): return None return Person.objects(id=ObjectId(session['user_id'])).get()