def signup(): """Register a new user Returns ------- json Info about the user """ user = {} data = request.get_json() local_auth = LocalAuth(current_app, session) local_auth.check_inputs(data) if not local_auth.get_error(): user = local_auth.persist_user(data) local_auth.create_user_directories(user['id'], user['username']) session['user'] = user return jsonify({ 'error': local_auth.get_error(), 'errorMessage': local_auth.get_error_message(), 'user': user })
def signup(): """Creates a new user for Genocrowd """ new_user = {} local_auth = LocalAuth(ca, session) data = request.get_json() local_auth.check_inputs(data) if not local_auth.get_error(): # FIXME is it safe to pass role? where does it come from? new_user = local_auth.add_user_to_database(data['username'], data['email'], data['password'], data['grade'], data['role']) new_user['_id'] = str(new_user['_id']) session['user'] = new_user return kill_apollo_session( jsonify({ 'error': local_auth.get_error(), 'errorMessage': local_auth.get_error_message(), 'user': new_user }))