예제 #1
0
	def post(self):
		if self.body_json_object is None:
			self.exception_handle(
				'Request data format exception, %s' % self.request.uri)
			return
		tel = self.body_json_object.get('tel')
		if tel is None or len(tel) == 0:
			self.exception_handle('Missing argument \'tel\'')
			return
		user = yield MySQLHelper.fetch_profile_by_tel(tel)
		if user is None:
			self.exception_handle('User not found')
			return
		request_password = self.body_json_object.get('password')
		if request_password is None or len(request_password) == 0:
			self.exception_handle('Missing argument \'password\'')
			return
		password = user.get('password', '')
		if request_password <> password:
			self.exception_handle('Incorrect password')
			return
		request_deviceid = self.body_json_object.get('deviceid')
		if request_deviceid is None or len(request_deviceid) == 0:
			self.exception_handle('Missing argument \'deviceid\'')
			return
		deviceid = user.get('deviceid', '')
		if request_deviceid <> deviceid:
			self.exception_handle('Incorrect device id')
			return
		uu = self.session_set(user.get('id'))
		if uu is None or len(uu) == 0:
			self.exception_handle('Session setup failed')
			return
		self.write(self.gen_result(0, 'Successfully login', uu))
예제 #2
0
	def get(self):
		self.write(111)
		#a = yield MySQLHelper.add_user({
		#		'name': 'test1',
		#		'password': '******'
		#	})
		a = yield MySQLHelper.modify_password('bfb7c38a-9bda-11e5-8ad1-5254001a7787', '123456')
		self.write(222)
예제 #3
0
	def get(self):
		id_ = None
		session_id_ = self.session_get()
		if self.request.arguments.has_key('id'):
			id_ = self.get_argument('id')
		if id_ is None or len(id_) == 0:
			id_ = session_id_
		if id_ is None or len(id_) == 0:
			self.exception_handle('Missing argument \'id\'')
			return
		user = None
		if id_ <> session_id_:
			user = yield MySQLHelper.fetch_base_profile(id_)
		else:
			user = yield MySQLHelper.fetch_profile(id_)
		if user is None:
			self.exception_handle('User not found')
			return
		self.write(self.gen_result(0, 'Account profile', user))
		return
예제 #4
0
	def post(self):
		uid = self.session_get()
		if uid is None or len(uid) == 0:
			self.exception_handle(
				'Session timeout')
			return
		if self.body_json_object is None:
			self.exception_handle(
				'Request data format exception, %s' % self.request.uri)
			return
		self.body_json_object['id'] = uid
		rc = yield MySQLHelper.update_profile(self.body_json_object)
		if rc is None or rc == 0:
			self.exception_handle('The database operation failed (MySQL.UpdateProfile)')
			return
		self.write(self.gen_result(0, 'Successfully changed', 'ok'))
예제 #5
0
	def get(self):
		id_ = None
		if self.request.arguments.has_key('id'):
			id_ = self.get_argument('id')
		if id_ is None or len(id_) == 0:
			self.exception_handle('Missing argument \'id\'')
			return
		avatar = yield MySQLHelper.fetch_avatar(id_)
		if avatar is None or len(avatar) == 0:
			self.exception_handle('Specific avatar not found')
			return
		try:
			avatar = base64.b64decode(avatar)
		except Exception, e:
			self.exception_handle('Base64 decoding failure')
			return
예제 #6
0
	def post(self):
		uid = self.session_get()
		if uid is None or len(uid) == 0:
			self.exception_handle(
				'Session timeout')
			return
		if self.body_json_object is None:
			self.exception_handle(
				'Request data format exception, %s' % self.request.uri)
			return
		avatar = self.body_json_object.get('avatar')
		if avatar is None or len(avatar) == 0:
			self.exception_handle(
				'Missing argument \'avatar\'')
			return
		rc = yield MySQLHelper.modify_avatar(uid, avatar)
		if rc is None or rc == 0:
			self.exception_handle('The database operation failed (MySQL.ModifyAvatar)')
			return
		self.write(self.gen_result(0, 'Successfully changed', 'ok'))
예제 #7
0
	def post(self):
		uid = self.session_get()
		if uid is None or len(uid) == 0:
			self.exception_handle(
				'Session timeout')
			return
		if self.body_json_object is None:
			self.exception_handle(
				'Request data format exception, %s' % self.request.uri)
			return
		request_password = self.body_json_object.get('password')
		if request_password is None or len(request_password) == 0:
			self.exception_handle('Missing argument \'password\'')
			return
		# TODO Check password format
		try:
			rc = yield MySQLHelper.modify_password(uid, request_password)
		except Exception, e:
			self.exception_handle('Password change failed (MySQL)')
			return