Esempio n. 1
0
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
Esempio n. 2
0
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)
Esempio n. 3
0
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
Esempio n. 4
0
def show(user_id):
    person = Person.objects(id=ObjectId(user_id)).get()
    if not person:
        return redirect('/')

    return render_template('profile.html', person=person)
Esempio n. 5
0
def get_current_user():
    if not is_loggedin():
        return None

    return Person.objects(id=ObjectId(session['user_id'])).get()