def _on_user_info2(self, data): data = json.loads(data) ret = data.get('ret', None) if ret != 0: self.write(_('QQ auth failed: %s') % data.get('msg', '')) return self.finish() # create new user O = OpenID(openid=self.openid, _type=1) # TODO: QQ now O.config = json.dumps({'get_user_info': data}) self.db.add(O) self.db.commit() while True: username = '******' % random.randint(1, 10000000) U = self.db.query(User).filter_by(username=username).first() if not U: break U = User(username=username, password='******', language=self.language) U.nickname = data.get('nickname', None) U.email_valid = True self.db.add(U) self.db.commit() U.init_account(self.db) self.save_session(U.id) U.last_login = datetime.datetime.now() O.user_id = U.id self.db.commit() # TODO: drop account relationships profile = UserProfile(U) self.db.add(profile) self.db.commit() self.redirect('/account')
def _on_user_info2(self, data): data = json.loads( data ) ret = data.get('ret', None) if ret != 0: self.write(_('QQ auth failed: %s') % data.get('msg','')) return self.finish() # create new user O = OpenID( openid = self.openid, _type = 1 ) # TODO: QQ now O.config = json.dumps( { 'get_user_info': data } ) self.db.add(O) self.db.commit() while True: username = '******' % random.randint(1, 10000000) U = self.db.query(User).filter_by(username=username).first() if not U: break U = User( username = username, password = '******', language = self.language ) U.nickname = data.get('nickname', None) U.email_valid = True self.db.add( U ) self.db.commit() U.init_account(self.db) self.save_session(U.id) U.last_login = datetime.datetime.now() O.user_id = U.id self.db.commit() # TODO: drop account relationships profile = UserProfile( U ) self.db.add(profile) self.db.commit() self.redirect('/account')
def _on_user_info(self, data): data = json.loads( data ) ret = data.get('ret', None) if ret != 0: self.write(_('QQ auth failed: %s') % data.get('msg','')) return self.finish() # create openid O = OpenID( openid = self.openid, _type = 1 ) # TODO: QQ now O.config = json.dumps( { 'get_user_info': data } ) self.db.add(O) self.db.commit() # create auth key K = AuthKey( data = O.openid, seconds = 3600 * 24 * 7 ) self.db.add( K ) self.db.commit() self.render('account/openid_success.html', auth_key = K.auth_key, openid=O.id)
def _on_user_info(self, data): data = json.loads(data) ret = data.get('ret', None) if ret != 0: self.write(_('QQ auth failed: %s') % data.get('msg', '')) return self.finish() # create openid O = OpenID(openid=self.openid, _type=1) # TODO: QQ now O.config = json.dumps({'get_user_info': data}) self.db.add(O) self.db.commit() # create auth key K = AuthKey(data=O.openid, seconds=3600 * 24 * 7) self.db.add(K) self.db.commit() self.render('account/openid_success.html', auth_key=K.auth_key, openid=O.id)