Esempio n. 1
0
def identify():
    if is_logged():
        user = UserService().get_by_id(flask.session['user_id'])
        if user is not None:
            return flask.jsonify(user.to_dic())
        flask.session.pop('user_id', None)
    return '', 403
Esempio n. 2
0
def login():
    user = UserService().get_by_log(flask.request.form["username"], flask.request.form["password"])
    if user is not None:
        flask.session['user_id'] = user.id
        flask.session.pop('board_id', None)
        return flask.jsonify(user.to_dic())
    flask.session.pop('user_id', None)
    return '', 403
Esempio n. 3
0
def register():
    user = UserService().add(flask.request.form["username"], flask.request.form["email"], flask.request.form["password"])
    # TODO board = BoardService().add(db.Session(), name, user)
    if user is not None:
        return flask.jsonify(user.to_dic())
    return flask.jsonify(identified=False)