Bug fixes with identitity federation

legacy
Gogs 8 years ago
parent 4ca95366b9
commit 7f1d9e0eb6

@ -19,8 +19,7 @@ class User:
self.user = None self.user = None
def initialize(self,uid) : def initialize(self,uid) :
id = self.getId(uid) id = self.getId(uid)
if id is not None and self.db.doc_exist(id) :
if self.db.doc_exist(id) :
self.user = self.db.get(id) self.user = self.db.get(id)
""" """
This function will cast an object to JSON, This function will cast an object to JSON,
@ -42,7 +41,7 @@ class User:
r = r.first() r = r.first()
return r['value'] return r['value']
else: else:
None return None
def init (self,uid,plans): def init (self,uid,plans):
customer = {} customer = {}
@ -235,6 +234,7 @@ class User:
def update_user(self,**args) : def update_user(self,**args) :
id = args['id'] id = args['id']
uid= args['uid'] uid= args['uid']
print ['update ...',id,uid]
self.user = self.db.get(id) self.user = self.db.get(id)
self.user['emails'].append(uid) self.user['emails'].append(uid)
self.user['emails'] = list(set(self.user['emails'])) self.user['emails'] = list(set(self.user['emails']))

@ -37,23 +37,46 @@ COUCHDB = Server(uri=CONFIG['couchdb']['uri']) ;
@app.route("/init/<app_name>",methods=['POST']) @app.route("/init/<app_name>",methods=['POST'])
def init(app_name): def init(app_name):
plans = [] plans = []
if 'uid' in request.headers: handler = None
uid = request.headers['uid'] uid = request.headers['uid']
plan= request.headers['pid'] plan = request.headers['pid']
couchdb = Couchdb(uri=CONFIG['couchdb']['uri'],dbname=app_name,uid=uid) auid = None
if 'uid' in request.headers and 'auid' not in request.headers:
id = uid
#couchdb = Couchdb(uri=CONFIG['couchdb']['uri'],dbname=app_name,uid=uid,create=False)
#DB = couchdb.dbase
if 'auid' in request.headers :
auid = request.headers['auid']
auid = json.loads(auid)if auid.startswith('[') else auid
if isinstance(auid,list) :
auid = list(set(auid) - set([uid]))
if len(auid) == 0:
auid = None
id = uid
else:
auid = auid[0]
id = auid
couchdb = Couchdb(uri=CONFIG['couchdb']['uri'],dbname=app_name,uid=id,create=False)
DB = couchdb.dbase DB = couchdb.dbase
#handler.update_user(id=handler.getId(auid),uid=uid)
handler = Domain.User(DB,stripe) ; handler = Domain.User(DB,stripe) ;
if 'customer.id' not in session : if auid is None :
handler.init(uid,plan) handler.init(uid,plan) ;
id=handler.getId(uid)
session['customer.id'] = id
else: else:
id = session['customer.id'] if couchdb.isready() == False:
handler.initialize(uid) handler.init(auid,plan)
handler.update_user(id,uid=uid) id = handler.getId(uid)
handler.initialize(auid)
id = handler.getId(auid)
handler.update_user(id=id,uid=uid) ;
plans = handler.plans() plans = handler.plans()
#return json.dumps(plans) #return json.dumps(plans)
return features(app_name) _features = features(app_name)
return _features
""" """
This function will update the user's email This function will update the user's email
""" """

Loading…
Cancel
Save