--登录 localfunctionlogin(c) local req = c.req local body = req.body local account = body.account local password = body.password assert(account, "not account") assert(password, "not passwword")
local isok, errcode, errmsg = rpc_center_account.auth(account, password) ifnot isok then rsp_body.set_rsp(c, nil, errcode, errmsg) else local player_id, hall_server_id = errcode, errmsg local host = rpc_hall_player.get_host(player_id) assert(host, "can`t get host") local token = rpc_hall_player.create_token(player_id, ENUM.LOGIN_TOKEN_TIME_OUT) assert(type(token) == "string", "create token err ") rsp_body.set_rsp(c, { token = token, host = host, player_id = player_id, }) end end
--验证登录 functionCMD.auth(account, password) local orm_clinet = get_orm_by_account(account) local account_info = orm_clinet:get_one_entry(account) ifnot account_info then returnnil, CODE.NOT_USER, "NOT_USER" end
password = crypt_util.HMAC.SHA256(password, crypt.base64decode(account_info.key)) if account_info.password ~= password then returnnil, CODE.ERR_PASSWORD, "ERR_PASSWORD" end --log.info("auth >>>>> :", account_info) account_info.last_login_time = time_util.time() orm_clinet:change_save_one_entry(account_info) returntrue, account_info.player_id, account_info.hall_server_id end
1 2 3 4 5 6 7 8 9
--注册 functionM.register(account_info, channel) local cli = frpc_client:instance("centerserver", "account_m") cli:set_mod_num(sbyte(account_info.account, account_info.account:len())) local ret = cli:one_mod_call("register", account_info, channel) ifnot ret thenreturnend