def check_uid(cls, params): sql = "select * from 352dt_user_info where uid = %s" row = mysql_utils.Database().query_one(sql, (params['uid'], )) if row is not None: user = user_model.User(uid=row['uid'], uname=row['uname'], usergroup=row['user_group'], nickname=row['nickname'], mail=row['mail'], phone=row['phone']) # 实例化一个对象,将查询结果逐一添加给对象的属性 else: return None return user
def login_auth(cls, params): passwd = hash.salted_password(params['passwd']) sql = "select * from 352dt_user_info where uname = %s and passwd = %s" row = mysql_utils.Database().query_one(sql, (params['uname'], passwd)) if row is not None: user = user_model.User(uid=row['uid'], uname=row['uname'], usergroup=row['user_group'], nickname=row['nickname'], mail=row['mail'], phone=row['phone']) # 实例化一个对象,将查询结果逐一添加给对象的属性 else: return None return user
def find_user(self, user_id): try: user = self.db.users.find_one({'user_id': user_id}) if user: return user_model.User(user['user_id'], user['first_name'], user['last_name'], user['email'], user['gender'], user['last_seen'], address_line=user.get('address_line'), city=user.get('city'), state=user.get('state'), zipcode=user.get('zipcode'), phone_number=user.get('phone_number')) return None except: return None