def client_login(params): code = params.get("code") if not code or len(code) != 36: return {"error_code":1, "msg":"params invalid"} key = "jump-%s" % code obj = misc.misc_get(key) if not obj: return {"error_code":1, "msg":"code not exists"} dic = utils.loads(obj.value) obj.delete_instance() if dic['expire_at'] < utils.stamp(): return {"error_code":1, "msg":"code expire"} user = User.select().where(User.id==dic['user_id']).first() res = {"error_code":0, "msg":"ok"} res['session_token'] = generate_token() sess = Session() sess.user = user sess.session_key = res['session_token'] sess.expire_at = utils.timedelta(utils.now(), days=1) res['expire_at'] = 0 sess.save() res['identify'] = user.identify return res
def client_login(params): code = params.get("code") if not code or len(code) != 36: return {"error_code": 1, "msg": "params invalid"} key = "jump-%s" % code obj = misc.misc_get(key) if not obj: return {"error_code": 1, "msg": "code not exists"} dic = utils.loads(obj.value) obj.delete_instance() if dic['expire_at'] < utils.stamp(): return {"error_code": 1, "msg": "code expire"} user = User.select().where(User.id == dic['user_id']).first() res = {"error_code": 0, "msg": "ok"} res['session_token'] = generate_token() sess = Session() sess.user = user sess.session_key = res['session_token'] sess.expire_at = utils.timedelta(utils.now(), days=1) res['expire_at'] = 0 sess.save() res['identify'] = user.identify return res
def login(uname, password): if not uname or not password: return {"error_code":20001, "msg":"parameters required"} user = User.select().where(User.username == uname or User.email == uname or User.phone == uname).first() if not user: return {"error_code":20002, "msg":"user not exists"} if not check_password(password, user.password, user.salt): return {"error_code":20003, "msg":"username or password invalid"} res = {"error_code":0, "msg":"ok"} res['session_token'] = generate_token() sess = Session() sess.user = user sess.session_key = res['session_token'] sess.expire_at = utils.timedelta(utils.now(), days=1) res['expire_at'] = 0 sess.save() return res
def login(uname, password): if not uname or not password: return {"error_code":20001, "msg":"parameters required"} user = SystemUser.select().where(SystemUser.username == uname).first() if not user: return {"error_code":20002, "msg":"user not exists"} if not check_password(password, user.password, user.salt): return {"error_code":20003, "msg":"username or password invalid"} res = {"error_code":0, "msg":"ok"} res['session_token'] = generate_token() sess = Session() sess.user = user sess.session_key = res['session_token'] sess.expire_at = utils.timedelta(utils.now(), days=1) res['expire_at'] = 0 sess.save() return res