Example #1
0
File: index.py Project: 9wfox/robot
    def post(self):
        username = self.get_argument('username')
        password = self.get_argument('password')
        password = hashlib.md5(password).hexdigest()
        user = mongo_util.m_find_one('passport', loginname = username, pwd = password)
        if user:
            self.set_secure_cookie('__UID__', user.get('_id'))

        self.redirect("/")
Example #2
0
def get_user_acs(handler):
    """ 获取用户的权限表"""

    access = handler.user
    acs = access.get('access')
    if isinstance(acs, list): return acs

    if access.get('roleid'):
        role_acs = mongo_util.m_find_one(T_ROLE,
                            fields = {'access': 1, '_id': 0},
                            _id = ObjectId(access.get('roleid'))).get('access', [])
        return role_acs
    return []
Example #3
0
def get_subst_info(uid = None, substid = None):
    fields = ['substid', 'name', 'fid', 'location_name', 'location_lat', 'location_lng']
    if not substid:
        sql = "select {} from {}"
        if uid:
            substid = mongo_util.m_find_one(T_PASSPORT,_id=ObjectId(uid)).get('substid') or ['']
            substid = ["'" + item + "'" for item in substid]
            sql += " where substid IN ({})".format(','.join(substid))
        data,p = mysql_util.m_query(sql.format(','.join(fields), T_SUBST_INFO), fields, findall=True)
    else:
        sql = "select {} from {} where substid='{}'"
        data = mysql_util.m_query_one(sql.format(','.join(fields), T_SUBST_INFO, substid), fields)

    return data
Example #4
0
File: user.py Project: 9wfox/robot
    def get(self):
        uids, t = mongo_util.m_list(T_ACCESS, findall = '1', fields = {'_id': 1})
        uids = [ObjectId(item.get('_id')) for item in uids]

        userlist, t = mongo_util.m_list(T_PASSPORT, fields = {'pwd': 0}, findall = '1',
                                        _id = {'$in': uids})

        users = {}
        for u in userlist:
            company = mongo_util.m_find_one(T_COMPANY, user = u.get('_id'))
            companyname = company.get('name', '未分组')

            if users.has_key(companyname):
                users[companyname].append(u)
            else:
                users[companyname] = [u]

        self.write(dict(status = True, data = users))
Example #5
0
File: user.py Project: 9wfox/robot
def pre_user(user):
    for u in user:
        roleid = u.get('roleid')
        if roleid:
            role = mongo_util.m_find_one(T_ROLE, _id = ObjectId(roleid))
            u['rolename'] = role.get('name')
Example #6
0
File: user.py Project: 9wfox/robot
 def get(self):
     uid = self.get_argument('uid')
     user = mongo_util.m_find_one(T_PASSPORT,  _id = ObjectId(uid))
     self.render("tpl/user_edit.html", user = user)
Example #7
0
 def get_user(self):
     user = mongo_util.m_find_one('passport', _id = ObjectId(self.uid))
     return user