示例#1
0
def create_session_or_user():
    """
	Acquires form method, and identity of the form
	If the form validates, its values will be sent to UserController 
	
	if the identity of the form is register, sent to 
	function create()

	if the identity of the form is login, sent to
	function login()
	"""
    if request.method == "POST":
        if not current_user.is_authenticated:
            if request.form["auth"] == "register":
                username = request.form["username"]
                email = request.form["email"]
                password = request.form["password"]
                return UserController.create_user(username, email, password)
            elif request.form["auth"] == "login":
                username = request.form["username"]
                password = request.form["password"]
                return UserController.create_session(username, password)
        else:
            return ErrorController.error("403"), 403
    else:
        return ErrorController.error("404"), 404
示例#2
0
def update_user():
    """
	Verifies current_user
	
	If POST
	Sends username, email, and password to UserController
	function update()

	If GET
	Sends the user to UserController
	function updateView()

	"""
    if request.method == "POST":
        if request.form["user"] == "update":
            username = request.form["username"]
            email = request.form["email"]
            bio = request.form["bio"]
            password = request.form["password"]
            return UserController.update(username, email, bio, password)
        else:
            profile_picture = request.files["file"]
            return UserController.update_profile_picture(profile_picture)
    elif request.method == "GET":
        return UserController.update_view()
    else:
        return ErrorController.error("404"), 404
示例#3
0
def follow_user(username):
    """
	Verifies current_user
	Sends username to UserController
	function follow()
	"""
    return UserController.follow(username)
示例#4
0
def ban_user(username):
    """
	Verifies current_user is admin
	Sends username to UserController
	function ban()
	"""
    return UserController.ban(username)
示例#5
0
def destroy_user_session():
    """
	Varifies current_user
	Sends to UserController
	function logout()
	"""
    return UserController.destroy_session()
示例#6
0
def load_logged_in_user():
    """
	Before any request
	Sends to UserController
	function getUser()
	"""
    return UserController.get()
示例#7
0
def show_user(username):
    """
	Sends username to UserController
	function show()
	"""
    return UserController.show(username)