def register_post():
    vm = RegisterViewModel()
    vm.validate()

    if vm.error:
        return vm.to_dict()

    user = user_service.create_user(vm.name, vm.email, vm.password)
    if not user:
        vm.error = "The account could not be created."
        return vm.to_dict()

    resp = flask.redirect('/account')
    cookie_auth.set_auth(resp, user.id)

    return resp
Exemplo n.º 2
0
def register_post():
    view_model = RegisterViewModel()
    view_model.validate()

    if view_model.error:
        return view_model.to_dict()

    user = user_service.create_user(view_model.name, view_model.email,
                                    view_model.password)

    if not user:
        return view_model.to_dict()

    resp = flask.redirect('/account')
    cookie_auth.set_auth(resp, user.id)
    return resp
Exemplo n.º 3
0
def register_post():
    vm = RegisterViewModel()
    vm.validate()
    if vm.error:
        return vm.to_dict()

    # Create the user (in the DB)
    user = user_service.create_user(vm.name, vm.email, vm.password)
    if not user:
        vm.error = 'The account could not be created'
        return vm.to_dict()

    # Log in browser as a session
    resp = flask.redirect('/account')
    cookie_auth.set_auth(resp, user.id)

    return resp
Exemplo n.º 4
0
def register_post():
    # ViewModel gets name/email/password from flask.request, checks whether they're filled out, and if so tries to
    # register a user.  We just interpret the results here.
    # These are broken into a few calls here, although originally I had it as all in __init__.  This is more clear about
    # what is happening though

    vm = RegisterViewModel()

    vm.validate()
    if vm.error:
        return flask.render_template("/account/register.html", **vm.to_dict())

    vm.create_user()
    if vm.error:
        return flask.render_template("/account/register.html", **vm.to_dict())

    resp = flask.redirect("/account")
    cookie_auth.set_auth(resp, vm.user.id)
    return resp
def register_post():
    log.notice(f"Anonymous user is registering for a new account")

    vm = RegisterViewModel()
    vm.validate()

    if vm.error:
        log.notice(f"User could not create account, error: {vm.error}.")
        return vm.to_dict()

    user = user_service.create_user(vm.name, vm.email, vm.password)
    if not user:
        vm.error = 'The account could not be created'
        log.notice(f"User could not create account, error: {vm.error}.")
        return vm.to_dict()

    resp = flask.redirect('/account')
    cookie_auth.set_auth(resp, user.id)

    log.notice(f"User SUCCESSFULLY created account: {user.name} - {user.email}.")
    return resp
def register_get():
    vm = RegisterViewModel()
    return vm.to_dict()