Exemple #1
0
def search_account(hm):
    mm = hm.mm
    account = hm.get_argument('account', '')
    user = UserData.get(account)
    if user.inited or not account:
        return 1, {'msg': '账号信息有误'}
    return 0, {'msg': '搜索成功', 'name': user.name, 'account': user.account}
Exemple #2
0
def logout(hm):
    mm = hm.mm
    user = UserData.get(mm.user.account)
    hm.req.clear_cookie('account')
    # if not user.online:
    #     return 1,{'msg':'当前没在登陆状态'}
    user.online = False
    user.save()
    return 0, {'msg': "退出成功"}
Exemple #3
0
def reset_name(hm):
    account = hm.get_argument('account', '')
    if account.inited:
        return 2, {'msg': '用户不存在'}
    new_name = hm.get_argument('new_name', '')
    if not new_name:
        return 1, {'msg': '请输入正确的名称'}
    user = UserData.get(account)
    rc, data = user.rename(new_name)
    return rc, data
Exemple #4
0
def reset_pwd(hm):
    old_pwd = hm.get_argument('old_pwd', '')
    new_pwd = hm.get_argument('new_pwd', '')
    account = hm.get_argument('account', '')
    if account.inited:
        return 2, {'msg': '用户不存在'}
    if not old_pwd or not new_pwd:
        return 1, {'msg': '新密码、旧密码都不允许为空'}  # 新密码、旧密码都不允许为空
    user = UserData.get(account)
    rc, data = user.resetpwd(old_pwd, new_pwd)
    return rc, data
Exemple #5
0
 def add_friend(self, account):
     if account in self.messages:
         del self.messages[self.messages.index(account)]
     user = UserData.get(account)
     self.friends[account] = {
         'msg': [],
         'new_msg': [],
         'name': user.name,
         'account': account
     }
     self.save()
Exemple #6
0
    def get():
        data = CompanyAppliedList.parser.parse_args()

        users = UserCompany(None, None,
                            data['company_id']).find_all_applicants()

        all_users = []
        if users:
            for user in users:
                all_users.append(UserData.json(User.find_by_id(user[1])))

        return {"all_applied_users": all_users}, 200
Exemple #7
0
def login(hm):
    mm = hm.mm
    account = hm.get_argument('account', '')
    password = hm.get_argument('password', '')
    user = UserData.get(account)
    if user.inited:
        return 1, {'msg': '账号不存在'}
    if not user.check_pwd(password):
        return 2, {'msg': '密码不正确'}
    if user.online:
        return 3, {'msg': '账号已经在登陆状态'}
    user.online = True
    user.save()
    hm.req.set_secure_cookie('account', account)

    return 0, {'msg': '登陆成功'}
Exemple #8
0
def register_user(hm):
    account = hm.get_argument('account', '')
    password = hm.get_argument('password', '')
    name = hm.get_argument('name', '')
    if not password:
        return 1, {'msg': '密码不允许为空'}  # 密码有误
    user = UserData.get(account)
    if not user.inited:
        return 2, {'msg': '账号已存在'}  # 账号已存在
    user.set_pwd(password)
    user.rename(name)
    mm = ModelManager(user.uid)
    mm.user = user
    user.save()
    mm.do_save()
    hm.mm = user
    return 0, {'msg': '注册成功'}
Exemple #9
0
def index(hm):
    account = hm.req.get_current_user()
    user = UserData.get(account)
    if not user.inited:
        return 0, {'msg': '已经登陆', 'name': user.name, 'uid': user.account}
    return 1, {'msg': '没有登陆'}