Example #1
0
def addusersettings():
    username = request.json.get("username", "")
    settings = request.json.get("settings", {})
    users_setting = oauthsocial.SocialAuth()._loginUsers()
    try:
        if "settings" in users_setting[username]:
            settings_user = json.loads(users_setting[username]["settings"])
            settings_user.update(settings)
            users_setting[username]["settings"] = json.dumps(settings_user)
        else:
            users_setting[username]["settings"] = json.dumps(settings)
        oauthsocial.SocialAuth()._save_loginFile(users_setting)
        return "Added User settings"
    except:
        import traceback
        print traceback.format_exc()
        return "User not found"
Example #2
0
def reset():
    username = request.json.get("username", "")
    password = request.json.get("password", "")
    if username not in users:
        return "Invalid Username, does not exists."
    users[username] = password
    oauthsocial.SocialAuth()._save_loginFile(users)
    return "Password Reset Done"
Example #3
0
def getuser():
    try:
        username = request.values.get("username", "").split('"')[1]
    except:
        username = request.values.get("username", "")
    try:
        users_setting = oauthsocial.SocialAuth()._loginUsers()
        return jsonify(json.loads(users_setting[username]["settings"]))
    except:
        return jsonify({})
Example #4
0
def adduser():
    username = request.json.get("username", "")
    password = request.json.get("password", "")
    settings = request.json.get("settings", {})
    users[username] = {"password": password}
    try:
        users[username]["settings"] = json.dumps(settings)
    except:
        import traceback
        print traceback.format_exc()
        pass
    oauthsocial.SocialAuth()._save_loginFile(users)
    return "Added New User"
Example #5
0
 def __init__(self):
     self.twitterApiObj, self.instaApiObj = oauthsocial.SocialAuth(
     )._getAPIObj()
Example #6
0
import stream
import datetime
from flask import Flask
from flask_cors import CORS, cross_origin
import flask_login
import user
import oauthsocial

app = Flask(__name__,
            static_url_path='/root/SocialHashtag/grapevine-social/public')
app.secret_key = '#50C!@L@H@5HT@G!@SA'
CORS(app)
login_manager = flask_login.LoginManager()
login_manager.init_app(app)

users = oauthsocial.SocialAuth()._getUsers()


class User(flask_login.UserMixin):
    pass


@login_manager.user_loader
def user_loader(email):
    if email not in users:
        return

    user = User()
    user.id = email
    return user