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
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
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